@font-face {
  font-family: "Sarabun";
  src: url("fonts/Sarabun-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
}

@font-face {
  font-family: "Sarabun";
  src: url("fonts/Sarabun-Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 600 800;
  font-display: swap;
}

:root {
  color-scheme: light;
  font-family: "Sarabun", "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-synthesis: none;
  --canvas: #edf0ef;
  --rail: #131921;
  --rail-active: #28374a;
  --surface: #ffffff;
  --surface-raised: #f7f8f7;
  --surface-hover: #f1f3f2;
  --line: #d5d9d9;
  --line-soft: #e6e9e7;
  --text: #303535;
  --text-strong: #101414;
  --muted: #5f6665;
  --muted-2: #747b79;
  --navy: #0e2a47;
  --navy-deep: #0a1d33;
  --gold: #c9a35b;
  --gold-strong: #9f742d;
  --gold-soft: #fbf6ea;
  --action: #f2c765;
  --action-hover: #eab94e;
  --accent: #0a6f75;
  --accent-soft: #e8f5f3;
  --success: #276749;
  --success-soft: #e9f5ed;
  --warning: #8a5a10;
  --warning-soft: #fff7df;
  --danger: #a33a2b;
  --danger-soft: #fbecea;
  --focus: #087f8c;
  --shadow: 0 1px 2px rgba(10, 29, 51, .08), 0 8px 24px rgba(10, 29, 51, .06);
  --rail-width: 68px;
  --topbar-height: 60px;
  --radius: 10px;
  --type-caption: 12px;
  --type-label: 13px;
  --type-body: 14px;
  --type-title: 16px;
  --line-body: 22px;
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: var(--canvas); text-size-adjust: 100%; }
body { min-width: 320px; min-height: 100vh; margin: 0; color: var(--text); background: var(--canvas); font-size: var(--type-body); line-height: var(--line-body); }
body.menu-open { overflow: hidden; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
h1, h2, h3, p, dl, dd { margin: 0; }
input, select, textarea { color: var(--text-strong); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid rgba(8, 127, 140, .36); outline-offset: 2px; }
.skip-link { position: fixed; z-index: 500; top: 8px; left: 8px; padding: 9px 12px; border-radius: 7px; color: var(--text-strong); background: var(--action); font-weight: 600; transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }
.sr-only { position: absolute !important; inset: 0 auto auto 0 !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { min-height: 100vh; }
.rail { position: fixed; z-index: 120; inset: 0 auto 0 0; width: var(--rail-width); display: flex; flex-direction: column; align-items: stretch; color: #d7dde4; background: var(--rail); border-right: 1px solid rgba(255,255,255,.08); }
.rail-brand { width: 44px; height: 44px; display: grid; place-items: center; margin: 8px auto 16px; border: 1px solid rgba(201,163,91,.5); border-radius: 11px; background: #fff; overflow: hidden; }
.rail-brand img { width: 34px; height: 34px; object-fit: contain; }
.rail nav { display: grid; gap: 4px; }
.rail nav a, .rail-logout button { min-height: 52px; position: relative; display: grid; place-items: center; gap: 2px; padding: 7px 3px; border: 0; color: #c3ccd5; background: transparent; font-size: 10px; line-height: 14px; }
.rail nav a::before { content: ""; position: absolute; inset: 6px auto 6px 0; width: 3px; border-radius: 0 3px 3px 0; background: transparent; }
.rail nav a:hover, .rail-logout button:hover { color: #fff; background: rgba(255,255,255,.05); }
.rail nav a.active { color: #fff; background: var(--rail-active); }
.rail nav a.active::before { background: var(--gold); }
.rail nav .icon, .rail-logout .icon { width: 19px; height: 19px; }
.rail-logout { margin-top: auto; }
.rail-logout button { width: 100%; margin-bottom: 6px; }

.workspace { min-height: 100vh; margin-left: var(--rail-width); }
.topbar { height: var(--topbar-height); position: sticky; z-index: 90; top: 0; display: grid; grid-template-columns: minmax(150px, .7fr) minmax(260px, 520px) minmax(190px, .7fr); align-items: center; gap: 20px; padding: 0 22px; color: #f5f7f9; background: var(--rail); border-bottom: 1px solid rgba(255,255,255,.08); }
.mobile-menu { display: none; width: 42px; height: 42px; place-items: center; border: 0; color: #fff; background: transparent; border-radius: 8px; }
.topbar-context { display: grid; line-height: 18px; }
.topbar-context span { color: #abb6c2; font-size: var(--type-caption); }
.topbar-context strong { color: #fff; font-size: var(--type-body); font-weight: 600; }
.global-search { min-width: 0; height: 40px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; padding: 0 9px; border: 1px solid #bdc4ca; border-radius: 7px; color: var(--muted); background: #fff; }
.global-search:focus-within { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,163,91,.24); }
.global-search input { min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; font-size: var(--type-body); }
.global-search kbd { padding: 1px 7px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); background: var(--surface-raised); font-family: inherit; font-size: 11px; }
.user-chip { justify-self: end; display: flex; align-items: center; gap: 9px; min-width: 0; }
.user-chip > span { width: 36px; height: 36px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 50%; color: var(--navy-deep); background: var(--gold); font-weight: 700; }
.user-chip > div { min-width: 0; display: grid; line-height: 17px; }
.user-chip strong { max-width: 130px; overflow: hidden; color: #fff; font-size: var(--type-label); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.user-chip small { color: #abb6c2; font-size: 11px; }
.bottom-nav { display: none; }

.page-layout { width: min(100%, 1440px); margin: 0 auto; padding: 24px clamp(18px, 2.6vw, 38px) 48px; }
.page-header, .dashboard-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
.page-header h1, .dashboard-intro h1 { margin: 2px 0 4px; color: var(--text-strong); font-size: clamp(24px, 2.5vw, 32px); line-height: 1.22; font-weight: 600; letter-spacing: -.02em; }
.page-header p, .dashboard-intro p { max-width: 680px; color: var(--muted); }
.eyebrow { color: var(--gold-strong); font-size: var(--type-caption); line-height: 18px; font-weight: 700; letter-spacing: .055em; text-transform: uppercase; }
.surface { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 4px 0 10px; }
.section-heading h2, .focus-card h2, .pipeline-card h2 { color: var(--text-strong); font-size: 18px; line-height: 26px; font-weight: 600; }
.section-heading p, .focus-card header p, .pipeline-card header p { color: var(--muted-2); font-size: var(--type-caption); line-height: 18px; }
.text-link { display: inline-flex; align-items: center; gap: 5px; padding: 4px 0; border: 0; color: var(--accent); background: transparent; font-size: var(--type-label); font-weight: 600; }
.text-link .icon { width: 15px; height: 15px; }
.text-link:hover { color: var(--gold-strong); text-decoration: underline; }

.button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 14px; border: 1px solid transparent; border-radius: 7px; font-size: var(--type-body); line-height: 20px; font-weight: 600; white-space: nowrap; }
.button .icon { width: 17px; height: 17px; }
.button-primary { color: var(--navy-deep); border-color: #bb8e37; background: var(--action); box-shadow: 0 1px 2px rgba(15,17,17,.16); }
.button-primary:hover { background: var(--action-hover); }
.button-secondary { color: var(--text); border-color: #b9c0be; background: var(--surface); }
.button-secondary:hover { background: var(--surface-hover); }
.button-light { color: var(--text-strong); border-color: rgba(255,255,255,.7); background: rgba(255,255,255,.92); }
.button-large { min-height: 46px; font-size: 15px; }
.button:disabled { cursor: wait; opacity: .62; }
.icon-button { width: 38px; height: 38px; display: inline-grid; place-items: center; border: 1px solid transparent; border-radius: 7px; color: var(--muted); background: transparent; }
.icon-button:hover { color: var(--text-strong); border-color: var(--line); background: var(--surface-hover); }
.icon-button .icon { width: 18px; height: 18px; }
.danger-icon:hover, .danger-link { color: var(--danger) !important; }

.notice { padding: 10px 12px; border: 1px solid #e0c681; border-radius: 8px; color: #5c4313; background: var(--warning-soft); font-size: var(--type-label); line-height: 20px; }
.notice-success { color: var(--success); border-color: #b9dec6; background: var(--success-soft); }
.notice-error { color: var(--danger); border-color: #e6b9b2; background: var(--danger-soft); }
.notice-warning { color: var(--warning); border-color: #e0c681; background: var(--warning-soft); }
.page-notice { max-width: 1360px; display: flex; align-items: center; gap: 9px; margin: 12px auto 0; }
.workspace > main > .page-notice { width: calc(100% - clamp(36px, 5.2vw, 76px)); }
.page-notice a { color: var(--accent); font-weight: 600; text-decoration: underline; }

label { display: grid; gap: 5px; color: var(--text); font-size: var(--type-label); }
label > span:first-child { color: var(--muted); font-weight: 500; }
label em { color: var(--gold-strong); font-style: normal; font-size: 11px; }
input, select, textarea { width: 100%; min-width: 0; min-height: 40px; padding: 8px 10px; border: 1px solid #b8bfbd; border-radius: 7px; background: var(--surface); outline: 0; }
textarea { resize: vertical; line-height: 20px; }
input:hover, select:hover, textarea:hover { border-color: #8f9895; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(8,127,140,.13); }
input::placeholder, textarea::placeholder { color: #8a9290; }
label small { color: var(--muted-2); font-size: var(--type-caption); line-height: 18px; }
label small a { color: var(--accent); text-decoration: underline; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stack-form { display: grid; gap: 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.check-control { min-height: 54px; grid-template-columns: auto 1fr; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.check-control input { width: 18px; min-height: 18px; accent-color: var(--navy); }
.check-control span { display: grid; }
.check-control strong { color: var(--text-strong); font-weight: 600; }
.check-control small { color: var(--muted-2); }

.metric-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 20px; }
.metric-strip > a { min-width: 0; min-height: 92px; display: grid; grid-template-columns: 42px 1fr; align-items: center; gap: 11px; padding: 13px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 1px 2px rgba(10,29,51,.05); }
.metric-strip > a:hover { border-color: #adb6b3; box-shadow: var(--shadow); }
.metric-strip a > div { min-width: 0; display: grid; }
.metric-strip small { color: var(--muted); font-size: var(--type-caption); }
.metric-strip strong { color: var(--text-strong); font-size: 23px; line-height: 27px; font-weight: 600; font-variant-numeric: tabular-nums; }
.metric-strip a > div > span { overflow: hidden; color: var(--muted-2); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.metric-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; }
.metric-icon.navy { color: #fff; background: var(--navy); }
.metric-icon.blue { color: #24537b; background: #e6f0f8; }
.metric-icon.green { color: var(--success); background: var(--success-soft); }
.metric-icon.gold { color: #6b4b12; background: var(--gold-soft); }
.dashboard-columns { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(280px, .75fr); gap: 12px; }
.main-column, .side-column { min-width: 0; display: grid; align-content: start; gap: 12px; }

.table-surface { min-width: 0; overflow: visible; }
.responsive-table { width: 100%; overflow-x: auto; border-radius: inherit; }
table { width: 100%; border-collapse: collapse; font-size: var(--type-body); line-height: 20px; }
th { padding: 10px 13px; color: var(--muted); background: var(--surface-raised); text-align: left; font-size: var(--type-caption); line-height: 18px; font-weight: 500; white-space: nowrap; }
td { padding: 11px 13px; border-top: 1px solid var(--line-soft); color: var(--text); vertical-align: middle; }
tbody tr:hover { background: #fafbfa; }
td strong, td small { display: block; }
td strong { color: var(--text-strong); font-weight: 500; }
td small { color: var(--muted-2); font-size: var(--type-caption); line-height: 18px; }
.quote-number { color: var(--accent); font-weight: 700; white-space: nowrap; }
.quote-number:hover { text-decoration: underline; }
.money-cell { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.status { display: inline-flex; align-items: center; width: max-content; padding: 3px 8px; border-radius: 999px; font-size: var(--type-caption); line-height: 18px; font-weight: 600; white-space: nowrap; }
.status-gray { color: #596160; background: #eef0ef; }
.status-blue { color: #24537b; background: #e7f0f8; }
.status-green { color: var(--success); background: var(--success-soft); }
.status-red { color: var(--danger); background: var(--danger-soft); }
.status-amber { color: var(--warning); background: var(--warning-soft); }
.table-summary { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 14px; border-bottom: 1px solid var(--line-soft); }
.table-summary > div { display: grid; }
.table-summary strong { color: var(--text-strong); font-weight: 600; }
.table-summary span { color: var(--muted-2); font-size: var(--type-caption); }
.empty-state { min-height: 260px; display: grid; justify-items: center; align-content: center; padding: 28px; text-align: center; }
.empty-state.compact { min-height: 180px; }
.empty-mark { width: 54px; height: 54px; display: grid; place-items: center; margin-bottom: 10px; border-radius: 50%; color: var(--navy); background: var(--gold-soft); }
.empty-mark .icon { width: 26px; height: 26px; }
.empty-state strong { color: var(--text-strong); font-size: var(--type-title); }
.empty-state p { max-width: 380px; color: var(--muted-2); }

.craft-banner { min-height: 230px; position: relative; overflow: hidden; border-radius: var(--radius); color: #fff; background: var(--navy-deep); box-shadow: var(--shadow); }
.craft-banner::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(8,24,40,.98) 0%, rgba(8,24,40,.88) 48%, rgba(8,24,40,.12) 86%); }
.craft-banner img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center; }
.craft-banner > div { width: min(62%, 560px); position: relative; z-index: 1; padding: 27px 25px; }
.craft-banner > div > span { color: #f2d89f; font-size: var(--type-caption); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.craft-banner h2 { margin: 5px 0 7px; color: #fff; font-size: clamp(19px, 2vw, 25px); line-height: 1.35; font-weight: 600; }
.craft-banner p { margin-bottom: 15px; color: #dce3e8; }
.focus-card, .pipeline-card { overflow: hidden; }
.focus-card > header, .pipeline-card > header { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line-soft); }
.count-badge { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; color: var(--navy-deep); background: var(--action); font-weight: 700; }
.focus-row { min-height: 68px; display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--line-soft); }
.focus-row:hover { background: var(--surface-hover); }
.focus-row > span { min-width: 0; display: grid; }
.focus-row > span:nth-child(2) { text-align: right; }
.focus-row small { color: var(--muted-2); font-size: 11px; line-height: 17px; }
.focus-row strong { overflow: hidden; color: var(--text-strong); font-size: var(--type-label); line-height: 20px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.focus-row > .icon { width: 15px; height: 15px; color: var(--muted-2); }
.empty-inline { min-height: 92px; display: flex; align-items: center; gap: 11px; padding: 14px; color: var(--success); }
.empty-inline > span { display: grid; }
.empty-inline strong { color: var(--text-strong); font-weight: 600; }
.empty-inline small { color: var(--muted-2); }
.pipeline-card { padding-bottom: 8px; }
.pipeline-row { min-height: 57px; display: grid; grid-template-columns: 104px 1fr 24px; align-items: center; gap: 9px; padding: 6px 13px; }
.pipeline-row > span { display: grid; }
.pipeline-row strong { color: var(--text-strong); font-size: var(--type-label); line-height: 18px; font-weight: 500; }
.pipeline-row small { color: var(--muted-2); font-size: 11px; line-height: 16px; }
.pipeline-row i { height: 4px; overflow: hidden; border-radius: 99px; background: var(--line-soft); }
.pipeline-row i b { display: block; height: 100%; border-radius: inherit; background: var(--gold); }
.pipeline-row em { color: var(--text-strong); font-style: normal; font-weight: 600; text-align: right; }

.toolbar { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; padding: 10px; }
.search-control { min-width: 180px; height: 40px; display: grid; grid-template-columns: auto 1fr; align-items: center; flex: 1; gap: 8px; padding: 0 10px; border: 1px solid #b8bfbd; border-radius: 7px; color: var(--muted); background: var(--surface); }
.search-control:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(8,127,140,.13); }
.search-control input { min-height: 36px; padding: 0; border: 0; box-shadow: none; }
.select-control select { min-width: 145px; }
.clear-filter { margin-left: auto; padding: 8px; }
.quotes-table td:nth-child(2) { min-width: 220px; }
.row-actions { display: flex; align-items: center; }
.action-menu { position: relative; }
.action-menu > summary { list-style: none; user-select: none; }
.action-menu > summary::-webkit-details-marker { display: none; }
.action-menu > div { width: 210px; position: absolute; z-index: 30; top: calc(100% + 4px); right: 0; padding: 5px; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: 0 12px 32px rgba(10,29,51,.18); }
.action-menu form { margin: 0; }
.action-menu button, .action-menu label { width: 100%; min-height: 40px; display: flex; align-items: center; gap: 8px; padding: 7px 9px; border: 0; border-radius: 6px; color: var(--text); background: transparent; text-align: left; }
.action-menu button:hover { background: var(--surface-hover); }
.action-menu label { display: grid; grid-template-columns: 1fr; gap: 4px; }
.action-menu label select { min-height: 36px; }
.table-search { padding: 10px; border-bottom: 1px solid var(--line-soft); }

.split-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(330px, .72fr); gap: 12px; align-items: start; }
.form-panel { position: sticky; top: calc(var(--topbar-height) + 14px); overflow: hidden; }
.form-panel > header, .settings-section > header, .builder-section > header { min-height: 72px; display: flex; align-items: center; gap: 11px; padding: 12px 14px; border-bottom: 1px solid var(--line-soft); }
.form-panel > header > div, .settings-section > header > div, .builder-section > header > div { min-width: 0; display: grid; }
.form-panel h2, .settings-section h2, .builder-section h2 { color: var(--text-strong); font-size: var(--type-title); line-height: 22px; font-weight: 600; }
.form-panel header p, .settings-section header p, .builder-section header p { color: var(--muted-2); font-size: var(--type-caption); line-height: 18px; }
.panel-icon { width: 38px; height: 38px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 50%; color: var(--navy); background: var(--gold-soft); }
.form-panel > form { padding: 15px; }
.code-label { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.settings-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.settings-section { overflow: hidden; }
.settings-fields { display: grid; gap: 13px; padding: 16px; }
.sticky-save { grid-column: 1 / -1; position: sticky; z-index: 20; bottom: 12px; min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 12px; border: 1px solid #cbb987; border-radius: 9px; background: rgba(255,252,244,.96); box-shadow: 0 10px 32px rgba(10,29,51,.14); backdrop-filter: blur(8px); }
.sticky-save > span { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: var(--type-label); }

.back-link { display: inline-flex; margin-bottom: 3px; color: var(--accent); font-size: var(--type-label); font-weight: 600; }
.quote-title-line { display: flex; align-items: center; gap: 10px; }
.quote-header-actions { display: flex; align-items: end; gap: 8px; }
.status-form label { gap: 2px; }
.status-form select { min-width: 130px; }
.builder-steps { max-width: 820px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin: 0 0 18px; padding: 0; list-style: none; }
.builder-steps li { min-width: 0; position: relative; display: grid; grid-template-columns: 30px 1fr; align-items: center; gap: 8px; color: var(--muted-2); }
.builder-steps li:not(:last-child)::after { content: ""; position: absolute; z-index: -1; top: 15px; left: 30px; right: 0; height: 2px; background: var(--line); }
.builder-steps li > span { width: 30px; height: 30px; display: grid; place-items: center; border: 2px solid var(--line); border-radius: 50%; background: var(--canvas); font-size: var(--type-caption); font-weight: 700; }
.builder-steps li > div { display: grid; padding-right: 10px; background: var(--canvas); }
.builder-steps strong { color: var(--text); font-size: var(--type-label); line-height: 18px; font-weight: 600; }
.builder-steps small { font-size: 11px; line-height: 16px; }
.builder-steps li.done > span { color: #fff; border-color: var(--success); background: var(--success); }
.builder-steps li.current > span { color: var(--navy-deep); border-color: var(--gold); background: var(--action); }
.builder-steps li.done:not(:last-child)::after { background: var(--success); }
.quote-builder { display: grid; grid-template-columns: minmax(0, 1fr) 320px; align-items: start; gap: 12px; }
.quote-main { min-width: 0; display: grid; gap: 12px; }
.builder-section { min-width: 0; overflow: hidden; }
.builder-section > header { justify-content: flex-start; }
.builder-section > header .button { margin-left: auto; }
.section-number { width: 31px; height: 31px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 50%; color: var(--navy-deep); background: var(--gold-soft); font-weight: 700; }
.builder-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 13px 12px; padding: 15px; }
.field-span-2 { grid-column: 1 / -1; }
.quote-summary { min-width: 0; position: sticky; top: calc(var(--topbar-height) + 12px); display: grid; gap: 10px; }
.summary-card { overflow: hidden; }
.summary-card > header { min-height: 70px; display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; color: #fff; background: var(--navy); border-bottom: 3px solid var(--gold); }
.summary-card > header h2 { color: #fff; font-size: 19px; font-weight: 600; }
.summary-card > header .eyebrow { color: #e7d0a1; }
.summary-card > header > .icon { width: 28px; height: 28px; color: var(--gold); }
.summary-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 13px 14px; border-bottom: 1px solid var(--line-soft); }
.summary-options label:first-child { grid-column: 1 / -1; }
.compound-field { display: grid; grid-template-columns: 74px 1fr; }
.compound-field select { border-radius: 7px 0 0 7px; border-right: 0; }
.compound-field input { border-radius: 0 7px 7px 0; }
.totals-list { padding: 8px 14px 12px; }
.totals-list > div { min-height: 34px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line-soft); font-variant-numeric: tabular-nums; }
.totals-list dt { color: var(--muted); font-size: var(--type-label); }
.totals-list dd { color: var(--text-strong); font-weight: 500; }
.totals-list .grand-total { min-height: 64px; margin-top: 4px; border: 0; }
.totals-list .grand-total dt { color: var(--text-strong); font-size: var(--type-title); font-weight: 600; }
.totals-list .grand-total dd { display: grid; justify-items: end; color: var(--navy); font-size: 26px; line-height: 28px; font-weight: 700; }
.totals-list .grand-total small { color: var(--muted-2); font-size: 11px; line-height: 15px; font-weight: 400; }
.summary-actions { display: grid; gap: 8px; padding: 0 14px 12px; }
.save-state { padding: 10px 14px; color: var(--muted-2); background: var(--surface-raised); font-size: 11px; line-height: 16px; text-align: center; }
.save-state.dirty { color: var(--warning); background: var(--warning-soft); }
.pdf-note { display: flex; align-items: flex-start; gap: 10px; padding: 12px; }
.pdf-note > span { width: 34px; height: 34px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 50%; color: var(--success); background: var(--success-soft); }
.pdf-note strong { color: var(--text-strong); font-size: var(--type-label); font-weight: 600; }
.pdf-note p { color: var(--muted-2); font-size: var(--type-caption); line-height: 18px; }

.item-grid { display: grid; grid-template-columns: minmax(260px, 1fr) 76px 78px 112px 82px 104px 40px; gap: 8px; align-items: center; padding: 10px 12px; border-top: 1px solid var(--line-soft); }
.item-grid-head { min-height: 40px; padding-block: 7px; color: var(--muted); background: var(--surface-raised); border-top: 0; font-size: var(--type-caption); line-height: 18px; }
.item-grid-head span:nth-child(n+2):nth-child(-n+6) { text-align: right; }
.item-description { min-width: 0; display: grid; gap: 5px; }
.item-grid label { min-width: 0; }
.item-grid input { min-height: 36px; padding: 6px 8px; }
.item-description [data-description] { font-weight: 600; }
.item-description [data-specification] { color: var(--muted); font-size: var(--type-label); }
.item-description [data-product-picker] { color: var(--accent); background: var(--accent-soft); border-color: #aad0cc; font-size: var(--type-label); }
.item-grid output { justify-self: end; color: var(--text-strong); font-weight: 600; font-variant-numeric: tabular-nums; }
.mobile-label { display: none; }
.add-row-button { width: 100%; min-height: 45px; display: flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-top: 1px dashed #b8bfbd; color: var(--accent); background: #fbfcfb; font-weight: 600; }
.add-row-button:hover { background: var(--accent-soft); }
.add-row-button .icon { width: 17px; height: 17px; }

.auth-page { overflow-x: hidden; background: var(--rail); }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(380px, .75fr); }
.auth-story { min-height: 100vh; position: relative; overflow: hidden; background: var(--navy-deep); }
.auth-story::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(8,24,40,.08) 15%, rgba(8,24,40,.94) 100%); }
.auth-story > img { width: 100%; height: 100%; position: absolute; inset: 0; object-fit: cover; }
.auth-story-copy { max-width: 680px; position: absolute; z-index: 1; right: 7vw; bottom: 8vh; left: 7vw; color: #fff; }
.auth-story-copy .eyebrow { color: #efd8a7; }
.auth-story-copy h1 { margin: 8px 0 10px; color: #fff; font-size: clamp(30px, 4vw, 54px); line-height: 1.24; font-weight: 600; letter-spacing: -.025em; }
.auth-story-copy p { max-width: 600px; color: #dfe6eb; font-size: 17px; line-height: 27px; }
.auth-panel { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: clamp(30px, 5vw, 72px); background: #fff; }
.auth-brand { position: absolute; top: 28px; display: flex; align-items: center; gap: 10px; }
.auth-brand img { width: 42px; height: 42px; object-fit: contain; }
.auth-brand div { display: grid; }
.auth-brand strong { color: var(--navy); font-size: var(--type-title); }
.auth-brand span { color: var(--muted-2); font-size: 11px; }
.auth-copy { margin-bottom: 22px; }
.auth-copy h2 { margin: 4px 0; color: var(--text-strong); font-size: 28px; line-height: 36px; font-weight: 600; }
.auth-copy p { color: var(--muted); }
.auth-panel .notice { margin-bottom: 14px; }
.auth-foot { margin-top: 22px; color: var(--muted-2); font-size: var(--type-caption); }
.auth-foot strong { color: var(--navy); }
.rail-scrim { display: none; }

@media (max-width: 1180px) {
  .metric-strip { grid-template-columns: repeat(2, 1fr); }
  .dashboard-columns { grid-template-columns: minmax(0, 1.5fr) minmax(270px, .75fr); }
  .quote-builder { grid-template-columns: minmax(0, 1fr) 286px; }
  .item-grid { grid-template-columns: minmax(235px, 1fr) 68px 70px 98px 74px 94px 38px; gap: 6px; padding-inline: 9px; }
  .split-layout { grid-template-columns: minmax(0, 1.35fr) 330px; }
}

@media (max-width: 960px) {
  .dashboard-columns { grid-template-columns: 1fr; }
  .side-column { grid-template-columns: 1fr 1fr; }
  .craft-banner > div { width: 68%; }
  .quote-builder { grid-template-columns: 1fr; }
  .quote-summary { position: static; grid-template-columns: minmax(0, 1fr) 300px; }
  .pdf-note { min-height: 120px; }
  .item-grid { grid-template-columns: minmax(245px, 1fr) 72px 76px 106px 78px 96px 40px; }
  .split-layout { grid-template-columns: 1fr; }
  .form-panel { position: static; }
  .settings-form { grid-template-columns: 1fr; }
  .topbar { grid-template-columns: 155px 1fr 46px; }
  .user-chip > div { display: none; }
}

@media (max-width: 760px) {
  :root { --rail-width: 0px; --topbar-height: 58px; }
  body { padding-bottom: 66px; }
  .rail { width: min(78vw, 270px); align-items: stretch; padding: 10px; transform: translateX(-105%); transition: transform .18s ease; box-shadow: 16px 0 40px rgba(0,0,0,.24); }
  .rail.open { transform: translateX(0); }
  .rail-brand { margin: 2px 0 16px 6px; }
  .rail nav a, .rail-logout button { min-height: 48px; grid-template-columns: 28px 1fr; justify-items: start; gap: 10px; padding: 8px 12px; border-radius: 7px; font-size: var(--type-body); }
  .rail nav a::before { inset: 8px auto 8px -10px; }
  .workspace { margin-left: 0; }
  .topbar { grid-template-columns: 42px minmax(0,1fr) 40px; gap: 8px; padding: 0 12px; }
  .mobile-menu { display: grid; }
  .topbar-context { display: none; }
  .global-search { height: 40px; }
  .global-search kbd { display: none; }
  .user-chip > span { width: 34px; height: 34px; }
  .bottom-nav { height: 66px; position: fixed; z-index: 100; inset: auto 0 0; display: grid; grid-template-columns: repeat(4, 1fr); color: #c4cdd6; background: #1d2937; border-top: 1px solid rgba(255,255,255,.08); }
  .bottom-nav a { min-width: 0; position: relative; display: grid; justify-items: center; align-content: center; gap: 2px; font-size: 10px; line-height: 14px; }
  .bottom-nav a::before { content: ""; position: absolute; inset: 0 8px auto; height: 3px; border-radius: 0 0 3px 3px; background: transparent; }
  .bottom-nav a.active { color: #fff; background: #2b3b4f; }
  .bottom-nav a.active::before { background: var(--gold); }
  .bottom-nav .icon { width: 19px; height: 19px; }
  .rail-scrim { position: fixed; z-index: 110; inset: 0; display: block; background: rgba(5,12,18,.54); }
  .rail-scrim[hidden] { display: none; }
  .page-layout { padding: 17px 12px 26px; }
  .workspace > main > .page-notice { width: calc(100% - 24px); }
  .page-header, .dashboard-intro { align-items: flex-start; gap: 12px; }
  .page-header h1, .dashboard-intro h1 { font-size: 24px; }
  .metric-strip { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric-strip > a { min-height: 84px; grid-template-columns: 36px 1fr; padding: 10px; }
  .metric-icon { width: 36px; height: 36px; }
  .side-column { grid-template-columns: 1fr; }
  .craft-banner { min-height: 280px; }
  .craft-banner::after { background: linear-gradient(180deg, rgba(8,24,40,.24) 0%, rgba(8,24,40,.96) 72%); }
  .craft-banner > div { width: 100%; position: absolute; bottom: 0; padding: 20px; }
  .toolbar { align-items: stretch; flex-wrap: wrap; }
  .toolbar .search-control { flex-basis: 100%; }
  .toolbar .select-control { flex: 1; }
  .toolbar .select-control select { min-width: 0; }
  .clear-filter { margin-left: 0; }
  .page-header.quote-header { display: grid; }
  .quote-header-actions { flex-wrap: wrap; }
  .builder-steps small { display: none; }
  .quote-summary { grid-template-columns: 1fr; }
  .item-grid-head { display: none; }
  .item-grid { position: relative; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px 48px 14px 12px; }
  .item-description { grid-column: 1 / -1; }
  .item-grid > output { min-height: 40px; display: grid; align-items: center; justify-content: end; padding: 0 10px; border-radius: 7px; color: var(--navy); background: var(--gold-soft); }
  .item-grid > output::before { content: "รวม "; color: var(--muted); font-weight: 400; }
  .item-grid > .icon-button { position: absolute; top: 12px; right: 6px; }
  .mobile-label { display: block; color: var(--muted); font-size: 11px; line-height: 16px; }
  .builder-fields { grid-template-columns: 1fr; }
  .field-span-2 { grid-column: auto; }
  .settings-form .field-grid { grid-template-columns: 1fr; }
  .sticky-save { align-items: stretch; flex-direction: column; bottom: 72px; }
  .sticky-save .button { width: 100%; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-story { display: none; }
  .auth-panel { min-height: 100vh; padding: 92px 24px 32px; }
  .auth-brand { top: 24px; }
}

@media (max-width: 480px) {
  .page-header, .dashboard-intro { display: grid; }
  .page-header .button, .dashboard-intro .button { width: 100%; }
  .metric-strip { grid-template-columns: 1fr; }
  .metric-strip > a { min-height: 76px; }
  .field-grid { grid-template-columns: 1fr; }
  .builder-steps strong { font-size: 12px; }
  .builder-steps li { grid-template-columns: 28px 1fr; gap: 6px; }
  .builder-steps li > span { width: 28px; height: 28px; }
  .builder-steps li:not(:last-child)::after { top: 14px; left: 28px; }
  .quote-header-actions .button, .quote-header-actions .status-form { width: 100%; }
  .status-form select { width: 100%; }
  .summary-options { grid-template-columns: 1fr; }
  .summary-options label:first-child { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

@media (forced-colors: active) {
  .status, .surface, .metric-strip > a, .button, input, select, textarea { border: 1px solid CanvasText; }
  .builder-steps li > span { border: 2px solid CanvasText; }
}
