/* ============================================================================
   BuildDesk PH — Design system
   Warm, professional, trustworthy. Sidebar shell + cards. Light/dark aware.
   ============================================================================ */
:root {
  --amber:      #d97706;   /* primary — construction amber */
  --amber-600:  #b45309;
  --amber-50:   #fff7ed;
  --ink:        #1c1917;   /* stone-900 */
  --ink-2:      #44403c;   /* stone-700 */
  --muted:      #78716c;   /* stone-500 */
  --line:       #e7e2dc;
  --line-2:     #efeae4;
  --bg:         #faf8f5;   /* warm paper */
  --panel:      #ffffff;
  --panel-2:    #fbf9f6;
  --green:      #15803d;
  --green-bg:   #dcfce7;
  --red:        #b91c1c;
  --red-bg:     #fee2e2;
  --blue:       #1d4ed8;
  --blue-bg:    #dbeafe;
  --amber-bg:   #fef3c7;
  --purple:     #6d28d9;
  --purple-bg:  #ede9fe;
  --shadow:     0 1px 2px rgba(28,25,23,.06), 0 4px 16px rgba(28,25,23,.05);
  --shadow-lg:  0 10px 40px rgba(28,25,23,.14);
  --radius:     14px;
  --radius-sm:  10px;
  --sidebar-w:  248px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink:#f5f2ee; --ink-2:#d6d0c9; --muted:#a8a29e; --line:#302c28; --line-2:#26221f;
    --bg:#1a1613; --panel:#231e1a; --panel-2:#1f1a16; --amber-50:#2a2118;
    --green-bg:#12371f; --red-bg:#3a1717; --blue-bg:#152244; --amber-bg:#33260f; --purple-bg:#241a3a;
    --shadow:0 1px 2px rgba(0,0,0,.3),0 4px 16px rgba(0,0,0,.28); --shadow-lg:0 10px 40px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  --ink:#f5f2ee; --ink-2:#d6d0c9; --muted:#a8a29e; --line:#302c28; --line-2:#26221f;
  --bg:#1a1613; --panel:#231e1a; --panel-2:#1f1a16; --amber-50:#2a2118;
  --green-bg:#12371f; --red-bg:#3a1717; --blue-bg:#152244; --amber-bg:#33260f; --purple-bg:#241a3a;
  --shadow:0 1px 2px rgba(0,0,0,.3),0 4px 16px rgba(0,0,0,.28); --shadow-lg:0 10px 40px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--amber-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }

/* -------------------------------------------------------------- app shell */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 20px 18px 14px; display: flex; align-items: center; gap: 11px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 10px; flex: 0 0 38px;
  background: linear-gradient(135deg, var(--amber), var(--amber-600));
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 18px;
  box-shadow: var(--shadow);
}
.brand-name { font-weight: 800; font-size: 16px; line-height: 1.1; }
.brand-sub { font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.nav { padding: 6px 10px; overflow-y: auto; flex: 1; }
.nav-group { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 14px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-weight: 600; cursor: pointer; margin: 1px 0; font-size: 14px;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--panel-2); color: var(--ink); }
.nav-item.active { background: var(--amber-50); color: var(--amber-600); }
.nav-ico { width: 18px; text-align: center; font-size: 15px; opacity: .9; }
.nav-badge { margin-left: auto; background: var(--amber); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.sidebar-foot { padding: 12px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; border-bottom: 1px solid var(--line); background: var(--panel);
  display: flex; align-items: center; gap: 14px; padding: 0 24px; position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 18px; }
.topbar .crumb { color: var(--muted); font-weight: 600; }
.topbar-spacer { flex: 1; }
.content { padding: 24px; max-width: 1180px; width: 100%; margin: 0 auto; }

/* menu toggle (mobile) */
.menu-toggle { display: none; }

/* ------------------------------------------------------------------ cards */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.card.pad-0 { padding: 0; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h3 { font-size: 15.5px; }
.card-head .sub { color: var(--muted); font-size: 12.5px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.mono { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.center { text-align: center; }
.mt-0{margin-top:0}.mt-1{margin-top:8px}.mt-2{margin-top:16px}.mb-1{margin-bottom:8px}.mb-2{margin-bottom:16px}

/* ------------------------------------------------------------------ stats */
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat-value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.stat-sub { font-size: 12px; margin-top: 6px; color: var(--ink-2); }
.stat-primary { background: linear-gradient(135deg, var(--amber), var(--amber-600)); border-color: transparent; }
.stat-primary .stat-value, .stat-primary .stat-label, .stat-primary .stat-sub { color: #fff; }
.stat-primary .stat-label { color: rgba(255,255,255,.85); }

/* ---------------------------------------------------------------- badges */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700;
  padding: 2px 9px; border-radius: 999px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-amber { background: var(--amber-bg); color: var(--amber-600); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); background: var(--panel); }
.chip-amber { border-color: var(--amber); color: var(--amber-600); background: var(--amber-50); }

/* ----------------------------------------------------------------- bars */
.bar { height: 8px; background: var(--line-2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--amber); border-radius: 999px; transition: width .3s ease; }
.bar-green { background: var(--green); }
.bar-blue { background: var(--blue); }

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  padding: 9px 15px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); transition: all .12s; white-space: nowrap;
}
.btn:hover { background: var(--panel-2); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--amber); border-color: var(--amber); color: #fff; }
.btn-primary:hover { background: var(--amber-600); border-color: var(--amber-600); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(.94); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--panel-2); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ----------------------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
.field-label { font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.field-hint { font-size: 11.5px; color: var(--muted); }
.input {
  font-family: inherit; font-size: 14px; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 11px; width: 100%;
}
.input:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-50); }
textarea.input { resize: vertical; min-height: 64px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }

/* ---------------------------------------------------------------- tables */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--panel-2); }
.table .right { text-align: right; }

/* --------------------------------------------------------------- checklist */
.check-item { display: flex; gap: 11px; padding: 10px 12px; border-radius: var(--radius-sm); align-items: flex-start; }
.check-item:hover { background: var(--panel-2); }
.check-box {
  width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--line); flex: 0 0 20px;
  cursor: pointer; display: grid; place-items: center; margin-top: 1px; background: var(--panel); transition: all .12s;
}
.check-box.done { background: var(--green); border-color: var(--green); color: #fff; }
.check-label { flex: 1; }
.check-label.done { color: var(--muted); text-decoration: line-through; }

/* ------------------------------------------------------------------ misc */
.section-title { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 22px 0 10px; display: flex; align-items: center; justify-content: space-between; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-title { font-weight: 700; color: var(--ink-2); font-size: 15px; }
.empty-sub { font-size: 13px; margin: 6px 0 14px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; }
.pill-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.pill-tab { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel);
  font-weight: 600; font-size: 13px; cursor: pointer; color: var(--ink-2); }
.pill-tab.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* phase stepper */
.stepper { display: flex; flex-wrap: wrap; gap: 8px; }
.step { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); font-size: 12.5px; font-weight: 600; }
.step-dot { width: 9px; height: 9px; border-radius: 999px; background: var(--line); }
.step.done { border-color: var(--green); color: var(--green); background: var(--green-bg); }
.step.done .step-dot { background: var(--green); }
.step.current { border-color: var(--amber); color: var(--amber-600); background: var(--amber-50); }
.step.current .step-dot { background: var(--amber); }

/* --------------------------------------------------------------- toast */
.toast-host { position: fixed; bottom: 20px; right: 20px; z-index: 3000; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 600; opacity: 0; transform: translateY(10px);
  transition: all .25s; max-width: 340px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-green { background: var(--green); color: #fff; }
.toast-red { background: var(--red); color: #fff; }

/* --------------------------------------------------------------- modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(28,25,23,.5); display: grid; place-items: center;
  z-index: 2000; opacity: 0; transition: opacity .2s; padding: 20px; overflow-y: auto; }
.modal-overlay.show { opacity: 1; }
.modal { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; max-height: 88vh; display: flex; flex-direction: column; transform: scale(.97); transition: transform .2s; }
.modal-overlay.show .modal { transform: scale(1); }
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-title { flex: 1; font-size: 16px; }
.modal-x { background: none; border: none; font-size: 24px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.modal-x:hover { color: var(--ink); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }

/* --------------------------------------------------------- responsive */
@media (max-width: 860px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 100; transform: translateX(-100%); transition: transform .25s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; }
  .content { padding: 16px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 8px; }
}
@media (max-width: 560px) {
  .grid-3, .grid-4, .grid-2 { grid-template-columns: 1fr; }
}

/* ----- scrim for mobile sidebar ----- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 90; display: none; }
.scrim.show { display: block; }
