* { box-sizing: border-box; }
:root { color-scheme: light; font: 16px/1.55 "Phetsarath OT","Noto Sans Lao","Lao UI","Leelawadee UI","DokChampa","Microsoft YaHei UI",system-ui,sans-serif; color: #152847; background: #edf3fa; --blue: #1c55b3; --navy: #102950; --line: #d7e2f1; --muted: #516685; }
body { margin: 0; min-width: 0; }
button,input,select,textarea { font: inherit; }
a { color: #174fa5; }
button,summary { cursor: pointer; }
:focus-visible { outline: 3px solid #e7a632; outline-offset: 3px; }
[hidden] { display: none !important; }
h1,h2,p,dl { margin: 0; }
h1 { font-size: clamp(1.55rem, 3vw, 2.4rem); line-height: 1.25; overflow-wrap: anywhere; }
h2 { font-size: 1.19rem; margin: 22px 0 10px; }
.panel h2:first-child { margin-top: 0; }
.workspace { display: grid; grid-template-columns: 240px minmax(0,1fr); min-height: 100vh; }
.sidebar { background: #102e61; color: #fff; padding: 24px 15px; display: flex; flex-direction: column; align-self: start; position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; }
.sidebar-footer { margin-top: auto; padding-top: 18px; }
.brand { display: flex; gap: 12px; align-items: center; }
.sidebar .brand { margin: 0 0 26px; padding: 0 6px; }
.brand strong { font-size: 1.13rem; letter-spacing: .045em; display: block; white-space: nowrap; }
.brand strong span { color: #8ab7ff; }
.brand small { font-size: .75rem; display: block; color: #d4e3fb; line-height: 1.45; }
.brand-mark { display: flex; align-items: end; justify-content: center; gap: 3px; flex: 0 0 38px; height: 38px; background: #2b65c0; border-radius: 11px; padding-bottom: 10px; }
.brand-mark i { width: 4px; border-radius: 3px; background: #fff; height: 9px; }
.brand-mark i:nth-child(2) { height: 13px; }
.brand-mark i:nth-child(3) { height: 18px; background: #a4d9ff; }
nav { display: grid; gap: 5px; }
nav a { display: flex; align-items: center; gap: 11px; padding: 10px; min-height: 44px; color: #deeaff; text-decoration: none; border-radius: 9px; min-width: 0; overflow-wrap: anywhere; }
nav a span { display: grid; place-items: center; flex: 0 0 25px; height: 25px; border-radius: 6px; background: #ffffff1a; color: #cfe5ff; }
nav a:hover,nav a[aria-current] { background: #234d8e; color: #fff; }
.top { min-height: 62px; background: #fff; border-bottom: 1px solid var(--line); padding: 8px clamp(14px,3vw,32px); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.top-title,.top-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.top-title strong { font-size: .92rem; }
.top-title span,.identity { color: var(--muted); font-size: .82rem; overflow-wrap: anywhere; }
main { max-width: 1260px; margin: auto; padding: clamp(14px, 3vw, 32px); }
.title { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.title > div { min-width: 0; }
.welcome p,.eyebrow { color: var(--muted); font-size: .95rem; margin-bottom: 3px; }
.welcome-meta,.row { display: flex; align-items: center; gap: 8px; }
.row.spread { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.date-badge,.tag { display: inline-flex; align-items: center; background: #e6efff; color: #1d4c91; border-radius: 7px; padding: 3px 8px; font-size: .87rem; overflow-wrap: anywhere; }
.tag.warn { color: #6c4300; background: #fff0cc; }
.tag.muted { color: #435575; background: #edf1f6; }
.panel { min-width: 0; background: #fff; border: 1px solid var(--line); border-radius: 15px; padding: clamp(13px,2vw,21px); margin-bottom: 13px; }
.grid { display: grid; gap: 12px; min-width: 0; }
.grid > .panel { margin-bottom: 0; }
.grid + .grid,.grid + .panel { margin-top: 13px; }
.overview { grid-template-columns: repeat(2,minmax(0,1.35fr)) minmax(0,1fr); }
.two { grid-template-columns: repeat(2,minmax(0,1fr)); }
.four { grid-template-columns: repeat(4,minmax(0,1fr)); }
.staff-progress,.customer-grid,.fields { grid-template-columns: repeat(auto-fit,minmax(min(100%,220px),1fr)); }
.customer-grid { grid-template-columns: repeat(auto-fill,minmax(min(100%,275px),1fr)); }
.metric-label { color: #455e82; font-size: .91rem; font-weight: 600; }
.metric-number { font-size: clamp(1.5rem,3.6vw,2.55rem); font-weight: 750; line-height: 1.18; margin: 9px 0 11px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.metric-number span { font-size: .53em; color: #516685; font-weight: 600; }
.meter.accent { background: linear-gradient(145deg,#194f9f,#113976); color: white; border-color: #194f9f; }
.accent .metric-label,.accent .metric-number span,.accent .progress-foot { color: #eaf2ff; }
progress { display: block; appearance: none; width: 100%; height: 9px; background: #e1ecfc; border: 0; border-radius: 20px; overflow: hidden; }
progress::-webkit-progress-bar { background: #e1ecfc; border-radius: 20px; }
progress::-webkit-progress-value { background: #2364c7; border-radius: 20px; }
progress::-moz-progress-bar { background: #2364c7; border-radius: 20px; }
.accent progress,.accent progress::-webkit-progress-bar { background: #ffffff38; }
.accent progress::-webkit-progress-value { background: #a6d7ff; }
.accent progress::-moz-progress-bar { background: #a6d7ff; }
.progress-foot { display: flex; justify-content: space-between; gap: 5px 9px; flex-wrap: wrap; color: var(--muted); font-size: .87rem; margin: 8px 0 4px; }
.remaining { color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.shortcuts { grid-template-columns: repeat(auto-fit,minmax(min(100%,150px),1fr)); }
.shortcut { display: flex; flex-direction: column; justify-content: center; min-height: 112px; gap: 8px; border-radius: 13px; padding: 13px; background: #fff; border: 1px solid var(--line); text-decoration: none; overflow-wrap: anywhere; }
.shortcut span { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: #e6efff; color: #194e9c; font-size: 1.22rem; }
.shortcut:hover { border-color: #5a8cdd; }
.shortcut.lead { background: #dceaff; border-color: #bed6fa; }
.button { border: 1px solid transparent; border-radius: 8px; padding: 8px 13px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; text-align: center; font-weight: 650; line-height: 1.35; white-space: normal; }
.button.primary { background: var(--blue); color: #fff; }
.button.primary:hover { background: #143f86; }
.button.danger { color: #fff; background: #9b281f; }
.button.danger:hover { background: #7d2018; }
.button.secondary,.button.ghost { background: #edf4ff; color: #174984; border-color: #d3e1f5; }
.button.ghost { background: #fff; }
.button:disabled { opacity: .64; cursor: wait; }
.vstack { display: grid; gap: 14px; }
.vstack > .button { justify-self: start; min-width: 110px; }
.form-panel { max-width: 950px; }
.visit-form { gap: 10px; }
.visit-fields { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px 12px; }
.visit-sections { display: grid; gap: 7px; }
.visit-section { border: 1px solid var(--line); border-radius: 9px; min-width: 0; }
.visit-section summary { padding: 8px 10px; list-style-position: inside; font-weight: 650; }
.visit-section summary .tag { float: right; }
.visit-section > :not(summary) { padding: 0 9px 9px; }
.visit-section legend { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.visit-actions { position: sticky; bottom: 0; z-index: 1; background: #fff; padding: 7px 0; border-top: 1px solid var(--line); }
.visit-actions .button { min-width: 110px; }
.date-scopes { margin-bottom: 4px; }
.field { display: grid; align-content: start; gap: 5px; font-size: .91rem; font-weight: 620; min-width: 0; }
.field input,.field select,.field textarea { width: 100%; min-width: 0; max-width: 100%; padding: 8px 9px; min-height: 45px; border: 1px solid #bacbe1; border-radius: 8px; color: #172c4e; background-color: #fff; font-size: 1rem; font-weight: 500; }
.field select { appearance: none; padding-right: 28px; background-image: linear-gradient(45deg,transparent 50%,#345888 50%),linear-gradient(135deg,#345888 50%,transparent 50%); background-position: calc(100% - 15px) 50%,calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.field input:disabled { background: #edf1f6; }
textarea { resize: vertical; }
fieldset { min-width: 0; margin: 0; padding: 6px 0 0; border: 0; }
legend { padding: 0; font-weight: 660; }
.checks { display: grid; gap: 6px; grid-template-columns: repeat(auto-fit,minmax(min(100%,210px),1fr)); }
.choice { display: flex; align-items: center; gap: 8px; min-height: 44px; border: 1px solid #d6e2f2; border-radius: 8px; background: #f5f8ff; padding: 7px 9px; color: #213d66; overflow-wrap: anywhere; }
.choice input { flex: 0 0 18px; width: 18px; height: 18px; accent-color: var(--blue); margin: 0; }
.choice:has(input:checked) { border-color: #5387d6; background: #e6f0ff; }
.filters .actions { margin-top: 12px; flex-wrap: wrap; }
.details { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,165px),1fr)); gap: 12px; }
.meta { margin-bottom: 14px; }
.padded { margin-top: 12px; }
dt { color: var(--muted); font-size: .87rem; }
dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.client-title { font-size: 1.08rem; font-weight: 750; overflow-wrap: anywhere; }
.client p { margin: 4px 0; overflow-wrap: anywhere; }
.muted-text,.empty { color: var(--muted); font-size: .92rem; }
.empty { padding: 9px 0; }
.table-scroll { overflow: auto; max-width: 100%; }
table { text-align: start; border-collapse: collapse; width: 100%; font-size: .91rem; }
th,td { padding: 9px; border-bottom: 1px solid #e2eaf5; text-align: start; vertical-align: top; overflow-wrap: anywhere; }
th { color: #355882; background: #eff5fe; }
td:first-child { min-width: 82px; }
summary { color: #174984; padding: 6px 0; min-height: 44px; }
.audit-values { display: grid; gap: 6px; padding: 7px 0; }
.commission-layout { display: grid; grid-template-columns: minmax(0,1.7fr) minmax(0,1fr); gap: 12px; align-items: start; }
.estimate-row { display: grid; grid-template-columns: minmax(0,1.4fr) minmax(0,1fr) minmax(0,1fr); gap: 8px; align-items: end; }
.rate,.estimate-row output { font-size: .89rem; color: var(--muted); overflow-wrap: anywhere; padding-bottom: 9px; }
.estimate-row output { font-weight: 680; color: #123f84; text-align: end; }
.estimate-card { background: #143e80; color: #fff; border-color: #143e80; }
.estimate-summary { display: grid; gap: 14px; }
.estimate-summary dt { color: #e2edff; }
.estimate-summary dd { font-size: 1.3rem; font-weight: 740; }
.estimate-summary div:last-child { border-top: 1px solid #ffffff4f; padding-top: 11px; }
.notes { margin: 0 0 8px; padding-inline-start: 23px; }
.notes li { margin: 6px 0; }
.error { color: #9b281f; overflow-wrap: anywhere; }
#toast { position: fixed; inset: auto 15px 15px auto; max-width: min(480px,calc(100% - 30px)); border: 1px solid #315d9f; border-radius: 10px; padding: 12px 16px; background: #153b77; color: white; box-shadow: 0 4px 18px #17315c33; z-index: 10; overflow-wrap: anywhere; }
.login-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(0,1fr) minmax(0,420px); align-items: center; gap: clamp(18px,6vw,78px); padding: clamp(18px,9vw,120px); background: radial-gradient(ellipse at 9% 90%,#2862b0,transparent 63%),linear-gradient(125deg,#0f2850,#194984); }
.login-brand { color: #fff; }
.login-brand .brand strong { font-size: clamp(1.65rem,4vw,3rem); white-space: normal; }
.login-brand .brand small { font-size: clamp(.95rem,2vw,1.27rem); }
.login-brand .brand-mark { scale: 1.25; margin-inline: 5px; }
.login-card { background: #fff; border-radius: 18px; padding: clamp(18px,4vw,34px); box-shadow: 0 20px 56px #0d24495c; }
.login-card .vstack > .button { justify-self: stretch; }
.login-tools { display: flex; justify-content: end; }
@media (max-width: 980px) {
  .workspace { grid-template-columns: 192px minmax(0,1fr); }
  .overview { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .overview .compact { grid-column: 1 / -1; }
}
@media (max-width: 690px) {
  .workspace { display: flex; flex-direction: column; }
  .sidebar { padding: 9px 12px; position: static; height: auto; align-self: stretch; overflow: visible; }
  .sidebar-footer { position: fixed; z-index: 3; left: 10px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); display: block; padding: 0; background: #102e61; border-radius: 9px; box-shadow: 0 2px 8px #102e6133; }
  .sidebar-footer a { padding-inline: 10px; }
  .admin-workspace main { padding-bottom: calc(66px + env(safe-area-inset-bottom, 0px)); }
  .visit-section .checks { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .visit-section .choice { gap: 5px; padding-inline: 6px; font-size: .9rem; }
  .visit-actions .button { width: 100%; }
  .sidebar .brand { display: none; }
  nav { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 3px 5px; }
  nav a { padding: 4px; gap: 4px; font-size: .79rem; line-height: 1.35; }
  nav a span { flex-basis: 18px; height: 20px; }
  .top { order: -1; }
  .top-title span,.identity { display: none; }
  .four { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .commission-layout { grid-template-columns: minmax(0,1fr); }
  .login-layout { display: flex; justify-content: center; flex-direction: column; padding: 19px; gap: 24px; }
  .login-card,.login-brand { width: min(100%,420px); }
  .shortcuts { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 360px) {
  .overview,.two { grid-template-columns: minmax(0,1fr); }
  .estimate-row { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .estimate-row .field { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
