:root {
  color-scheme: light;
  --navy: #123149;
  --navy-2: #1d4863;
  --ocean: #167b8c;
  --sea: #55b8b0;
  --foam: #e9f7f4;
  --sand: #f3e7cf;
  --coral: #ee795f;
  --green: #12805c;
  --ink: #18313f;
  --muted: #6a7e87;
  --line: #d8e5e5;
  --paper: #fffefa;
  --shadow: 0 18px 50px rgba(18, 49, 73, .12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  background: linear-gradient(145deg, #f6fbfa, #eef5f4);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding: 26px 18px; color: white;
  background:
    radial-gradient(circle at 15% 8%, rgba(85,184,176,.28), transparent 28%),
    linear-gradient(180deg, var(--navy-2), var(--navy));
}
.brand { padding: 4px 10px 24px; border-bottom: 1px solid rgba(255,255,255,.14); }
.brand-kicker, .eyebrow { display: block; letter-spacing: .14em; font-size: .7rem; font-weight: 800; }
.brand strong { display: block; margin: 5px 0; font-family: Georgia, serif; font-size: 1.55rem; }
.brand small { color: #c8e2e2; }
nav { display: grid; gap: 15px; padding: 18px 0; }
.nav-group { display: grid; gap: 5px; }
.nav-group-label {
  padding: 0 10px 4px; color: #83babe; font-size: .64rem; font-weight: 900;
  letter-spacing: .15em; text-transform: uppercase;
}
.nav-group.admin-group {
  margin-top: 8px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.17);
}
.nav-button {
  width: 100%; border: 1px solid transparent; border-radius: 11px; padding: 10px 11px;
  display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 7px;
  background: transparent; color: #d7e8e9; text-align: left; font-weight: 650;
}
.nav-icon {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: rgba(255,255,255,.08); color: #91ded7; font-weight: 900;
}
.nav-button:hover { background: rgba(255,255,255,.08); color: white; transform: translateX(2px); }
.nav-button.active {
  border-color: rgba(127,223,211,.28);
  background: linear-gradient(90deg, rgba(85,184,176,.25), rgba(255,255,255,.08));
  color: white; box-shadow: inset 3px 0 var(--sea);
}
.nav-button.active .nav-icon { background: var(--sea); color: var(--navy); }
.nav-button.dashboard-nav {
  margin-bottom: 7px; border: 1px solid rgba(129, 235, 215, .7);
  background: linear-gradient(135deg, rgba(85,184,176,.32), rgba(255,255,255,.12));
  color: white; font-weight: 900; box-shadow: inset 0 0 18px rgba(85,184,176,.14);
}
.nav-button.dashboard-nav.active { background: var(--sea); color: var(--navy); }
.nav-button.private { color: #ffd9ce; }
.privacy-card { margin-top: 14px; padding: 12px; border: 1px solid rgba(255,255,255,.14); border-radius: 12px; }
.privacy-card span { display: block; color: #99e2cf; font-size: .72rem; font-weight: 900; letter-spacing: .12em; }
.privacy-card small { display: block; margin-top: 4px; color: #c6d9db; }

main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 18px;
  min-height: 92px; padding: 18px 32px; background: rgba(255,254,250,.88);
  border-bottom: 1px solid var(--line); backdrop-filter: blur(14px);
}
.topbar h1 { margin: 2px 0 0; font-family: Georgia, serif; font-size: clamp(1.65rem, 3vw, 2.35rem); color: var(--navy); }
.title-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.eyebrow { margin: 0; color: var(--ocean); }
.kure-badge {
  display: flex; align-items: center; gap: 9px; min-width: 220px; padding: 5px 12px;
  border: 1px solid rgba(22,123,140,.42); border-radius: 17px;
  background: rgba(235,246,240,.9); box-shadow: 0 4px 12px rgba(18,49,73,.06);
}
.kure-badge > span:last-child { display: grid; }
.kure-badge strong { color: var(--navy); font-size: .72rem; line-height: 1.1; letter-spacing: .04em; }
.kure-badge small { color: var(--ocean); font-size: .56rem; letter-spacing: .03em; }
.kure-icon { position: relative; display: block; width: 25px; height: 23px; flex: 0 0 25px; }
.kure-icon i {
  position: absolute; left: 6px; top: 1px; width: 13px; height: 13px;
  border-radius: 50%; background: #f2b455;
}
.kure-icon::before, .kure-icon::after, .kure-icon b {
  content: ""; position: absolute; width: 18px; height: 7px;
  border-top: 2px solid var(--ocean); border-radius: 50%;
}
.kure-icon::before { left: 0; top: 14px; transform: rotate(-6deg); }
.kure-icon::after { left: 10px; top: 14px; transform: rotate(-6deg); }
.kure-icon b { left: 5px; top: 18px; opacity: .65; }
.identity-card { margin-left: auto; display: grid; gap: 1px; text-align: right; }
.identity-card span { color: var(--ocean); font-size: .72rem; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.identity-card strong { color: var(--navy); font-size: .9rem; }
.identity-card small { color: var(--muted); font-size: .7rem; }
.sign-out-button {
  justify-self: end; border: 0; padding: 2px 0; background: transparent;
  color: var(--coral); font-size: .68rem; font-weight: 800;
}
.login-mode .sidebar, .login-mode .topbar, .login-mode .notice { display: none; }
.login-mode .app-shell { display: block; }
.login-mode .content { padding: 0; }
.login-shell {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, rgba(85,184,176,.28), transparent 25%),
    linear-gradient(145deg, var(--navy), var(--navy-2) 55%, var(--ocean));
}
.login-card {
  width: min(440px, 100%); display: grid; gap: 14px; padding: 32px;
  border-radius: 22px; background: var(--paper); box-shadow: var(--shadow);
}
.login-card h2 { margin: 0; color: var(--navy); font-family: Georgia, serif; font-size: 2rem; }
.login-card p { margin: 0; color: var(--muted); }
.login-card label { display: grid; gap: 6px; color: var(--navy); font-size: .8rem; font-weight: 800; }
.login-card input { width: 100%; padding: 11px; border: 1px solid var(--line); border-radius: 9px; }
.login-badge { margin-bottom: 6px; }
.login-message { min-height: 22px; color: var(--coral); font-size: .82rem; }
select { min-width: 120px; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; background: white; color: var(--navy); }
.menu-button { display: none; border: 0; background: transparent; color: var(--navy); font-size: 1.4rem; }
.content { padding: 30px 32px 60px; }
.notice { margin: 18px 32px 0; padding: 12px 16px; border-radius: 10px; background: #fff3cf; color: #6b4c00; }
.loading { padding: 48px; text-align: center; color: var(--muted); }

.hero {
  position: relative; overflow: hidden; min-height: 260px; padding: 34px;
  border-radius: 24px; color: white; box-shadow: var(--shadow);
  background: linear-gradient(115deg, rgba(18,49,73,.97), rgba(22,123,140,.82)), url("assets/house-dashboard-v2.png") center right/contain no-repeat;
}
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent 45%, rgba(255,255,255,.06)); pointer-events: none; }
.hero > * { position: relative; z-index: 1; max-width: 550px; }
.coastal-rule { height: 7px; margin: 20px 0 0; border-radius: 999px; background: linear-gradient(90deg, #59c9be, #f2dfb8, #ef856b); }
.hero h2 { margin: 6px 0 10px; font-family: Georgia, serif; font-size: clamp(2rem, 5vw, 4rem); }
.hero p { color: #d9efee; line-height: 1.6; }
.badge-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.glass-badge { padding: 10px 14px; border: 1px solid rgba(255,255,255,.25); border-radius: 13px; background: rgba(255,255,255,.12); backdrop-filter: blur(10px); }
.glass-badge strong { display: block; font-size: 1.2rem; }
.glass-badge small { color: #cde6e5; }
.completion-card {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: minmax(220px, .8fr) minmax(260px, 1.6fr) 90px;
  align-items: center; gap: 22px; margin-top: 20px; padding: 30px 26px 26px;
  border: 1px solid rgba(85,184,176,.48); border-radius: 22px;
  background:
    radial-gradient(circle at 92% 10%, rgba(242,180,85,.28), transparent 18%),
    linear-gradient(125deg, #f9fffd, #e3f5f3 55%, #eaf0df);
  box-shadow: 0 16px 40px rgba(18,49,73,.12);
}
.completion-card::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .35;
  background-image: radial-gradient(circle, rgba(22,123,140,.25) 1px, transparent 1px);
  background-size: 18px 18px;
}
.completion-card > * { position: relative; z-index: 1; }
.completion-spark {
  position: absolute; top: 0; left: 0; padding: 6px 15px;
  border-radius: 0 0 12px 0; background: linear-gradient(90deg, var(--coral), #f2b455);
  color: white; font-size: .62rem; font-weight: 950; letter-spacing: .16em;
}
.completion-copy strong { display: block; margin: 2px 0; color: var(--navy); font-size: 2rem; }
.completion-copy h3 { margin: 0 0 4px; color: var(--ocean); font-family: Georgia, serif; }
.completion-copy p { margin: 0; color: var(--muted); font-size: .82rem; line-height: 1.4; }
.completion-journey { display: grid; gap: 8px; }
.completion-track { height: 23px; overflow: visible; border: 4px solid white; border-radius: 999px; background: #d6e7e6; box-shadow: 0 5px 16px rgba(18,49,73,.16), inset 0 2px 5px rgba(18,49,73,.12); }
.completion-track span {
  position: relative; display: block; height: 100%; min-width: 5px; border-radius: inherit;
  background: linear-gradient(90deg, #55b8b0, #168ba0, #12805c, #f2b455);
  background-size: 200% 100%; animation: completionShimmer 3s linear infinite;
  transition: width .35s ease;
}
.completion-track span i {
  position: absolute; right: -9px; top: 50%; width: 18px; height: 18px;
  transform: translateY(-50%); border: 3px solid white; border-radius: 50%;
  background: var(--coral); box-shadow: 0 0 0 4px rgba(238,121,95,.2);
}
.completion-milestones { display: flex; justify-content: space-between; color: var(--muted); font-size: .62rem; font-weight: 800; text-transform: uppercase; }
.completion-house {
  display: grid; place-items: center; width: 70px; height: 70px; border-radius: 18px;
  background: linear-gradient(to top, var(--sea) var(--completion), #e4eeee var(--completion));
  color: var(--navy); font-size: 2.8rem; box-shadow: 0 8px 20px rgba(18,49,73,.14), inset 0 0 0 1px rgba(18,49,73,.1);
}
.completion-house span { animation: houseFloat 2.8s ease-in-out infinite; }
.completion-waves { position: absolute; right: -30px; bottom: -9px; display: flex; opacity: .32; }
.completion-waves i { width: 72px; height: 25px; margin-left: -18px; border-top: 4px solid var(--ocean); border-radius: 50%; }
@keyframes completionShimmer { to { background-position: -200% 0; } }
@keyframes houseFloat { 50% { transform: translateY(-4px); } }
.concept-note { padding: 8px 10px; border-left: 3px solid var(--coral); background: #fff3ef; color: #8f3c2b !important; font-size: .78rem; font-weight: 750; }

.stats, .card-grid, .floor-grid { display: grid; gap: 16px; margin-top: 20px; }
.stats { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.dashboard-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.floor-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card, .stat, .panel {
  border: 1px solid var(--line); border-radius: 16px; background: var(--paper); box-shadow: 0 8px 26px rgba(18,49,73,.06);
}
.stat { padding: 18px; }
.stat strong { display: block; color: var(--navy); font-size: 1.45rem; }
.stat small { color: var(--muted); }
.card { overflow: hidden; }
.card-image { height: 160px; background: var(--foam) center/cover no-repeat; border-bottom: 1px solid var(--line); }
.pool-image-card { cursor: zoom-in; transition: transform .18s ease, box-shadow .18s ease; }
.pool-image-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card-body { padding: 18px; }
.card h3, .panel h2, .panel h3 { margin: 0 0 8px; color: var(--navy); }
.card p, .panel p { color: var(--muted); line-height: 1.55; }
.panel { padding: 22px; margin-bottom: 18px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin: 30px 0 14px; }
.section-heading h2 { margin: 0; color: var(--navy); font-family: Georgia, serif; font-size: 1.75rem; }
.section-heading p { margin: 0; color: var(--muted); }
.button {
  border: 0; border-radius: 10px; padding: 10px 14px; background: var(--ocean); color: white; font-weight: 800;
}
.button.secondary { background: var(--navy); }
.button.coral { background: var(--coral); }
.button.green { background: var(--green); }
.button.ghost { background: var(--foam); color: var(--ocean); }

.tabs { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 18px; padding-bottom: 4px; }
.tab { white-space: nowrap; border: 1px solid var(--line); border-radius: 999px; padding: 8px 13px; background: white; color: var(--navy); }
.tab.active { border-color: var(--ocean); background: var(--ocean); color: white; }
.note-group { margin-bottom: 14px; padding: 16px; border-left: 4px solid var(--sea); border-radius: 10px; background: #f8fbfa; }
.note-group h3 { margin: 0 0 8px; color: var(--navy); }
.note-editor, .reference-editor {
  width: 100%; min-height: 120px; resize: vertical; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; background: white; color: var(--ink); line-height: 1.5;
}
.reference-editor { min-height: 360px; }
.private-banner { padding: 12px 15px; border-radius: 10px; background: #fff0ec; color: #963e2a; font-weight: 800; }

.plan-panel { padding: 0; overflow: hidden; }
.plan-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border-bottom: 1px solid var(--line); background: #eef7f5;
}
.plan-toolbar > div { display: flex; gap: 7px; flex-wrap: wrap; }
.plan-viewport {
  height: min(62vh, 620px); overflow: auto; display: grid; place-items: center;
  background: #dfeeed; cursor: grab;
}
.plan-viewport img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  transform-origin: center; transition: transform .12s ease;
}
.image-viewer {
  position: fixed; inset: 0; z-index: 100; display: grid; grid-template-rows: auto 1fr;
  background: rgba(8,24,36,.94); color: white;
}
.image-viewer-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 18px; background: var(--navy);
}
.image-viewer-bar > div { display: flex; gap: 8px; }
.image-viewer-stage { overflow: auto; display: grid; place-items: center; padding: 20px; }
.image-viewer-stage img {
  max-width: 92vw; max-height: 82vh; object-fit: contain; transform-origin: center;
  transition: transform .12s ease;
}

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: white; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { position: sticky; top: 0; background: #eef7f5; color: var(--navy); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; }
td.number { text-align: right; font-variant-numeric: tabular-nums; }
.status-pill { display: inline-block; border-radius: 999px; padding: 4px 8px; background: var(--foam); color: var(--green); font-size: .74rem; font-weight: 800; }
.cost-table-wrap { overflow-x: visible; }
.cost-table { min-width: 0; table-layout: fixed; font-size: clamp(.66rem, .7vw, .78rem); }
.cost-table th { background: var(--navy); color: white; top: 0; }
.cost-table th, .cost-table td { padding: 6px 5px; overflow-wrap: anywhere; }
.cost-table th:nth-child(1) { width: 22%; }
.cost-table th:nth-child(2) { width: 8%; }
.cost-table th:nth-child(3) { width: 8%; }
.cost-table th:nth-child(4) { width: 8%; }
.cost-table th:nth-child(5) { width: 10%; }
.cost-table th:nth-child(6) { width: 4%; }
.cost-table th:nth-child(7) { width: 10%; }
.cost-table th:nth-child(8) { width: 22%; }
.cost-table th:nth-child(9) { width: 8%; }
.cost-table input:not([type="checkbox"]), .cost-table select {
  width: 100%; min-width: 0; padding: 6px 5px; border: 1px solid #cbdcdc;
  border-radius: 7px; background: white; color: var(--ink);
}
.cost-table .cost-notes { min-width: 0; }
.cost-table .cost-actual { background: #f8fcf5; text-align: right; }
.cost-table .cost-section { min-width: 0; font-weight: 600; }
.cost-level-0 { background: #cadcf0; color: var(--navy); font-weight: 900; }
.cost-level-0 .cost-section { font-size: .9rem; }
.cost-level-1 .cost-section { padding-left: 28px; }
.cost-level-2 .cost-section { padding-left: 52px; font-weight: 500; }
.cost-level-1.structural-row { background: #f3f7f9; font-weight: 800; }
.cost-difference.under-budget { background: #ebf6ed; color: #246b3b; }
.cost-difference.over-budget { background: #ffe7e1; color: #a53b29; }
.included-row { background: #faf7ec; }
.included-label { display: inline-block; padding: 4px 7px; border-radius: 999px; background: var(--sand); color: #75582e; font-weight: 850; }
.timeline { display: grid; gap: 14px; }
.timeline-item { display: grid; grid-template-columns: 100px 1fr; gap: 16px; }
.timeline-date { color: var(--ocean); font-weight: 800; }
.asset-list { display: grid; gap: 10px; }
.asset-row { display: flex; align-items: center; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.asset-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 9px; background: var(--sand); }
.asset-row .button { margin-left: auto; }
.asset-thumb { width: 72px; height: 54px; object-fit: cover; border-radius: 8px; background: var(--foam); }
.upload-zone {
  display: grid; place-items: center; min-height: 130px; padding: 22px;
  border: 2px dashed #94c8c5; border-radius: 14px; background: #f5fbfa; text-align: center;
}
.upload-zone input { max-width: 100%; }
.compact-upload {
  display: inline-flex; align-items: center; justify-content: center; margin: 10px 0;
  padding: 8px 11px; border: 1px dashed var(--ocean); border-radius: 9px;
  background: var(--foam); color: var(--ocean); font-size: .78rem; font-weight: 850;
  cursor: pointer;
}
.compact-upload input, .compact-special-upload input { display: none; }
.compact-special-upload { min-height: 72px; margin-top: 12px; cursor: pointer; }
.mini-asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; margin: 10px 0; }
.mini-asset {
  min-width: 0; padding: 5px; border: 1px solid var(--line); border-radius: 9px;
  background: white; color: var(--navy); cursor: pointer;
}
.mini-asset img { width: 100%; height: 66px; object-fit: cover; border-radius: 6px; }
.mini-asset > span { display: grid; place-items: center; height: 66px; background: var(--sand); border-radius: 6px; font-size: .68rem; font-weight: 900; }
.mini-asset small { display: block; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-upload-empty { margin: 8px 0; color: var(--muted); font-size: .76rem; font-style: italic; }
.admin-grid { display: grid; gap: 12px; }
.admin-row {
  display: grid; grid-template-columns: minmax(210px, 1fr) 140px 180px 90px;
  align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line);
  border-radius: 12px; background: white;
}
.admin-row input, .admin-row select { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.sync-card { border-left: 4px solid var(--green); background: #f1fbf7; }
.empty { padding: 26px; border: 1px dashed #b8cccc; border-radius: 12px; color: var(--muted); text-align: center; }
.builder-hidden { display: none !important; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .completion-card { grid-template-columns: 1fr; }
  .completion-house { display: none; }
  .cost-table-wrap { overflow-x: auto; }
  .cost-table { min-width: 1050px; }
}
@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 30; width: 270px; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .menu-button { display: block; }
  .topbar { padding: 14px 18px; }
  .kure-badge { min-width: 190px; }
  .kure-badge small { display: none; }
  .content { padding: 20px 16px 48px; }
  .notice { margin: 14px 16px 0; }
  .stats, .card-grid, .floor-grid { grid-template-columns: 1fr; }
  .hero { padding: 26px 22px; background-position: center bottom; }
  .identity-card small { display: none; }
  .identity-card strong { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
  .timeline-item { grid-template-columns: 1fr; gap: 4px; }
  .admin-row { grid-template-columns: 1fr; }
}
