/* Direction: Sanrachana Interior Pro — warm stone paper, bronze accent, serif display, walnut sidebar */
/* Completed by the platform from the short form: both modes, every
   palette token, each text-on-ground pair at its floor. To restyle, write the
   short form again (the decisions in one :root) and it is completed again. */

:root {
  --canvas: #f6f2ea;
  --surface: #fffdf9;
  --surface-2: #efe8dc;
  --border: #ddd3c2;
  --border-strong: #b2ada5;
  --ink: #241f19;
  --muted: #6a6054;
  --accent: #7d4f26;
  --accent-hover: #6a4320;
  --accent-ink: #ffffff;
  --accent-text: #7d4f26;
  --accent-strong: #7d4f26;
  --accent-soft: #f1e3d0;
  --accent-border: #c0a992;
  --success: #2a7048;
  --success-ink: #ffffff;
  --success-soft: #dee2d7;
  --success-strong: #2a7048;
  --warning: #8f5a10;
  --warning-ink: #ffffff;
  --warning-soft: #eae0d0;
  --warning-strong: #84530f;
  --danger: #a8301f;
  --danger-ink: #ffffff;
  --danger-soft: #eddbd2;
  --danger-strong: #a8301f;
  --chart-1: #7d4f26;
  --chart-2: #6b7f0b;
  --chart-3: #0b5a4f;
  --chart-4: #1076ad;
  --chart-5: #593888;
  --chart-6: #ad4d6e;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", system-ui, sans-serif;
  --radius-card: 12px;
  --radius-btn: 8px;
  --radius-input: 8px;
  --x-side: #221c15;
  --x-side-ink: #efe6d6;
  --x-side-muted: #a99d8a;
  --font-mono: "JetBrains Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-sans: "Inter", system-ui, sans-serif;
  --display-weight: 700;
  --display-tracking: -0.02em;
  --eyebrow-tracking: 0.08em;
}

html[data-theme="dark"] {
  --canvas: #120b05;
  --surface: #2a231e;
  --surface-2: #1e1712;
  --border: #332d28;
  --border-strong: #595450;
  --ink: #f6f2ea;
  --muted: #9b968e;
  --accent: #7d4f26;
  --accent-hover: #916947;
  --accent-ink: #ffffff;
  --accent-text: #a98b70;
  --accent-strong: #a28164;
  --accent-soft: #2a1a0c;
  --accent-border: #422a14;
  --success: #2a7048;
  --success-ink: #ffffff;
  --success-soft: #172114;
  --success-strong: #66997b;
  --warning: #8f5a10;
  --warning-ink: #ffffff;
  --warning-soft: #2e1c07;
  --warning-strong: #af8854;
  --danger: #a8301f;
  --danger-ink: #ffffff;
  --danger-soft: #33130b;
  --danger-strong: #c5776b;
  --chart-1: #96663d;
  --chart-2: #839830;
  --chart-3: #1f9483;
  --chart-4: #268fcd;
  --chart-5: #8d6cc2;
  --chart-6: #c86586;
}

/* Sanrachana Interior Pro — app shell, tables, gantt, charts, documents */
.app-shell { min-height: 100vh; }
.side { position: fixed; inset: 0 auto 0 0; width: 16rem; background: var(--x-side); color: var(--x-side-ink); z-index: 40; display: flex; flex-direction: column; overflow-y: auto; transition: transform .2s, width .2s; }
.side a.nav { display: flex; align-items: center; gap: .75rem; padding: .6rem .9rem; border-radius: 8px; color: var(--x-side-ink); font-size: .92rem; }
.side a.nav:hover { background: color-mix(in srgb, var(--x-side-ink) 12%, transparent); }
.side a.nav:focus-visible { outline: 2px solid var(--x-side-ink); outline-offset: 1px; }
.side a.nav.on { background: var(--accent); color: var(--accent-ink); }
.side .muted-s { color: var(--x-side-muted); }
.main { margin-left: 16rem; transition: margin .2s; min-width: 0; }
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .75rem; padding: .55rem 1rem; background: var(--canvas); border-bottom: 1px solid var(--border); }
.side-backdrop { display: none; }
@media (max-width: 1023px) {
  .side { transform: translateX(-100%); }
  .main { margin-left: 0; }
  body.side-open .side { transform: none; }
  body.side-open .side-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: color-mix(in srgb, var(--ink) 45%, transparent); }
}
@media (min-width: 1024px) {
  body.side-collapsed .side { width: 4.25rem; }
  body.side-collapsed .main { margin-left: 4.25rem; }
  body.side-collapsed .side-label { display: none; }
}
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; border: 1px solid; }
.flash-ok { background: color-mix(in srgb, var(--success) 12%, transparent); border-color: var(--success); color: var(--ink); }
.flash-err { background: color-mix(in srgb, var(--danger) 12%, transparent); border-color: var(--danger); color: var(--ink); }
.tblwrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; padding: .55rem .6rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: .55rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.tbl tr.subtotal td { font-weight: 700; background: var(--surface-2); }
.tbl tr.roomrow td { font-weight: 700; background: var(--accent-soft); }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cell { width: 100%; min-width: 4.5rem; padding: .32rem .45rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--ink); font-size: .85rem; }
.cell:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
textarea.cell { min-height: 2.2rem; resize: vertical; }
.st { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 600; white-space: nowrap; }
.st-ok { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); }
.st-warn { background: color-mix(in srgb, var(--warning) 16%, transparent); color: var(--warning); }
.st-bad { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.st-info { background: var(--accent-soft); color: var(--accent-text); }
.st-mute { background: var(--surface-2); color: var(--muted); }
.ptabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; scrollbar-width: thin; }
.ptabs a { padding: .6rem .85rem; font-size: .85rem; white-space: nowrap; color: var(--muted); border-bottom: 2px solid transparent; }
.ptabs a:hover { color: var(--ink); }
.ptabs a.on { color: var(--accent-text); border-bottom-color: var(--accent); font-weight: 600; }
.rtabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.rtabs a { padding: .35rem .8rem; border: 1px solid var(--border); border-radius: 999px; font-size: .82rem; background: var(--surface); }
.rtabs a:hover { border-color: var(--accent); }
.rtabs a.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.kpi { padding: 1rem 1.1rem; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); }
.kpi .k { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.kpi .v { font-family: var(--font-display); font-size: 1.55rem; margin-top: .2rem; font-variant-numeric: tabular-nums; }
.kpi .n { font-size: .74rem; color: var(--muted); margin-top: .15rem; }
.kpi.est { border-style: dashed; }
.bars { display: flex; align-items: flex-end; gap: .6rem; height: 220px; padding-top: 1rem; }
.bar-col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.bar-pair { display: flex; align-items: flex-end; gap: 3px; width: 100%; justify-content: center; flex: 1; }
.bar-in, .bar-out { width: 42%; max-width: 30px; min-height: 2px; border-radius: 4px 4px 0 0; transition: filter .15s; }
.bar-in { background: var(--success); }
.bar-out { background: var(--danger); }
.bar-col:hover .bar-in, .bar-col:hover .bar-out { filter: brightness(1.2); }
.bar-lbl { font-size: .68rem; color: var(--muted); margin-top: .3rem; white-space: nowrap; }
.bar-tip { display: none; position: absolute; bottom: 100%; z-index: 5; background: var(--ink); color: var(--canvas); padding: .35rem .55rem; border-radius: 6px; font-size: .72rem; white-space: nowrap; }
.bar-col:hover .bar-tip, .bar-col:focus .bar-tip { display: block; }
.donut { width: 170px; height: 170px; border-radius: 50%; position: relative; flex: none; }
.donut::after { content: ""; position: absolute; inset: 28px; border-radius: 50%; background: var(--surface); }
.donut b { position: absolute; inset: 0; display: grid; place-items: center; z-index: 2; font-family: var(--font-display); font-size: 1.6rem; }
.dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 3px; margin-right: .4rem; }
.pbar { height: .5rem; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.pbar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
/* Gantt */
.gantt { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); max-height: 70vh; }
.g-row { display: flex; height: 30px; border-bottom: 1px solid var(--border); }
.g-row[hidden] { display: none; }
.g-row.head { position: sticky; top: 0; z-index: 6; background: var(--surface-2); height: 44px; }
.g-row.phase { background: var(--surface-2); font-weight: 600; }
.g-label { position: sticky; left: 0; width: 270px; flex: none; z-index: 4; background: var(--surface); padding: 0 .6rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; line-height: 30px; font-size: .78rem; border-right: 1px solid var(--border); }
.g-row.phase .g-label, .g-row.head .g-label { background: var(--surface-2); }
.g-row.head .g-label { line-height: 44px; z-index: 8; }
.g-track { position: relative; flex: none; background-image: linear-gradient(to right, var(--border) 1px, transparent 1px); background-size: var(--dw) 100%; }
.g-h { position: absolute; top: 0; height: 100%; border-right: 1px solid var(--border); font-size: .66rem; text-align: center; line-height: 1.1; padding-top: 6px; overflow: hidden; color: var(--muted); }
.g-h.we { background: var(--accent-soft); }
.g-h.td { background: var(--danger); color: var(--surface); }
.g-bar { position: absolute; top: 5px; height: 20px; border-radius: 5px; min-width: 4px; overflow: hidden; touch-action: none; cursor: grab; }
.g-bar i { display: block; height: 100%; background: color-mix(in srgb, var(--ink) 32%, transparent); pointer-events: none; }
.g-bar span { position: absolute; left: 5px; top: 2px; font-size: .66rem; color: var(--surface); white-space: nowrap; pointer-events: none; }
.gb-completed { background: var(--success); }
.gb-inprogress { background: var(--accent); }
.gb-delayed { background: var(--danger); outline: 2px solid var(--danger); outline-offset: 1px; }
.gb-onhold { background: var(--warning); }
.gb-notstarted { background: var(--muted); }
.g-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); z-index: 2; pointer-events: none; }
/* Documents (quotation / invoice / PUR / report) */
.doc { background: var(--surface); color: var(--ink); max-width: 210mm; margin: 0 auto; padding: 14mm; border: 1px solid var(--border); border-radius: 6px; font-size: .86rem; }
.doc h1, .doc h2, .doc h3 { font-family: var(--font-display); }
.doc table { width: 100%; border-collapse: collapse; font-size: .78rem; }
.doc th, .doc td { border: 1px solid var(--border); padding: .3rem .45rem; vertical-align: top; }
.doc th { background: var(--surface-2); text-align: left; }
.doc tr.room td { font-weight: 700; background: var(--accent-soft); }
.doc tr.sub td { font-weight: 700; background: var(--surface-2); }
.doc .num { text-align: right; white-space: nowrap; }
.doc .head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; border-bottom: 2px solid var(--accent); padding-bottom: .7rem; margin-bottom: .8rem; }
.doc .sigblock { margin-top: 2rem; margin-left: auto; width: 15rem; text-align: center; break-inside: avoid; }
.doc .sigblock img { max-height: 70px; max-width: 14rem; margin: 0 auto; display: block; }
.doc .logo { max-height: 64px; max-width: 160px; object-fit: contain; }
.grid-form { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.thumbs { display: flex; flex-wrap: wrap; gap: .5rem; }
.thumbs img { width: 96px; height: 72px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.thumbs label { position: relative; display: block; }
.thumbs input[type=checkbox] { position: absolute; top: 4px; left: 4px; }
@media print {
  .side, .top, .no-print, .ptabs { display: none !important; }
  .main { margin: 0 !important; }
  .doc { border: 0; padding: 0; max-width: none; border-radius: 0; }
  .doc thead { display: table-header-group; }
  .doc tr { break-inside: avoid; }
  main { padding: 0 !important; }
}
