/* ==========================================================================
   Aseman Builders design system v3: mobile-first, then widen.
   1 Tokens  2 Base  3 Controls  4 Feedback  5 Data display  6 Public site
   7 Staff shell  8 Portal shell  9 Dashboard  10 Explorer / tours  11 Desktop
   ========================================================================== */

@font-face {
  font-family: 'Vazirmatn';
  src: url("../fonts/Vazirmatn-Variable.f6d31671339d.woff2") format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* 1. Tokens ------------------------------------------------------------- */
:root {
  --c-ink: #0b1324;
  --c-ink-2: #2c3a52;
  --c-muted: #64708a;
  --c-faint: #97a3b8;
  --c-line: #e6e9f0;
  --c-line-2: #f0f2f7;
  --c-bg: #f3f5fa;
  --c-surface: #ffffff;

  --c-brand: #2a55e5;
  --c-brand-2: #1f43c0;
  --c-brand-soft: #eaf0ff;
  --c-deep: #0d1a3a;
  --c-deep-2: #17307a;
  --c-gold: #e0a42b;
  --c-gold-soft: #fff4d8;

  --c-ok: #0f8a4f;
  --c-ok-soft: #e3f6ec;
  --c-warn: #b36a00;
  --c-warn-soft: #fff1d6;
  --c-bad: #d1343b;
  --c-bad-soft: #fde8e9;
  --c-info: #2a64a8;
  --c-info-soft: #e7f0fa;

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --shadow-1: 0 1px 2px rgba(13, 26, 58, 0.04), 0 6px 18px -10px rgba(13, 26, 58, 0.12);
  --shadow-2: 0 18px 40px -18px rgba(13, 26, 58, 0.35);
  --shadow-glow: 0 14px 30px -14px rgba(42, 85, 229, 0.65);
  --font: 'Vazirmatn', Tahoma, system-ui, sans-serif;
  --focus: 0 0 0 3px rgba(42, 85, 229, 0.28);
  --tabbar-h: 68px;
}

/* 2. Base ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--c-bg); color: var(--c-ink);
  font-family: var(--font); font-size: 15px; line-height: 1.75;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { color: var(--c-ink); line-height: 1.35; margin: 0; }
p { margin: 0 0 12px; }
a { color: var(--c-brand); }
img { max-width: 100%; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 8px; }
.icon { width: 20px; height: 20px; flex: none; }
.icon.flip { transform: scaleX(-1); }
.num, .kpi-value, td.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--c-muted); }
.small { font-size: 13px; }
.stack { display: grid; gap: 20px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }
.container { width: min(1200px, 100% - 32px); margin-inline: auto; }
.inline-form { display: inline; margin: 0; }
a, button, select, summary, label[for], .btn { cursor: pointer; }

/* 3. Controls ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px; border-radius: var(--r-md); border: 1px solid transparent;
  font: inherit; font-size: 15px; font-weight: 700; text-decoration: none; white-space: nowrap;
  transition: transform .12s, background-color .15s, border-color .15s, box-shadow .15s;
}
.btn:active { transform: scale(.97); }
.btn .icon { width: 18px; height: 18px; }
.btn-primary { background: var(--c-brand); color: #fff; box-shadow: var(--shadow-glow); }
.btn-primary:hover { background: var(--c-brand-2); }
.btn-secondary { background: var(--c-surface); border-color: #d5dbe7; color: var(--c-ink); }
.btn-secondary:hover { background: var(--c-line-2); }
.btn-ghost { background: transparent; color: var(--c-brand); padding: 0 12px; }
.btn-ghost:hover { background: var(--c-brand-soft); }
.btn-danger { background: var(--c-surface); border-color: #f2c4c7; color: var(--c-bad); }
.btn-danger:hover { background: var(--c-bad-soft); }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 13.5px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn[disabled], button:disabled { opacity: .5; cursor: not-allowed; }
button.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--c-brand); font-weight: 700; }
.icon-btn {
  position: relative; width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center;
  color: var(--c-ink-2); text-decoration: none; border: 0; background: transparent;
}
.icon-btn:hover { background: var(--c-line-2); }
.icon-btn .dot {
  position: absolute; top: 5px; inset-inline-end: 5px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--c-bad); color: #fff; font-size: 10.5px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--c-surface);
}

.form-grid { display: grid; grid-template-columns: 1fr; gap: 18px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > label, .field-label { font-size: 13.5px; font-weight: 700; color: var(--c-ink-2); }
.field input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
.field select, .field textarea {
  width: 100%; min-height: 50px; padding: 12px 16px; font: inherit; font-size: 16px; color: var(--c-ink);
  background: var(--c-surface); border: 1.5px solid #d5dbe7; border-radius: var(--r-md);
  transition: border-color .15s, box-shadow .15s; -webkit-appearance: none; appearance: none;
}
.field select {
  background-image: linear-gradient(45deg, transparent 50%, #7a869c 50%), linear-gradient(135deg, #7a869c 50%, transparent 50%);
  background-position: 18px 54%, 24px 54%; background-size: 6px 6px; background-repeat: no-repeat; padding-inline-start: 38px;
}
.field textarea { min-height: 110px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--c-brand); box-shadow: var(--focus); }
.field input:disabled, .field select:disabled { background: var(--c-line-2); color: var(--c-faint); }
.field input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--c-brand); }
.field-check { flex-direction: row; align-items: center; gap: 12px; }
.field .help { font-size: 12.5px; color: var(--c-muted); }
.field .error { font-size: 12.5px; color: var(--c-bad); font-weight: 700; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 26px; flex-wrap: wrap; }
.form-actions .btn { flex: 1 1 140px; }
.form-errors { margin-bottom: 16px; }

/* 4. Feedback ------------------------------------------------------------ */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 700; line-height: 1.6; background: var(--c-line-2); color: var(--c-ink-2); white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-brand { background: var(--c-brand-soft); color: var(--c-brand); }
.badge-ok, .badge-success { background: var(--c-ok-soft); color: var(--c-ok); }
.badge-warn, .badge-warning { background: var(--c-warn-soft); color: var(--c-warn); }
.badge-bad, .badge-danger { background: var(--c-bad-soft); color: var(--c-bad); }
.badge-info { background: var(--c-info-soft); color: var(--c-info); }
.badge-gold { background: var(--c-gold-soft); color: #8a6212; }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-md); margin-bottom: 14px; font-size: 14px; border: 1px solid transparent; }
.alert-success { background: var(--c-ok-soft); color: #0b5c35; border-color: #bfe8d2; }
.alert-error, .alert-danger { background: var(--c-bad-soft); color: #8d1f25; border-color: #f4c3c6; }
.alert-warning { background: var(--c-warn-soft); color: #6d4200; border-color: #f2dba8; }
.alert-info { background: var(--c-info-soft); color: #1d4f85; border-color: #c9dcf1; }
.flash-stack { margin-bottom: 14px; }

.empty-state { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 40px 20px; text-align: center; color: var(--c-muted); }
.empty-state .icon { width: 38px; height: 38px; color: var(--c-faint); }

.progress { height: 9px; border-radius: 999px; background: var(--c-line-2); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: var(--c-brand); }
.ring { width: 76px; height: 76px; flex: none; }
.ring-track { fill: none; stroke: var(--c-line-2); stroke-width: 3.4; }
.ring-value { fill: none; stroke: var(--c-brand); stroke-width: 3.4; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; }
.ring-text { font-size: 7.5px; font-weight: 700; fill: var(--c-ink); text-anchor: middle; font-family: var(--font); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px; border-radius: 999px; background: var(--c-line-2); color: var(--c-ink-2); font-size: 12.5px; text-decoration: none; }
.chip strong { color: var(--c-ink); }
.chip .icon { width: 14px; height: 14px; }
.chip-ok { background: var(--c-ok-soft); color: var(--c-ok); }
.chip-ok strong { color: var(--c-ok); }

/* 5. Data display -------------------------------------------------------- */
.page-header { display: flex; flex-direction: column; gap: 14px; margin-bottom: 20px; }
.page-eyebrow { font-size: 12.5px; font-weight: 700; color: var(--c-brand); margin-bottom: 2px; }
.page-title { font-size: 24px; font-weight: 800; }
.page-desc { color: var(--c-muted); margin-top: 6px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.page-actions .btn { flex: 1 1 auto; }
.crumbs { font-size: 13px; color: var(--c-muted); display: flex; gap: 6px; align-items: center; min-width: 0; overflow: hidden; white-space: nowrap; }
.crumbs a { color: var(--c-muted); text-decoration: none; }
.crumbs .icon { width: 14px; height: 14px; }

.panel { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); min-width: 0; overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--c-line-2); flex-wrap: wrap; }
.panel-title { font-size: 16px; font-weight: 800; }
.panel-desc { font-size: 13px; color: var(--c-muted); margin-top: 2px; }
.panel-body { padding: 18px; }
.panel-body.flush { padding: 0; }
.panel-foot { padding: 14px 18px; border-top: 1px solid var(--c-line-2); font-size: 13px; color: var(--c-muted); }

.kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: 16px; display: flex; flex-direction: column; gap: 8px; min-width: 0; text-decoration: none; color: inherit; }
a.kpi { transition: transform .15s, border-color .15s; }
a.kpi:active { transform: scale(.98); }
.kpi-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kpi-label { font-size: 12.5px; font-weight: 700; color: var(--c-muted); line-height: 1.5; }
.kpi-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--c-brand-soft); color: var(--c-brand); flex: none; }
.kpi-icon .icon { width: 19px; height: 19px; }
.kpi-value { font-size: 20px; font-weight: 800; color: var(--c-ink); line-height: 1.3; }
.kpi-value.small-value { font-size: 17px; }
.kpi-note { font-size: 12px; color: var(--c-muted); line-height: 1.6; }
.kpi-note a { font-weight: 700; }
.kpi.tone-ok .kpi-icon { background: var(--c-ok-soft); color: var(--c-ok); }
.kpi.tone-warn .kpi-icon { background: var(--c-warn-soft); color: var(--c-warn); }
.kpi.tone-bad .kpi-icon { background: var(--c-bad-soft); color: var(--c-bad); }
.kpi.tone-bad .kpi-value { color: var(--c-bad); }
.kpi.tone-warn .kpi-value { color: var(--c-warn); }

.two-col { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
.stack-col { display: grid; gap: 16px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
table.data th { text-align: right; font-size: 12.5px; font-weight: 700; color: var(--c-muted); padding: 12px 16px; background: #fafbfd; border-bottom: 1px solid var(--c-line); white-space: nowrap; }
table.data td { padding: 14px 16px; border-bottom: 1px solid var(--c-line-2); color: var(--c-ink-2); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td a.cell-link { color: var(--c-ink); font-weight: 700; text-decoration: none; }
table.data td a.cell-link:hover { color: var(--c-brand); }
table.data tfoot th { background: var(--c-brand-soft); color: var(--c-brand); border-bottom: 0; }

.dl { display: grid; grid-template-columns: minmax(96px, max-content) 1fr; gap: 12px 20px; margin: 0; font-size: 14px; }
.dl dt { color: var(--c-muted); font-weight: 700; }
.dl dd { margin: 0; color: var(--c-ink); }
.pager { display: flex; gap: 12px; justify-content: center; align-items: center; font-size: 14px; color: var(--c-muted); }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.timeline li { display: grid; grid-template-columns: 10px 1fr; gap: 12px; font-size: 14px; }
.timeline li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--c-brand); margin-top: 8px; box-shadow: 0 0 0 4px var(--c-brand-soft); }
.timeline .when { font-size: 12.5px; color: var(--c-muted); }
.stage-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.stage-item { display: grid; gap: 8px; }
.stage-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; }
.stage-meta { font-size: 12.5px; color: var(--c-muted); font-weight: 400; }
.photo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.photo-grid img { width: 100%; height: 120px; object-fit: cover; border-radius: var(--r-md); border: 1px solid var(--c-line); }
.photo-grid figcaption { font-size: 12px; color: var(--c-muted); margin-top: 4px; }
.chart-box { position: relative; height: 230px; }
.search-hit { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--c-line-2); }
.search-hit:last-child { border-bottom: 0; }
.search-kind { font-size: 12px; font-weight: 800; color: var(--c-brand); }

/* 6. Public site ----------------------------------------------------------- */
.site-header { background: rgba(255, 255, 255, 0.86); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px); border-bottom: 1px solid rgba(13, 26, 58, 0.06); position: sticky; top: 0; z-index: 30; }
.site-nav { height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; color: var(--c-ink); }
.brand-mark { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; background: linear-gradient(145deg, var(--c-brand), var(--c-deep-2)); color: #fff; font-weight: 800; font-size: 19px; box-shadow: var(--shadow-glow); flex: none; }
.brand-name { font-weight: 800; font-size: 15px; line-height: 1.25; display: block; }
.brand-sub { display: block; font-size: 11.5px; color: var(--c-muted); font-weight: 500; }
.site-links { display: flex; align-items: center; gap: 4px; }
.site-links a { color: var(--c-ink-2); text-decoration: none; font-size: 14px; font-weight: 700; padding: 8px 12px; border-radius: 12px; }
.site-links a:hover { background: var(--c-line-2); }
.site-links a.btn { color: #fff; }
.site-main { padding: 16px 0 56px; }

.hero {
  position: relative; overflow: hidden; border-radius: var(--r-xl); color: #fff; padding: 30px 22px 26px;
  background: radial-gradient(520px 260px at 12% 0%, rgba(42, 85, 229, .55), transparent 70%), radial-gradient(420px 260px at 100% 100%, rgba(224, 164, 43, .28), transparent 70%), linear-gradient(160deg, var(--c-deep), var(--c-deep-2));
}
.hero::before { content: ""; position: absolute; inset: 0; pointer-events: none; background-image: linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px); background-size: 44px 44px; mask-image: linear-gradient(to bottom, #000, transparent 85%); -webkit-mask-image: linear-gradient(to bottom, #000, transparent 85%); }
.hero-inner { position: relative; max-width: 640px; }
.hero-kicker { display: inline-flex; align-items: center; gap: 8px; color: #ffd98a; font-weight: 700; font-size: 13px; margin-bottom: 12px; background: rgba(255, 255, 255, .08); padding: 5px 12px; border-radius: 999px; }
.hero h1 { color: #fff; font-size: 30px; line-height: 1.35; margin-bottom: 12px; font-weight: 800; }
.hero p { color: #c4cee3; font-size: 15px; }
.hero-actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.hero-actions .btn { flex: 1 1 150px; }
.hero .btn-secondary { background: rgba(255, 255, 255, .1); color: #fff; border-color: rgba(255, 255, 255, .25); }
.hero-stats { position: relative; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 26px; }
.hero-stat { background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .1); border-radius: 16px; padding: 12px; }
.hero-stat strong { display: block; font-size: 22px; color: #fff; font-variant-numeric: tabular-nums; line-height: 1.3; }
.hero-stat span { font-size: 12px; color: #aab8d6; }

.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin: 30px 0 14px; flex-wrap: wrap; }
.section-head h2 { font-size: 20px; font-weight: 800; }
.section-head p { color: var(--c-muted); margin: 4px 0 0; font-size: 14px; }

.project-grid, .pgrid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.project-card, .pcard { display: flex; flex-direction: column; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-xl); overflow: hidden; text-decoration: none; color: inherit; box-shadow: var(--shadow-1); transition: transform .2s, box-shadow .2s; }
.project-card:active, .pcard:active { transform: scale(.985); }
.project-cover, .pcard-cover {
  position: relative; height: 140px; color: #fff; overflow: hidden; display: flex; align-items: flex-end; justify-content: space-between; padding: 14px 16px;
  background: radial-gradient(240px 140px at 80% 0%, rgba(224, 164, 43, .35), transparent 70%), linear-gradient(150deg, var(--c-brand), var(--c-deep-2));
}
.project-cover::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255, 255, 255, .07) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .07) 1px, transparent 1px); background-size: 28px 28px; }
.project-cover .code, .pcard-code { position: relative; font-size: 13px; color: #ffe2a6; font-weight: 800; letter-spacing: .03em; }
.project-cover .status { position: relative; }
.skyline { position: absolute; inset: 0; width: 100%; height: 100%; }
.pcard-code { position: absolute; inset-inline-start: 16px; top: 14px; }
.pcard-status { position: absolute; inset-inline-end: 14px; top: 12px; }
.project-body, .pcard-body { padding: 16px 18px 18px; display: grid; gap: 12px; }
.project-body h3, .pcard-head h3 { font-size: 18px; font-weight: 800; }
.project-meta { font-size: 13px; color: var(--c-muted); display: flex; gap: 6px; align-items: center; }
.project-meta .icon { width: 16px; height: 16px; }
.project-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 12px; border-top: 1px solid var(--c-line-2); font-size: 13px; color: var(--c-muted); }
.project-foot strong { color: var(--c-ink); }
.pcard-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.pcard-head .ring { width: 60px; height: 60px; }
.pcard-go { display: inline-flex; align-items: center; gap: 6px; color: var(--c-brand); font-weight: 800; font-size: 14px; }

.detail-hero { display: grid; grid-template-columns: 1fr; gap: 20px; align-items: center; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-xl); padding: 22px; box-shadow: var(--shadow-1); }
.detail-hero h1 { font-size: 26px; font-weight: 800; }
.detail-hero .meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--c-muted); font-size: 14px; margin-top: 8px; }
.detail-hero .meta span { display: inline-flex; gap: 6px; align-items: center; }
.detail-hero .meta .icon { width: 16px; height: 16px; }
.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 16px; }
.fact { background: var(--c-bg); border-radius: var(--r-md); padding: 12px 14px; }
.fact span { display: block; font-size: 12px; color: var(--c-muted); font-weight: 700; }
.fact strong { font-size: 15px; color: var(--c-ink); }
.building-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.building-card { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-lg); padding: 18px; display: grid; gap: 12px; }
.building-card .numbers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.building-card .numbers div { background: var(--c-bg); border-radius: 12px; padding: 10px; text-align: center; }
.building-card .numbers strong { display: block; font-size: 18px; color: var(--c-ink); }
.building-card .numbers span { font-size: 12px; color: var(--c-muted); }
.login-wrap { min-height: 66vh; display: grid; place-items: center; padding: 8px 0; }
.login-card { width: min(440px, 100%); }
.login-card .panel-body { padding: 26px 22px; }
.login-card h1 { font-size: 24px; margin-bottom: 6px; font-weight: 800; }
.site-footer { color: var(--c-muted); font-size: 13px; padding: 24px 0 30px; }
.site-footer .container { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* 7. Staff shell (phone first) ---------------------------------------------- */
.app { min-height: 100vh; }
.sidebar { display: none; }
.workspace { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: rgba(255, 255, 255, .88); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px); border-bottom: 1px solid rgba(13, 26, 58, .06); flex-wrap: wrap; }
.topbar-brand { display: block; text-decoration: none; }
.topbar-brand .brand-mark { width: 38px; height: 38px; font-size: 18px; }
.topbar .crumbs { flex: 1; }
.search-form { position: relative; display: none; order: 5; flex: 1 1 100%; margin: 0 0 6px; }
.search-form.is-open { display: block; }
.search-form .icon { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--c-faint); pointer-events: none; }
.search-form input { width: 100%; height: 48px; padding: 0 44px 0 16px; border-radius: 14px; border: 1.5px solid #d5dbe7; background: var(--c-bg); font: inherit; font-size: 16px; }
.search-form input:focus { outline: none; border-color: var(--c-brand); background: #fff; box-shadow: var(--focus); }
.topbar-actions { display: flex; align-items: center; gap: 2px; }
.content { padding: 18px 16px calc(var(--tabbar-h) + 44px); width: 100%; }

.tabbar, .bottom-nav {
  position: fixed; z-index: 40; inset-inline: 12px; bottom: calc(10px + env(safe-area-inset-bottom));
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 6px;
  background: rgba(255, 255, 255, .94); backdrop-filter: saturate(160%) blur(16px); -webkit-backdrop-filter: saturate(160%) blur(16px);
  border: 1px solid rgba(13, 26, 58, .07); border-radius: 26px; box-shadow: 0 16px 36px -12px rgba(13, 26, 58, .38);
}
.tabbar a, .tabbar button, .bottom-nav a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 54px; border: 0; background: transparent; border-radius: 20px; font: inherit; font-size: 11.5px; font-weight: 700;
  color: var(--c-muted); text-decoration: none;
}
.tabbar .icon, .bottom-nav .icon { width: 22px; height: 22px; }
.tabbar a.is-active, .bottom-nav a.is-active { color: var(--c-brand); background: var(--c-brand-soft); }
.bottom-nav .badge-count { position: absolute; top: 4px; inset-inline-end: calc(50% - 22px); background: var(--c-bad); color: #fff; font-size: 10px; min-width: 17px; height: 17px; border-radius: 999px; display: grid; place-items: center; padding: 0 4px; }

.sheet { position: fixed; inset: 0; z-index: 60; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(8, 15, 35, .5); animation: fade .2s ease; }
.sheet-panel { position: absolute; inset-inline: 0; bottom: 0; max-height: 88vh; overflow-y: auto; background: var(--c-surface); border-radius: 28px 28px 0 0; padding: 10px 18px calc(24px + env(safe-area-inset-bottom)); animation: rise .25s cubic-bezier(.2, .8, .2, 1); }
.sheet-handle { width: 44px; height: 5px; border-radius: 3px; background: #d5dbe7; margin: 4px auto 14px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.sheet-nav .nav-group { margin-bottom: 8px; }
body.sheet-open { overflow: hidden; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.nav-group { display: grid; gap: 3px; }
.nav-group-title { font-size: 12px; font-weight: 800; color: var(--c-faint); padding: 8px 12px 4px; }
.nav-link { position: relative; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; color: var(--c-ink-2); text-decoration: none; font-size: 15px; font-weight: 600; }
.nav-link .icon { width: 21px; height: 21px; opacity: .8; }
.nav-link:hover { background: var(--c-line-2); }
.nav-link.is-active { background: var(--c-brand-soft); color: var(--c-brand); font-weight: 800; }
.nav-link .count { margin-inline-start: auto; background: var(--c-bad); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; }

/* 8. Customer portal (phone first) ------------------------------------------- */
.portal-body { background: var(--c-bg); min-height: 100vh; }
.app-bar { position: sticky; top: 0; z-index: 20; height: 60px; background: rgba(255, 255, 255, .88); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px); border-bottom: 1px solid rgba(13, 26, 58, .06); display: flex; align-items: center; justify-content: space-between; padding: 0 14px; }
.app-bar .brand-mark { width: 36px; height: 36px; font-size: 17px; }
.portal-main { max-width: 720px; margin-inline: auto; padding: 16px 16px calc(var(--tabbar-h) + 44px); display: grid; gap: 18px; }
.greeting h1 { font-size: 22px; font-weight: 800; }
.greeting p { color: var(--c-muted); font-size: 14px; margin-top: 2px; }
.balance, .hero-card {
  position: relative; overflow: hidden; color: #fff; border-radius: var(--r-xl); padding: 22px; box-shadow: var(--shadow-2);
  background: radial-gradient(300px 200px at 0% 0%, rgba(42, 85, 229, .6), transparent 70%), radial-gradient(260px 200px at 100% 100%, rgba(224, 164, 43, .3), transparent 70%), linear-gradient(155deg, var(--c-deep), var(--c-deep-2));
}
.balance::before, .hero-card::before { content: ""; position: absolute; inset: 0; pointer-events: none; background-image: linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px); background-size: 32px 32px; mask-image: linear-gradient(to bottom, #000, transparent 80%); -webkit-mask-image: linear-gradient(to bottom, #000, transparent 80%); }
.balance > *, .hero-card > * { position: relative; }
.balance-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.balance-top span { font-size: 13px; color: #b6c3e0; font-weight: 700; }
.balance-top strong { display: block; font-size: 28px; margin-top: 4px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.3; }
.balance .ring-track { stroke: rgba(255, 255, 255, .16); }
.balance .ring-value { stroke: #ffd98a; }
.balance .ring-text { fill: #fff; }
.balance-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.balance-grid div { background: rgba(255, 255, 255, .09); border: 1px solid rgba(255, 255, 255, .08); border-radius: 16px; padding: 12px 14px; }
.balance-grid span { display: block; font-size: 12px; color: #b6c3e0; font-weight: 700; }
.balance-grid strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.next-due { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 12px 14px; background: rgba(224, 164, 43, .22); border-radius: 16px; font-size: 14px; }
.next-due .icon { color: #ffd98a; }
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quick { display: flex; flex-direction: column; align-items: center; gap: 8px; text-decoration: none; color: var(--c-ink-2); font-size: 12.5px; font-weight: 700; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: 20px; padding: 14px 4px; box-shadow: var(--shadow-1); }
.quick:active { transform: scale(.96); }
.quick .kpi-icon { width: 42px; height: 42px; }
.contract-card { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-lg); padding: 18px; display: grid; gap: 12px; text-decoration: none; color: inherit; box-shadow: var(--shadow-1); }
.contract-card:active { transform: scale(.985); }
.contract-card .head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.contract-card h3 { font-size: 16px; font-weight: 800; }
.contract-card .sub { font-size: 13px; color: var(--c-muted); }
.contract-card .amounts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 13px; color: var(--c-muted); }
.contract-card .amounts strong { display: block; color: var(--c-ink); font-size: 14px; font-variant-numeric: tabular-nums; }
.stat-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-tile { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: 18px; padding: 14px 16px; display: grid; gap: 4px; }
.stat-tile span { font-size: 12.5px; color: var(--c-muted); font-weight: 700; }
.stat-tile strong { font-size: 17px; font-variant-numeric: tabular-nums; }

/* 9. Dashboard (bento) ---------------------------------------------------------- */
.bento { display: grid; grid-template-columns: 1fr; gap: 14px; }
.hero-card-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; color: #b6c3e0; font-weight: 700; }
.hero-card-value { font-size: 34px; font-weight: 800; margin: 10px 0 2px; line-height: 1.25; font-variant-numeric: tabular-nums; }
.hero-card-sub { color: #b6c3e0; font-size: 13.5px; }
.meter { height: 10px; border-radius: 999px; background: rgba(255, 255, 255, .14); margin: 16px 0 14px; overflow: hidden; }
.meter-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #ffd98a, #e0a42b); }
.hero-card-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hero-card-foot div { background: rgba(255, 255, 255, .09); border-radius: 14px; padding: 10px 12px; font-size: 12px; color: #b6c3e0; }
.hero-card-foot strong { display: block; color: #fff; font-size: 14px; margin-top: 2px; }
.stat-strip { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x proximity; padding: 2px 16px 6px; margin: 0 -16px; scrollbar-width: none; }
.stat-strip::-webkit-scrollbar { display: none; }
.strip-item { flex: 0 0 auto; scroll-snap-align: start; display: flex; align-items: center; gap: 12px; padding: 12px 16px 12px 18px; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: 18px; text-decoration: none; color: inherit; box-shadow: var(--shadow-1); min-width: 170px; }
.strip-item strong { display: block; font-size: 17px; font-weight: 800; line-height: 1.3; }
.strip-item span.l { font-size: 12px; color: var(--c-muted); font-weight: 700; }

/* 10. Explorer / tours ------------------------------------------------------------- */
.stepper { list-style: none; margin: 0 0 18px; padding: 10px 12px; display: flex; gap: 2px; align-items: center; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: 20px; box-shadow: var(--shadow-1); overflow-x: auto; }
.step { display: flex; align-items: center; flex: 1 0 auto; }
.step + .step::before { content: ""; flex: 1; min-width: 12px; height: 2px; background: var(--c-line); margin-inline: 4px; border-radius: 2px; }
.step.is-done + .step::before { background: var(--c-brand); }
.step > a, .step > span { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-size: 13px; color: var(--c-muted); padding: 2px; border-radius: 999px; }
.step-dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 800; background: var(--c-line-2); color: var(--c-muted); flex: none; }
.step-dot .icon { width: 14px; height: 14px; }
.step.is-done .step-dot { background: var(--c-brand); color: #fff; }
.step.is-current .step-dot { background: var(--c-gold); color: var(--c-ink); box-shadow: 0 0 0 4px var(--c-gold-soft); }
.step.is-current .step-label { color: var(--c-ink); font-weight: 800; }
.step:not(.is-current) .step-label { display: none; }

.explore-layout { display: flex; flex-direction: column; gap: 16px; }
.explore-side { display: grid; gap: 14px; order: -1; }
.side-card { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-lg); padding: 16px 18px; box-shadow: var(--shadow-1); }
.trail { list-style: none; margin: 10px 0 14px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; font-size: 13px; }
.trail li { display: inline-flex; align-items: center; gap: 6px; background: var(--c-bg); padding: 5px 12px; border-radius: 999px; color: var(--c-ink-2); font-weight: 700; }
.trail .icon { width: 15px; height: 15px; color: var(--c-brand); }
.cta { min-height: 52px; font-size: 16px; }
.tour-link { display: grid; gap: 2px; padding: 12px 0; border-bottom: 1px solid var(--c-line-2); text-decoration: none; color: var(--c-ink); font-weight: 700; font-size: 14px; }
.tour-link:last-child { border-bottom: 0; }
.bgrid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.bcard { display: flex; align-items: center; gap: 16px; padding: 16px 18px; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-lg); text-decoration: none; color: inherit; box-shadow: var(--shadow-1); }
.bcard:active { transform: scale(.985); }
.bcard-info { flex: 1; display: grid; gap: 10px; min-width: 0; }
.bcard-info h3 { font-size: 16px; font-weight: 800; }
.bcard-go { color: var(--c-brand); }
.tower { display: flex; flex-direction: column-reverse; gap: 3px; width: 52px; padding-top: 10px; position: relative; flex: none; }
.tower::before { content: ""; position: absolute; top: 0; left: 8px; right: 8px; height: 8px; background: var(--c-gold); clip-path: polygon(0 100%, 50% 0, 100% 100%); }
.band { height: 9px; border-radius: 3px; background: var(--c-brand); opacity: .95; }
.band:nth-child(even) { opacity: .7; }
.floor-stack { display: grid; gap: 10px; border-inline-start: 3px solid var(--c-line); padding-inline-start: 16px; margin-inline-start: 6px; }
.slab { position: relative; display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-md); box-shadow: var(--shadow-1); flex-wrap: wrap; }
.slab::before { content: ""; position: absolute; inset-inline-start: -26px; top: 50%; width: 11px; height: 11px; border-radius: 50%; background: var(--c-brand); transform: translateY(-50%); box-shadow: 0 0 0 4px var(--c-bg); }
.slab-number { width: 46px; height: 46px; border-radius: 14px; background: var(--c-brand-soft); color: var(--c-brand); display: grid; place-items: center; font-weight: 800; font-size: 18px; flex: none; }
.slab-info { flex: 1; display: grid; gap: 6px; min-width: 150px; }
.slab-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; width: 100%; }
.slab-actions .btn { flex: 1 1 130px; }
.ugrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.utile { display: grid; gap: 4px; padding: 14px 16px; background: var(--c-surface); border: 1px solid var(--c-line); border-inline-start: 5px solid var(--c-faint); border-radius: var(--r-md); text-decoration: none; color: inherit; box-shadow: var(--shadow-1); }
.utile:active { transform: scale(.97); }
.utile.is-available { border-inline-start-color: var(--c-ok); }
.utile.is-reserved { border-inline-start-color: #e8a02c; }
.utile.is-allocated { border-inline-start-color: var(--c-info); }
.utile.is-handed_over { border-inline-start-color: var(--c-brand); }
.utile-status { font-size: 12px; font-weight: 800; color: var(--c-muted); }
.utile-number { font-size: 26px; font-weight: 800; line-height: 1.2; color: var(--c-ink); }
.utile-meta { font-size: 13px; color: var(--c-ink-2); }
.utile-foot { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--c-muted); margin-top: 4px; }
.utile-foot .icon { width: 14px; height: 14px; color: var(--c-gold); }
.unit-hero { display: flex; gap: 20px; align-items: center; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-xl); padding: 22px; box-shadow: var(--shadow-1); flex-wrap: wrap; }
.unit-hero-number { width: 96px; height: 96px; border-radius: 26px; display: grid; place-items: center; font-size: 36px; font-weight: 800; color: #ffd98a; flex: none; background: linear-gradient(150deg, var(--c-brand), var(--c-deep-2)); box-shadow: var(--shadow-glow); }
.dropzone-body { border: 2px dashed #c3ccdb; border-radius: var(--r-lg); padding: 26px 18px; display: grid; justify-items: center; gap: 6px; text-align: center; background: #fafbfe; transition: border-color .15s, background-color .15s; }
.dropzone-body .icon { width: 32px; height: 32px; color: var(--c-brand); }
.dropzone-body:hover { border-color: var(--c-brand); background: var(--c-brand-soft); }
.dropzone-body.is-dragging { border-color: var(--c-gold); background: var(--c-gold-soft); border-style: solid; }
.dropzone-body.is-busy { opacity: .6; pointer-events: none; }
.editor-grid { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
.viewer-frame { width: 100%; height: min(62vh, 560px); border-radius: var(--r-md); overflow: hidden; background: #0e1a2b; }
.scene-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--c-line-2); }
.scene-row:last-child { border-bottom: 0; }
.scene-row.is-active { background: var(--c-brand-soft); box-shadow: inset 3px 0 0 var(--c-brand); }
.scene-link { display: grid; gap: 2px; text-decoration: none; color: var(--c-ink); min-width: 0; }
.scene-name { font-weight: 700; font-size: 14px; }

/* Phone: tables become cards ------------------------------------------------------- */
@media (max-width: 719px) {
  table.data, table.data tbody, table.data tfoot, table.data tr { display: block; }
  table.data thead { display: none; }
  table.data tr { padding: 12px 16px; border-bottom: 1px solid var(--c-line-2); }
  table.data tbody tr:last-child { border-bottom: 0; }
  table.data td, table.data tfoot th { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 6px 0; border: 0; background: transparent; text-align: end; font-size: 14px; }
  table.data td::before, table.data tfoot th::before { content: attr(data-label); color: var(--c-muted); font-size: 12.5px; font-weight: 700; text-align: start; flex: none; }
  table.data td:first-child { font-weight: 700; }
  table.data tfoot tr { background: var(--c-brand-soft); }
  table.data tfoot th { color: var(--c-brand); }
  table.data td[colspan] { display: block; text-align: center; }
  table.data td[colspan]::before { display: none; }
  .table-wrap { overflow: visible; }
}

/* Tablet and up ------------------------------------------------------------------ */
@media (min-width: 720px) {
  body { font-size: 15.5px; }
  .container { width: min(1200px, 100% - 56px); }
  .page-header { flex-direction: row; justify-content: space-between; align-items: flex-end; }
  .page-title { font-size: 28px; }
  .page-actions .btn { flex: 0 0 auto; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 22px; }
  .form-actions .btn { flex: 0 0 auto; }
  .kpi-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
  .kpi-value { font-size: 23px; }
  .project-grid, .pgrid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
  .hero { padding: 54px 48px 46px; }
  .hero h1 { font-size: 42px; }
  .hero-stat strong { font-size: 28px; }
  .building-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .detail-hero { grid-template-columns: minmax(0, 1fr) auto; padding: 30px; }
  .facts { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .bgrid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
  .ugrid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .slab-actions { width: auto; }
  .chart-box { height: 290px; }
  .stat-strip { margin: 0; padding-inline: 0; flex-wrap: wrap; }
  .strip-item { flex: 1 1 200px; }
  .bento { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; }
  .step:not(.is-current) .step-label { display: inline; }
}

/* Desktop: sidebar shell, no bottom bar ---------------------------------------------- */
@media (min-width: 1024px) {
  .app { display: grid; grid-template-columns: 276px minmax(0, 1fr); }
  .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 22px 14px 18px; background: linear-gradient(180deg, var(--c-deep), #0a1430); color: #c5d0e8; }
  .sidebar .brand { color: #fff; padding: 0 8px 8px; }
  .sidebar .brand-sub { color: #8ea0c4; }
  .sidebar .nav-group-title { color: #6f83ad; }
  .sidebar .nav-link { color: #c5d0e8; padding: 10px 12px; font-size: 14px; }
  .sidebar .nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
  .sidebar .nav-link.is-active { background: rgba(42, 85, 229, .35); color: #fff; }
  .sidebar .nav-link.is-active::before { content: ""; position: absolute; inset-inline-start: -14px; top: 10px; bottom: 10px; width: 4px; border-radius: 4px; background: var(--c-gold); }
  .sidebar-foot { margin-top: auto; padding: 14px 12px 0; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 13px; color: #8ea0c4; }
  .sidebar-foot strong { display: block; color: #fff; font-size: 14px; }
  .topbar { padding: 12px 28px; flex-wrap: nowrap; }
  .topbar-brand, .search-toggle { display: none; }
  .search-form { display: block; order: 0; flex: 0 1 440px; margin: 0; margin-inline-start: auto; }
  .content { padding: 28px 32px 48px; max-width: 1480px; }
  .tabbar, .sheet { display: none !important; }
  .two-col { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; }
  .explore-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 22px; align-items: start; }
  .explore-side { order: 0; position: sticky; top: 84px; }
  .editor-grid { grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; }
  .bento { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); }
  .portal-main { max-width: 860px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media print {
  .sidebar, .topbar, .tabbar, .bottom-nav, .sheet, .site-header, .site-footer, .btn, .form-actions, .pager, .page-actions { display: none !important; }
  .app { display: block; }
  .content { padding: 0; }
  body { background: #fff; }
  .panel { box-shadow: none; }
}
