:root {
  --ink: #0f1c2e;
  --ink2: #4a5a6b;
  --paper: #f4f7fa;
  --card: #ffffff;
  --line: #d0d9e3;
  --teal: #0d7a68;
  --teal-d: #0a5c4f;
  --brass: #c9a227;
  --warn: #8a4b12;
  --warn-bg: #fff5e6;
  --shadow: 0 8px 28px rgba(15, 28, 46, 0.08);
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.2;
  margin: 0 0 0.5em;
  letter-spacing: -0.01em;
}

a { color: var(--teal-d); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 5vw;
  background: linear-gradient(135deg, #0f1c2e 0%, #1a2f4a 100%);
  color: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
.top a { color: #fff; text-decoration: none; }
.brand {
  font-family: Georgia, serif;
  font-size: 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
}
.mark {
  width: 24px;
  height: 24px;
  border: 3px solid #fff;
  border-top-color: var(--brass);
  display: inline-block;
  transform: rotate(45deg);
  border-radius: 2px;
}
.top nav a {
  opacity: 0.85;
  margin-left: 22px;
  font-size: 14px;
  font-weight: 500;
  transition: opacity 0.15s;
}
.top nav a:hover { opacity: 1; }

main {
  padding: 32px 5vw 70px;
  max-width: 1480px;
  margin: 0 auto;
}

.foot {
  padding: 24px 5vw;
  color: var(--ink2);
  font-size: 13px;
  border-top: 1px solid var(--line);
  background: #eef2f6;
}

/* Hero + Form */
.hero {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 48px;
  align-items: start;
  padding: 20px 0 40px;
}
.hero h1 {
  font-size: clamp(32px, 4.4vw, 52px);
  margin-bottom: 0.35em;
  color: var(--ink);
}
.hero p {
  font-size: 17.5px;
  color: var(--ink2);
  max-width: 58ch;
  line-height: 1.6;
}
.ticks {
  list-style: none;
  padding: 0;
  margin: 24px 0 0;
}
.ticks li {
  padding-left: 32px;
  margin: 12px 0;
  position: relative;
  font-size: 15.5px;
}
.ticks li:before {
  content: "";
  position: absolute;
  left: 4px;
  top: 8px;
  width: 13px;
  height: 7px;
  border-left: 3px solid var(--teal);
  border-bottom: 3px solid var(--teal);
  transform: rotate(-45deg);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}
.form h2 {
  font-size: 22px;
  margin-bottom: 4px;
  color: var(--ink);
}
.form label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  margin: 16px 0 0;
  color: var(--ink2);
  letter-spacing: 0.01em;
}
.form input[type=text],
.form input[type=number],
.form select,
.form input:not([type]) {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
  border: 1.5px solid #b8c5d2;
  border-radius: 8px;
  background: #fbfcfd;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form input:focus,
.form select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(13, 122, 104, 0.18);
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }

.form .check {
  display: flex;
  gap: 12px;
  align-items: center;
  font-weight: 500;
  color: var(--ink);
  margin-top: 14px;
  cursor: pointer;
}
.check input {
  width: 20px;
  height: 20px;
  accent-color: var(--teal);
  cursor: pointer;
}

.hint {
  font-size: 13px;
  color: var(--ink2);
  margin: 12px 0 0;
  line-height: 1.45;
}
.errors {
  background: #fdecec;
  color: #8c1d1d;
  border-radius: 8px;
  padding: 12px 16px;
  margin: 12px 0;
  font-size: 14px;
  border-left: 4px solid #c53030;
}

.btn {
  display: inline-block;
  padding: 11px 20px;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font: 600 15px/1.2 inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn:hover {
  background: var(--ink);
  color: #fff;
}
.btn.primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
  box-shadow: 0 4px 14px rgba(13, 122, 104, 0.25);
}
.btn.primary:hover {
  background: var(--teal-d);
  border-color: var(--teal-d);
  transform: translateY(-1px);
}
.form .btn {
  width: 100%;
  margin-top: 24px;
  padding: 15px;
  font-size: 16.5px;
  letter-spacing: 0.02em;
}

/* Professional Floor Grid */
.floorgrid {
  margin-top: 20px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fbfcfd;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}
.fg-head,
.fg-row {
  display: grid;
  grid-template-columns: minmax(110px, 1.6fr) repeat(5, minmax(56px, 0.85fr));
  gap: 6px;
  align-items: center;
  padding: 10px 14px;
}
.fg-head {
  background: linear-gradient(135deg, #0f1c2e, #1a2f4a);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.fg-head span {
  display: block;
  text-align: center;
}
.fg-head span:first-child {
  text-align: left;
}
.fg-row {
  border-top: 1px solid var(--line);
  transition: background 0.12s;
}
.fg-row:hover {
  background: #f0f5f8;
}
.fg-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.fg-row input {
  margin: 0 !important;
  padding: 9px 6px !important;
  text-align: center;
  font-weight: 600;
  border-radius: 6px !important;
  border: 1.5px solid #c5d0db !important;
  background: #fff !important;
}
.fg-row input:focus {
  border-color: var(--teal) !important;
  box-shadow: 0 0 0 2px rgba(13, 122, 104, 0.2);
}

/* Recent projects */
.recent h2 { font-size: 22px; margin-bottom: 16px; }
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.chip {
  display: flex;
  flex-direction: column;
  padding: 14px 18px;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink);
  transition: all 0.15s;
  min-width: 200px;
}
.chip strong { font-size: 15px; }
.chip span {
  font-size: 13px;
  color: var(--ink2);
  margin-top: 4px;
}
.chip:hover {
  border-color: var(--teal);
  box-shadow: 0 4px 16px rgba(13, 122, 104, 0.12);
  transform: translateY(-2px);
}

/* Overview / Plan pages */
.head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-end;
  margin-bottom: 24px;
}
.head h1 {
  font-size: clamp(28px, 3.8vw, 42px);
  margin: 0.1em 0;
}
.meta { color: var(--ink2); margin: 0; }
.back { font-size: 14px; text-decoration: none; font-weight: 500; }
.dl {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.dl span {
  font-size: 14px;
  color: var(--ink2);
  margin-right: 4px;
}

.plans {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 28px;
}
.plan {
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}
.plan:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 40px rgba(15, 28, 46, 0.12);
}
.plan img {
  display: block;
  width: 100%;
  height: auto;
  background: #d8eaf6;
}
.plan-body { padding: 22px 24px 24px; }
.plan h3 {
  font-size: 22px;
  margin-bottom: 0.2em;
}
.tag {
  color: var(--ink2);
  margin: 0 0 14px;
  font-size: 14px;
}
.facts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 18px;
  margin: 0 0 14px;
}
.facts div {
  border-left: 3px solid var(--brass);
  padding-left: 12px;
}
.facts dt {
  font-size: 12px;
  color: var(--ink2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.facts dd {
  margin: 2px 0 0;
  font-weight: 600;
  font-size: 15px;
}
.pts {
  padding-left: 20px;
  margin: 8px 0 16px;
}
.pts li { margin: 6px 0; }
.pts.big {
  font-size: 16.5px;
  max-width: 90ch;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.warn {
  background: var(--warn-bg);
  color: var(--warn);
  border-left: 4px solid var(--brass);
  padding: 12px 14px;
  border-radius: 6px;
  font-size: 14px;
}
.warn.wide { max-width: 900px; }
.delete { margin-top: 36px; }
.link {
  background: none;
  border: 0;
  color: #8c1d1d;
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
}

/* Subnav + Stats */
.subnav {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--paper);
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}
.subnav a {
  padding: 8px 16px;
  border-radius: 20px;
  background: #fff;
  border: 1.5px solid var(--line);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s;
}
.subnav a:hover {
  border-color: var(--teal);
  color: var(--teal-d);
}
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin: 12px 0 32px;
}
.stats div {
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}
.stats b {
  display: block;
  font-size: 22px;
  font-family: Georgia, serif;
  color: var(--ink);
}
.stats span {
  font-size: 13px;
  color: var(--ink2);
}
.stats .hl {
  background: linear-gradient(135deg, #0f1c2e, #1a2f4a);
  color: #fff;
  border-color: transparent;
}
.stats .hl span { color: #c9d5e0; }

.block { margin: 40px 0; }
.block h2 {
  font-size: 28px;
  border-bottom: 2px solid var(--line);
  padding-bottom: 10px;
  margin-bottom: 18px;
}
.wide-img {
  display: block;
  width: 100%;
  max-width: 1300px;
  height: auto;
  margin: 12px auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
figure { margin: 0 0 24px; text-align: center; }
figcaption { font-size: 14px; color: var(--ink2); }

.angles {
  display: flex;
  gap: 8px;
  margin: 10px 0;
}
.angles button {
  padding: 8px 16px;
  border: 1.5px solid var(--ink);
  background: #fff;
  border-radius: 8px;
  font: 600 14px inherit;
  cursor: pointer;
  transition: all 0.15s;
}
.angles button.on {
  background: var(--ink);
  color: #fff;
}

.tablewrap {
  overflow-x: auto;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14.5px;
}
th {
  background: linear-gradient(135deg, #0f1c2e, #1a2f4a);
  color: #fff;
  text-align: left;
  padding: 12px 14px;
  white-space: nowrap;
  font-weight: 600;
}
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.rate {
  padding: 3px 12px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
  background: #e4eaf0;
}
.rate.spacious { background: #d0f0e4; color: #0a5c4f; }
.rate.comfortable { background: #e4f0d0; color: #3c5a12; }
.rate.compact { background: #fbe5c8; color: #7a4510; }

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--brass);
  outline-offset: 2px;
}

/* Toolbar + Viewer */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 12px 0;
}
.toolbar button,
.angles button {
  padding: 9px 16px;
  border: 1.5px solid var(--ink);
  background: #fff;
  border-radius: 8px;
  font: 600 14px inherit;
  cursor: pointer;
  color: var(--ink);
  transition: all 0.15s;
}
.toolbar button.on,
.angles button.on {
  background: var(--ink);
  color: #fff;
}
.toolbar.small button {
  border-color: var(--teal);
  color: var(--teal-d);
  font-size: 13px;
}
.toolbar.small button.on {
  background: var(--teal);
  color: #fff;
}
.rng {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}
.rng input { accent-color: var(--teal); }

.viewer {
  position: relative;
  width: 100%;
  height: min(76vh, 740px);
  min-height: 440px;
  border-radius: 14px;
  overflow: hidden;
  border: 1.5px solid var(--line);
  background: linear-gradient(180deg, #a8d4f0 0%, #d4eaf8 100%);
  box-shadow: var(--shadow);
}
.viewer canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.vstatus {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--ink2);
  background: rgba(255,255,255,0.6);
}
.static3d { margin-top: 16px; }
.static3d summary {
  cursor: pointer;
  font-weight: 600;
  padding: 8px 0;
}

/* Quotation */
.quote .qhead {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin: 14px 0;
}
.qhead div {
  background: #fff;
  border: 1.5px solid var(--line);
  border-left: 4px solid var(--brass);
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}
.qhead span {
  display: block;
  font-size: 12px;
  color: var(--ink2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.qhead b { font-size: 16px; margin-top: 2px; display: block; }
.q-dl { margin: 8px 0 16px; }
.qt td.r,
.qt th.r {
  text-align: right;
  white-space: nowrap;
}
.qt tr.sec td {
  background: #e4eaf0;
  font-weight: 700;
  color: var(--ink);
}
.qt tr.sub td {
  background: #f1f5f8;
  font-weight: 700;
}
.qt tr.grand td {
  background: linear-gradient(135deg, #0f1c2e, #1a2f4a);
  color: #fff;
  font-weight: 700;
  font-size: 17px;
}
.qgrid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 28px;
  margin: 24px 0;
}
.words {
  background: #fff8e6;
  border-left: 4px solid var(--brass);
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 15px;
}

.mini {
  width: 100%;
  font-size: 13px;
  margin: 12px 0 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.mini th {
  padding: 7px 10px;
  background: #e4eaf0;
  color: var(--ink);
}
.mini td {
  padding: 7px 10px;
  text-align: center;
}
.mini td:first-child { text-align: left; }

/* Responsive */
@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; gap: 28px; }
  .plans { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: 1fr; }
  .qgrid { grid-template-columns: 1fr; }
  .fg-head,
  .fg-row {
    grid-template-columns: minmax(90px, 1.4fr) repeat(5, minmax(48px, 0.75fr));
    font-size: 12px;
    padding: 8px 10px;
  }
  .fg-head { font-size: 11px; }
}

@media (prefers-reduced-motion: no-preference) {
  .btn { transition: background 0.15s, color 0.15s, transform 0.15s; }
}

@media print {
  .top, .subnav, .toolbar, .viewer, .dl, .foot { display: none; }
}

/* ---- Interactive plan editor ---- */
.editor-wrap {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 20px;
  margin-top: 16px;
  align-items: start;
}
#planEditor {
  width: 100%;
  max-width: 920px;
  height: auto;
  background: #f7f9fb;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  cursor: default;
  box-shadow: var(--shadow);
  touch-action: none;
}
.editor-side {
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.editor-side h3 {
  font-size: 16px;
  margin: 0 0 12px;
}
#roomProps label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink2);
  margin: 10px 0 4px;
}
#roomProps input, #roomProps select {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid #b8c5d2;
  border-radius: 6px;
  font: inherit;
}
#roomProps .hint { margin-top: 0; }
.editor-legend {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--ink2);
}
.editor-legend span {
  display: flex;
  align-items: center;
  gap: 8px;
}
.editor-legend i {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
  border: 1px solid rgba(0,0,0,0.12);
}
@media (max-width: 900px) {
  .editor-wrap { grid-template-columns: 1fr; }
}

/* ---- Professional modal popup ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,28,46,0.45);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-backdrop.show { display: flex; }
.modal-box {
  background: #fff; border-radius: 14px; max-width: 440px; width: 100%;
  box-shadow: 0 20px 50px rgba(15,28,46,0.25);
  border: 1px solid var(--line);
  overflow: hidden; animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.modal-box header {
  padding: 16px 20px; background: linear-gradient(135deg,#0f1c2e,#1a2f4a);
  color: #fff; font-weight: 600; font-size: 16px;
  display: flex; justify-content: space-between; align-items: center;
}
.modal-box header button {
  background: none; border: 0; color: #fff; font-size: 22px;
  cursor: pointer; line-height: 1; opacity: 0.85;
}
.modal-box .modal-body { padding: 20px; }
.modal-box .modal-body p { margin: 0 0 14px; color: var(--ink2); font-size: 14.5px; line-height: 1.5; }
.modal-box .modal-body label {
  display: block; font-size: 12.5px; font-weight: 600; color: var(--ink2); margin: 12px 0 4px;
}
.modal-box .modal-body input,
.modal-box .modal-body select {
  width: 100%; padding: 10px 12px; border: 1.5px solid #b8c5d2;
  border-radius: 8px; font: inherit;
}
.modal-box footer {
  padding: 14px 20px; border-top: 1px solid var(--line);
  display: flex; gap: 10px; justify-content: flex-end; background: #f7f9fb;
}
.modal-box footer .btn { min-width: 90px; }
.custom-rooms-list {
  margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px;
}
.custom-room-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; background: #eef5f3; border: 1px solid #b8d4cc;
  border-radius: 20px; font-size: 13px; font-weight: 600; color: var(--ink);
}
.custom-room-chip button {
  background: none; border: 0; color: #8c1d1d; cursor: pointer;
  font-size: 16px; line-height: 1; padding: 0 2px;
}
.btn-add-room {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 12px; padding: 8px 14px; border: 1.5px dashed var(--teal);
  background: #f0faf7; color: var(--teal-d); border-radius: 8px;
  font: 600 14px inherit; cursor: pointer;
}
.btn-add-room:hover { background: #e0f5ef; }
.btn-add-room span.plus {
  display: inline-flex; width: 22px; height: 22px; border-radius: 50%;
  background: var(--teal); color: #fff; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700;
}
