/* ==========================================================================
   Shine Right Detailing — Operations Console
   Mobile-first. Ubuntu (UI/headings) + Lato (body/data).
   ========================================================================== */

:root {
  /* Brand */
  --blue: #2f6ef2;
  --blue-700: #1f56cc;
  --blue-050: #eef3fe;
  --blue-100: #dbe6fd;
  --gray: #848484;
  --black: #0b0d10;
  --white: #ffffff;

  /* Surfaces */
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --line: #e5e7ec;
  --line-strong: #d3d6dd;

  /* Text */
  --ink: #0b0d10;
  --ink-2: #4a4d55;
  --ink-3: #848484;
  --ink-4: #a7a9b0;

  /* Functional (kept low-saturation to sit beside the brand blue) */
  --pos: #1f7a4d;
  --pos-bg: #e9f5ef;
  --warn: #9a6a11;
  --warn-bg: #fbf2e2;
  --neg: #b23b3b;
  --neg-bg: #fbeceb;

  /* Geometry */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(11, 13, 16, .05);
  --shadow: 0 2px 8px rgba(11, 13, 16, .06);
  --shadow-lg: 0 12px 32px rgba(11, 13, 16, .12);
  --shadow-pop: 0 16px 48px rgba(11, 13, 16, .16);

  --sidebar-w: 244px;
  --topbar-h: 58px;
  --tabbar-h: 60px;

  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);

  --ease: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Lato', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
}

body.nav-open { overflow: hidden; }

h1, h2, h3, h4, h5,
.u, .btn, .nav-link, .stat-val, .tab, .chip, .badge, .num {
  font-family: 'Ubuntu', -apple-system, BlinkMacSystemFont, sans-serif;
}

h1, h2, h3, h4 { margin: 0; color: var(--ink); font-weight: 700; letter-spacing: -.02em; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
h4 { font-size: 13px; }
p { margin: 0 0 12px; }
a { color: var(--blue); text-decoration: none; }
img, svg { max-width: 100%; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

.num { font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* Default icon size. Deliberately low specificity (0,1,0) so the component
   rules below (.btn svg, .nav-link svg, …) still win. */
.ico { width: 16px; height: 16px; flex: 0 0 auto; }

/* ---------- Layout shell ------------------------------------------------ */

.app { min-height: 100dvh; }

.main {
  padding: 0 0 calc(var(--tabbar-h) + var(--sab) + 20px);
  min-height: 100dvh;
}

.page {
  padding: 16px 16px 32px;
  max-width: 1360px;
  margin: 0 auto;
}

/* ---------- Top bar (mobile) -------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: calc(var(--topbar-h) + var(--sat));
  padding-top: var(--sat);
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 12px;
  padding-right: 12px;
}

.topbar-title {
  font-family: 'Ubuntu', sans-serif;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -.02em;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar .logo-mark { height: 26px; width: auto; display: block; }

.icon-btn {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 10px;
  color: var(--ink-2);
  transition: background .15s var(--ease), color .15s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.icon-btn:active { background: var(--line); }
.icon-btn.has-dot { position: relative; }
.icon-btn.has-dot::after {
  content: '';
  position: absolute;
  top: 8px; right: 9px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--blue);
  border: 2px solid var(--white);
}

.avatar-btn { padding: 0; border: 0; background: none; }

/* ---------- Sidebar / drawer -------------------------------------------- */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(11, 13, 16, .42);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s var(--ease);
  z-index: 60;
  backdrop-filter: blur(2px);
}
body.nav-open .scrim { opacity: 1; pointer-events: auto; }

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 86vw;
  background: var(--white);
  border-right: 1px solid var(--line);
  z-index: 70;
  transform: translateX(-102%);
  transition: transform .28s var(--ease);
  display: flex;
  flex-direction: column;
  padding-top: var(--sat);
  overscroll-behavior: contain;
}
body.nav-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-pop); }

.sidebar-head {
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.sidebar-head .logo { height: 30px; width: auto; }

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px calc(20px + var(--sab));
  -webkit-overflow-scrolling: touch;
}

.nav-group + .nav-group { margin-top: 18px; }
.nav-label {
  font-family: 'Ubuntu', sans-serif;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-4);
  padding: 0 10px 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 10px;
  min-height: 44px;
  border-radius: 10px;
  color: var(--ink-2);
  font-size: 14.5px;
  font-weight: 500;
  transition: background .14s var(--ease), color .14s var(--ease);
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.nav-link svg { flex: 0 0 19px; width: 19px; height: 19px; color: var(--ink-3); transition: color .14s var(--ease); }
.nav-link:hover { background: var(--bg); color: var(--ink); }
.nav-link:hover svg { color: var(--ink-2); }
.nav-link.active { background: var(--blue-050); color: var(--blue-700); font-weight: 700; }
.nav-link.active svg { color: var(--blue); }
.nav-link .nav-count {
  margin-left: auto;
  font-family: 'Ubuntu', sans-serif;
  font-size: 11.5px;
  font-weight: 700;
  background: var(--line);
  color: var(--ink-2);
  border-radius: var(--r-pill);
  padding: 2px 8px;
  min-width: 22px;
  text-align: center;
}
.nav-link.active .nav-count { background: var(--blue); color: #fff; }

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 12px;
  padding-bottom: calc(12px + var(--sab));
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  transition: background .14s var(--ease);
}
.user-card:hover { background: var(--bg); }
.user-card .uc-name { font-family: 'Ubuntu', sans-serif; font-weight: 700; font-size: 13.5px; line-height: 1.2; color: var(--ink); }
.user-card .uc-role { font-size: 11.5px; color: var(--ink-3); }

/* ---------- Bottom tab bar (mobile only) -------------------------------- */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  height: calc(var(--tabbar-h) + var(--sab));
  padding-bottom: var(--sab);
  background: rgba(255, 255, 255, .93);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--ink-3);
  border: 0;
  background: none;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  transition: color .14s var(--ease);
  position: relative;
}
.tab svg { width: 21px; height: 21px; }
.tab.active { color: var(--blue); font-weight: 700; }
.tab.active::before {
  content: '';
  position: absolute;
  top: 0;
  width: 26px;
  height: 2.5px;
  border-radius: 0 0 3px 3px;
  background: var(--blue);
}
.tab:active { color: var(--blue-700); }

/* ---------- Buttons ------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--white);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .08s var(--ease), box-shadow .15s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn svg { width: 17px; height: 17px; }
.btn:hover { background: var(--surface-2); border-color: var(--gray); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(47, 110, 242, .3);
  position: relative;
  overflow: hidden;
}
.btn-primary:hover { background: var(--blue-700); border-color: var(--blue-700); }
/* "Shine" sweep — the one brand flourish */
.btn-primary::after {
  content: '';
  position: absolute;
  top: -60%; left: -30%;
  width: 30%; height: 220%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .38), transparent);
  transform: skewX(-18deg) translateX(-120%);
  pointer-events: none;
}
.btn-primary:hover::after { animation: shine .75s var(--ease); }
@keyframes shine { to { transform: skewX(-18deg) translateX(520%); } }

.btn-dark { background: var(--black); border-color: var(--black); color: #fff; font-weight: 700; }
.btn-dark:hover { background: #23262c; border-color: #23262c; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg); border-color: transparent; color: var(--ink); }
.btn-sm { min-height: 34px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn-sm svg { width: 15px; height: 15px; }
.btn-lg { min-height: 48px; padding: 0 22px; font-size: 15px; }
.btn-block { display: flex; width: 100%; }
.btn-icon { width: 38px; padding: 0; flex: 0 0 38px; }
.btn-danger { color: var(--neg); border-color: var(--line-strong); }
.btn-danger:hover { background: var(--neg-bg); border-color: var(--neg); }

/* ---------- Page header -------------------------------------------------- */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.page-head .ph-title { font-size: 23px; line-height: 1.2; }
.page-head .ph-sub { color: var(--ink-3); font-size: 13.5px; margin-top: 3px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-3);
  margin-bottom: 10px;
  font-family: 'Ubuntu', sans-serif;
}
.breadcrumb a { color: var(--ink-3); }
.breadcrumb a:hover { color: var(--blue); }
.breadcrumb svg { width: 13px; height: 13px; opacity: .6; }

/* ---------- Cards -------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.card-head h3 { font-size: 14.5px; }
.card-head .ch-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.card-body { padding: 16px; }
.card-body.tight { padding: 12px; }
.card-body.flush { padding: 0; }
.card-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 0 0 var(--r) var(--r);
}

/* minmax(0, 1fr) — NOT 1fr. A bare 1fr track has min-width:auto, so wide
   children (charts, tables, nowrap text) push the grid past the viewport. */
.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.grid-2, .grid-3, .grid-4 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.spacer { flex: 1; }

/* ---------- Stat tiles --------------------------------------------------- */

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 13px 14px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat-label {
  font-family: 'Ubuntu', sans-serif;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 6px;
}
.stat-label svg { width: 13px; height: 13px; }
.stat-val {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1.1;
  margin-top: 7px;
  font-variant-numeric: tabular-nums;
}
.stat-val .unit { font-size: 15px; color: var(--ink-3); font-weight: 500; letter-spacing: 0; }
.stat-meta { font-size: 12px; color: var(--ink-3); margin-top: 5px; display: flex; align-items: center; gap: 5px; }
.stat-meta svg { width: 13px; height: 13px; }
.stat-meta .up { color: var(--pos); font-weight: 700; }
.stat-meta .down { color: var(--neg); font-weight: 700; }
.stat.accent { border-color: var(--blue-100); background: linear-gradient(180deg, var(--blue-050), var(--white) 70%); }
.stat.accent .stat-val { color: var(--blue-700); }
.stat-spark { position: absolute; right: 0; bottom: 0; opacity: .5; pointer-events: none; }

/* ---------- Badges / pills ----------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  background: var(--line);
  color: var(--ink-2);
  white-space: nowrap;
  line-height: 1.5;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 6px; }
.badge-blue { background: var(--blue-050); color: var(--blue-700); }
.badge-dark { background: #e8eaee; color: var(--black); }
.badge-pos { background: var(--pos-bg); color: var(--pos); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-neg { background: var(--neg-bg); color: var(--neg); }
.badge-outline { background: transparent; border: 1px solid var(--line-strong); color: var(--ink-3); }
.badge-lg { font-size: 12.5px; padding: 5px 12px; }

.tagline { font-size: 12px; color: var(--ink-3); }

/* ---------- Filter chips (scrollable on mobile) -------------------------- */

.chips {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 2px 16px 12px;
  margin: 0 -16px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-snap-type: x proximity;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 13px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: var(--white);
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  scroll-snap-align: start;
  transition: all .15s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.chip .c-n { font-size: 11.5px; color: var(--ink-4); font-weight: 700; }
.chip:hover { border-color: var(--gray); }
.chip.active { background: var(--black); border-color: var(--black); color: #fff; font-weight: 700; }
.chip.active .c-n { color: rgba(255, 255, 255, .6); }

/* ---------- Search / inputs ---------------------------------------------- */

.field { display: block; margin-bottom: 14px; }
.field-label {
  display: block;
  font-family: 'Ubuntu', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.input, .select, .textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--white);
  color: var(--ink);
  font-size: 15px; /* >=16 avoids iOS zoom on focus; 15 + max on mobile below */
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
  appearance: none;
  -webkit-appearance: none;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-050);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-4); }
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23848484' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.search {
  position: relative;
  flex: 1;
  min-width: 0;
}
.search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--ink-4);
  pointer-events: none;
}
.search .input { padding-left: 38px; }

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

/* ---------- Tables → cards on mobile ------------------------------------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.data th {
  font-family: 'Ubuntu', sans-serif;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  white-space: nowrap;
}
table.data td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background .12s var(--ease); }
table.data tbody tr:hover { background: var(--surface-2); }
table.data .ta-r { text-align: right; }
table.data .nowrap { white-space: nowrap; }

/* Mobile list rows (used instead of tables under 860px) */
.list { display: grid; grid-template-columns: minmax(0, 1fr); }
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  min-height: 62px;
  transition: background .12s var(--ease);
  -webkit-tap-highlight-color: transparent;
  color: inherit;
}
.list-row:last-child { border-bottom: 0; }
.list-row:active { background: var(--bg); }
.list-row:hover { background: var(--surface-2); }
.lr-main { flex: 1; min-width: 0; }
.lr-title {
  font-family: 'Ubuntu', sans-serif;
  font-weight: 700;
  font-size: 14.5px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lr-sub {
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}
.lr-sub .sep { color: var(--line-strong); }
.lr-right { text-align: right; flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.lr-amt { font-family: 'Ubuntu', sans-serif; font-weight: 700; font-size: 14.5px; font-variant-numeric: tabular-nums; }
.lr-chev { color: var(--ink-4); flex: 0 0 16px; }
.lr-chev svg { width: 16px; height: 16px; display: block; }

/* Left rail colour-coding by service type */
.rail { border-left: 3px solid var(--line-strong); }
.rail-blue { border-left-color: var(--blue); }
.rail-dark { border-left-color: var(--black); }
.rail-gray { border-left-color: var(--gray); }
.rail-warn { border-left-color: var(--warn); }
.rail-pos { border-left-color: var(--pos); }
.rail-neg { border-left-color: var(--neg); }

/* ---------- Avatars ------------------------------------------------------ */

.avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: 'Ubuntu', sans-serif;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  background: var(--gray);
  letter-spacing: .01em;
  user-select: none;
  overflow: hidden;
}
.avatar-sm { width: 28px; height: 28px; flex: 0 0 28px; font-size: 10.5px; }
.avatar-lg { width: 56px; height: 56px; flex: 0 0 56px; font-size: 19px; }
.avatar-xl { width: 76px; height: 76px; flex: 0 0 76px; font-size: 25px; }
.avatar.a-blue { background: var(--blue); }
.avatar.a-dark { background: var(--black); }
.avatar.a-gray { background: var(--gray); }
.avatar.a-slate { background: #5a6472; }
.avatar.a-steel { background: #3c5a86; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { border: 2px solid var(--white); margin-left: -9px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ---------- Detail pages -------------------------------------------------- */

.detail-hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
}
.detail-hero .dh-top { display: flex; gap: 13px; align-items: flex-start; }
.detail-hero h1 { font-size: 21px; line-height: 1.2; }
.detail-hero .dh-meta { color: var(--ink-3); font-size: 13px; margin-top: 4px; }

.kv { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
.kv-item { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.kv-item:last-child { border-bottom: 0; }
.kv-k { color: var(--ink-3); font-size: 13.5px; flex: 0 0 auto; }
.kv-v { font-weight: 700; font-size: 13.5px; text-align: right; font-family: 'Ubuntu', sans-serif; min-width: 0; }
.kv-v.wrap { font-weight: 400; font-family: 'Lato', sans-serif; }

/* Tabs on detail pages */
.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  margin: 0 -16px 14px;
  padding: 0 16px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-link {
  flex: 0 0 auto;
  padding: 11px 12px;
  font-family: 'Ubuntu', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-3);
  border-bottom: 2.5px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  background: none;
  border-top: 0; border-left: 0; border-right: 0;
  -webkit-tap-highlight-color: transparent;
  transition: color .14s var(--ease), border-color .14s var(--ease);
}
.tab-link .c-n {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-4);
  background: var(--bg);
  border-radius: var(--r-pill);
  padding: 1px 7px;
  margin-left: 3px;
}
.tab-link.active .c-n { background: var(--blue-050); color: var(--blue); }
.tab-link:hover { color: var(--ink); }
.tab-link.active { color: var(--blue-700); border-bottom-color: var(--blue); font-weight: 700; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeUp .3s var(--ease); }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Timeline ------------------------------------------------------ */

.timeline { position: relative; padding-left: 26px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 8px; top: 6px; bottom: 6px;
  width: 1.5px;
  background: var(--line);
}
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: '';
  position: absolute;
  left: -22px; top: 4px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--line-strong);
}
.tl-item.on::before { border-color: var(--blue); background: var(--blue); box-shadow: 0 0 0 3px var(--blue-050); }
.tl-item.done::before { border-color: var(--black); background: var(--black); }
.tl-title { font-family: 'Ubuntu', sans-serif; font-weight: 700; font-size: 13.5px; }
.tl-meta { font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }
.tl-body { font-size: 13.5px; color: var(--ink-2); margin-top: 5px; }

/* ---------- Checklist ----------------------------------------------------- */

.checklist { display: grid; gap: 2px; }
.check {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 10px;
  border-radius: 9px;
  min-height: 46px;
  transition: background .14s var(--ease);
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
.check:hover { background: var(--surface-2); }
.check-box {
  width: 21px; height: 21px;
  flex: 0 0 21px;
  border-radius: 6px;
  border: 1.8px solid var(--line-strong);
  display: grid;
  place-items: center;
  background: var(--white);
  transition: all .16s var(--ease);
}
.check-box svg { width: 13px; height: 13px; color: #fff; opacity: 0; transform: scale(.6); transition: all .16s var(--ease); }
.check.on .check-box { background: var(--blue); border-color: var(--blue); }
.check.on .check-box svg { opacity: 1; transform: scale(1); }
.check-text { font-size: 14px; transition: color .16s var(--ease); }
.check.on .check-text { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.check .check-meta { margin-left: auto; font-size: 11.5px; color: var(--ink-4); font-family: 'Ubuntu', sans-serif; }

/* ---------- Progress ------------------------------------------------------ */

.bar { height: 6px; border-radius: var(--r-pill); background: var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: var(--r-pill); background: var(--blue); transition: width .5s var(--ease); }
.bar.dark > span { background: var(--black); }
.bar.gray > span { background: var(--gray); }
.bar-lg { height: 9px; }

/* ---------- Schedule ------------------------------------------------------ */

.cal-head {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 6px;
}
.cal-dow {
  text-align: center;
  font-family: 'Ubuntu', sans-serif;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 4px 0;
}
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-day {
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--white);
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  transition: all .14s var(--ease);
  -webkit-tap-highlight-color: transparent;
  min-width: 0;
}
.cal-day.mute { background: var(--surface-2); color: var(--ink-4); }
.cal-day.today { border-color: var(--blue); background: var(--blue-050); }
.cal-day.sel { border-color: var(--black); box-shadow: 0 0 0 1.5px var(--black); }
.cal-day:hover { border-color: var(--gray); }
.cal-n { font-family: 'Ubuntu', sans-serif; font-weight: 700; font-size: 12.5px; line-height: 1; }
.cal-day.today .cal-n { color: var(--blue-700); }
.cal-dots { display: flex; flex-wrap: wrap; gap: 2.5px; margin-top: auto; }
.cal-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--blue); display: block; }
.cal-dots i.g { background: var(--gray); }
.cal-dots i.k { background: var(--black); }
.cal-more { font-size: 9.5px; color: var(--ink-4); font-family: 'Ubuntu', sans-serif; font-weight: 700; }

/* Day agenda */
.agenda-item {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.agenda-item:last-child { border-bottom: 0; }
.ag-time {
  flex: 0 0 62px;
  font-family: 'Ubuntu', sans-serif;
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  line-height: 1.35;
}
.ag-time small { display: block; font-weight: 400; font-size: 11px; color: var(--ink-4); }
.ag-body { flex: 1; min-width: 0; }

/* ---------- Invoice ------------------------------------------------------- */

.doc {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.doc-head { padding: 20px 16px; border-bottom: 1px solid var(--line); }
.doc-body { padding: 16px; }
.doc-total-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 0;
  font-size: 14px;
}
.doc-total-row.grand {
  border-top: 1.5px solid var(--black);
  margin-top: 8px;
  padding-top: 13px;
  font-family: 'Ubuntu', sans-serif;
  font-weight: 700;
  font-size: 19px;
}
.doc-total-row .num { font-variant-numeric: tabular-nums; font-family: 'Ubuntu', sans-serif; font-weight: 700; }
.doc-total-row .lbl { color: var(--ink-3); }

.line-item { padding: 13px 0; border-bottom: 1px solid var(--line); }
.line-item:last-of-type { border-bottom: 1px solid var(--line); }
.li-top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.li-name { font-family: 'Ubuntu', sans-serif; font-weight: 700; font-size: 14.5px; }
.li-desc { font-size: 13px; color: var(--ink-3); margin-top: 3px; line-height: 1.5; }
.li-qty { font-size: 12.5px; color: var(--ink-3); margin-top: 4px; font-variant-numeric: tabular-nums; }
.li-amt { font-family: 'Ubuntu', sans-serif; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Photos -------------------------------------------------------- */

.photo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.photo {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(135deg, #dfe3ea, #c8cdd6);
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
}
.photo .ph-tag {
  position: absolute;
  top: 7px; left: 7px;
  font-family: 'Ubuntu', sans-serif;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  background: rgba(11, 13, 16, .75);
  color: #fff;
  padding: 3px 7px;
  border-radius: 5px;
  backdrop-filter: blur(4px);
}
.photo .ph-icon { color: rgba(11, 13, 16, .26); }
.photo .ph-icon svg { width: 30px; height: 30px; }
.photo.after { background: linear-gradient(135deg, #dbe6fd, #b7ccfa); }

/* ---------- Map (faux) ----------------------------------------------------- */

.map {
  position: relative;
  border-radius: var(--r);
  overflow: hidden;
  background: #eef0f3;
  border: 1px solid var(--line);
  aspect-ratio: 16 / 10;
}
.map svg { width: 100%; height: 100%; display: block; }
.map-pin-label {
  font-family: 'Ubuntu', sans-serif;
  font-size: 9px;
  font-weight: 700;
  fill: var(--ink-2);
}

/* ---------- Empty / misc --------------------------------------------------- */

.empty { text-align: center; padding: 40px 20px; color: var(--ink-3); }
.empty svg { width: 34px; height: 34px; color: var(--ink-4); margin-bottom: 10px; }
.empty h3 { color: var(--ink-2); margin-bottom: 4px; }

.divider { height: 1px; background: var(--line); margin: 16px 0; border: 0; }

.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.strong { font-weight: 700; }
.ta-r { text-align: right; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.hide { display: none !important; }

/* Sticky action bar on mobile detail pages */
.action-bar {
  position: sticky;
  bottom: calc(var(--tabbar-h) + var(--sab));
  z-index: 30;
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  margin: 16px -16px 0;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.action-bar .btn { flex: 1; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--sab) + 16px);
  transform: translate(-50%, 20px);
  z-index: 90;
  background: var(--black);
  color: #fff;
  font-family: 'Ubuntu', sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  padding: 11px 18px;
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: all .28s var(--ease);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 90vw;
}
.toast svg { width: 16px; height: 16px; color: #6ea8ff; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Segmented control */
.seg {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.seg button {
  border: 0;
  background: none;
  padding: 7px 13px;
  border-radius: 8px;
  font-family: 'Ubuntu', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
  min-height: 34px;
  transition: all .15s var(--ease);
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.seg button.active { background: var(--white); color: var(--ink); font-weight: 700; box-shadow: var(--shadow-sm); }

/* Mini bar chart */
.chart-bars { display: flex; align-items: stretch; gap: 6px; height: 140px; }
.cb-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
/* flex:1 inside a definite-height column gives the track a definite height,
   which is what lets the bars' percentage heights resolve. */
.cb-track { flex: 1; display: flex; align-items: flex-end; justify-content: center; min-height: 0; }
.cb-bar {
  width: 100%;
  max-width: 34px;
  max-height: 100%;
  background: var(--blue-100);
  border-radius: 5px 5px 2px 2px;
  transition: background .16s var(--ease);
  animation: growUp .6s var(--ease) backwards;
}
.cb-col:hover .cb-bar { background: var(--blue); }
.cb-bar.hi { background: var(--blue); }
.cb-lbl {
  font-family: 'Ubuntu', sans-serif;
  font-size: 10px;
  color: var(--ink-3);
  white-space: nowrap;
  text-align: center;
  margin-top: 7px;
  overflow: hidden;
}
@media (max-width: 559px) { .cb-lbl { font-size: 9px; } }
@keyframes growUp { from { height: 0 !important; opacity: .4; } }

/* Donut legend */
.legend { display: grid; gap: 9px; }
.legend-item { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.legend-item i { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 9px; }
.legend-item .lg-v { margin-left: auto; font-family: 'Ubuntu', sans-serif; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Note block */
.note {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gray);
  border-radius: 0 9px 9px 0;
  padding: 11px 13px;
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.55;
}
.note.blue { border-left-color: var(--blue); background: var(--blue-050); border-color: var(--blue-100); }
.note.warn { border-left-color: var(--warn); background: var(--warn-bg); border-color: #f0e2c6; color: #6d4c0c; }
.note-head { font-family: 'Ubuntu', sans-serif; font-weight: 700; font-size: 12.5px; margin-bottom: 3px; display: flex; align-items: center; gap: 6px; }
.note-head svg { width: 14px; height: 14px; }

/* ==========================================================================
   BREAKPOINTS
   ========================================================================== */

/* Small phones */
@media (max-width: 359px) {
  .stats { grid-template-columns: 1fr; }
  .tab { font-size: 9.5px; }
}

/* Larger phones / small tablets */
@media (min-width: 560px) {
  .page { padding: 20px 20px 36px; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chips { padding-left: 20px; padding-right: 20px; margin-left: -20px; margin-right: -20px; }
  .tabs { margin-left: -20px; margin-right: -20px; padding-left: 20px; padding-right: 20px; }
  .action-bar { margin-left: -20px; margin-right: -20px; padding-left: 20px; padding-right: 20px; }
  .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; }
  .kv-item:nth-last-child(2):nth-child(odd) { border-bottom: 0; }
}

/* Tablet */
@media (min-width: 760px) {
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat-val { font-size: 28px; }
  .detail-hero { padding: 20px; }
  .card-body { padding: 18px; }
}

/* Desktop: swap tab bar for permanent sidebar */
@media (min-width: 1000px) {
  :root { --tabbar-h: 0px; }

  .tabbar { display: none; }
  .scrim { display: none; }

  .sidebar {
    transform: none;
    box-shadow: none;
    width: var(--sidebar-w);
    max-width: none;
  }
  body.nav-open { overflow: auto; }

  .main { margin-left: var(--sidebar-w); padding-bottom: 0; }

  /* The topbar is a sticky sibling of .main, not a child of it, so it needs its
     own offset. Must be margin-left — `left` does nothing on position:sticky. */
  .topbar {
    margin-left: var(--sidebar-w);
    padding-left: 22px;
    padding-right: 22px;
    gap: 14px;
  }
  .topbar .menu-toggle,
  .topbar .logo-mark { display: none; }
  /* Sidebar is permanent at this width — nothing to close. */
  .sidebar .nav-close { display: none; }
  .topbar-title { flex: 0 0 auto; font-size: 16px; }
  .topbar .search { max-width: 400px; margin-left: 8px; }

  .page { padding: 24px 28px 48px; }
  .chips { padding-left: 28px; padding-right: 28px; margin-left: -28px; margin-right: -28px; }
  .tabs { margin-left: -28px; margin-right: -28px; padding-left: 28px; padding-right: 28px; }

  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid { gap: 16px; }
  .grid-2, .grid-3, .grid-4, .stack, .stats { gap: 16px; }

  .split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
  .split-wide { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; align-items: start; }
  .split-left { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }

  .action-bar {
    position: static;
    background: none;
    border: 0;
    backdrop-filter: none;
    padding: 0;
    margin: 16px 0 0;
    justify-content: flex-end;
  }
  .action-bar .btn { flex: 0 0 auto; }

  .toast { bottom: 24px; }

  .cal-day { aspect-ratio: auto; min-height: 96px; padding: 7px; }
  .cal-n { font-size: 13px; }

  .photo-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  .page-head .ph-title { font-size: 26px; }
  .detail-hero h1 { font-size: 24px; }
  .stat-val { font-size: 30px; }
}

@media (min-width: 1240px) {
  .split { grid-template-columns: minmax(0, 1fr) 380px; }
}

/* Show tables only on wider screens; card lists on mobile */
.only-wide { display: none; }
@media (min-width: 860px) {
  .only-wide { display: block; }
  .only-narrow { display: none !important; }
}

/* iOS: prevent input zoom */
@media (max-width: 999px) {
  .input, .select, .textarea { font-size: 16px; }
}

@media print {
  .sidebar, .tabbar, .topbar, .action-bar, .no-print { display: none !important; }
  .main { margin: 0; }
  body { background: #fff; }
  .doc { border: 0; box-shadow: none; }
}

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