:root {
  --ink: #002532;
  --teal: #004254;
  --sand: #AAAA9F;
  --paper: #E3E2DA;
  --line: #C8C7BD;
  --track: #D7D6CD;
  --muted: #646459;
  --green: #1F8A50;
  --green-soft: #8FE0AC;
  --sky: #7FC9DF;
  --ch:  polygon(0 0, calc(100% - 13px) 0, 100% 13px, 100% 100%, 13px 100%, 0 calc(100% - 13px));
  --chs: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
  --chL: polygon(0 0, calc(100% - 22px) 0, 100% 22px, 100% 100%, 22px 100%, 0 calc(100% - 22px));
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--paper);
  font-family: 'Hanken Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  padding: 34px 30px 70px;
}
::selection { background: var(--sand); color: var(--ink); }
*::-webkit-scrollbar { height: 9px; width: 9px; }
*::-webkit-scrollbar-thumb { background: var(--sand); border-radius: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal); outline-offset: 0; }
button { font-family: inherit; }

.wrap { max-width: 1240px; margin: 0 auto; }

/* --- Masthead ------------------------------------------------------------- */
.masthead {
  position: relative; background: var(--ink); color: #fff;
  padding: 32px 36px 34px; clip-path: var(--chL); margin-bottom: 22px;
}
.visor { position: absolute; }
.masthead-top { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; padding-left: 6px; }
.masthead-top img { height: 40px; width: auto; display: block; }
.masthead-sep { width: 1px; height: 26px; background: #3A5763; }
.masthead-kicker { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: #7FA0AD; font-weight: 600; }
.masthead-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; padding-left: 6px; }
.masthead h1 { font-weight: 800; font-size: clamp(30px, 4.4vw, 48px); line-height: 1.02; letter-spacing: -0.02em; }
.masthead p { margin: 14px 0 0; max-width: 560px; font-size: 15px; line-height: 1.5; color: var(--sand); }
.masthead-meta { text-align: right; font-size: 12px; color: #7FA0AD; line-height: 1.7; }
.masthead-meta .ver { color: #fff; font-weight: 700; letter-spacing: 0.04em; }
.masthead-meta .lbl { text-transform: uppercase; letter-spacing: 0.12em; font-size: 10.5px; margin-top: 2px; }
.masthead-meta .stamp { color: var(--sky); font-weight: 600; }

/* --- Manage bar ----------------------------------------------------------- */
.manage-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap;
  background: #fff; clip-path: var(--ch); padding: 11px 16px; margin-bottom: 28px;
  filter: drop-shadow(0 1px 3px rgba(0,37,50,0.10));
}
.manage-left, .manage-right { display: flex; align-items: center; gap: 8px; }
.manage-left { gap: 12px; }
.btn {
  border: 1px solid var(--line); background: #fff; clip-path: var(--chs);
  padding: 8px 14px; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--muted);
}
.btn:hover { border-color: var(--ink); }
.btn-manage {
  border: none; clip-path: var(--chs); padding: 9px 17px; font-size: 13px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; gap: 8px; background: #fff; color: var(--ink);
}
.btn-manage.on { background: var(--ink); color: #fff; }
.btn-manage .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sand); }
.btn-manage.on .dot { background: #3FD07A; }
.btn-new { border: 1px solid var(--line); background: #fff; clip-path: var(--chs); padding: 9px 15px; font-size: 13px; font-weight: 700; cursor: pointer; color: var(--ink); }
.btn-new:hover { border-color: var(--ink); }
.storage-note { font-size: 11px; color: var(--sand); margin-right: 4px; letter-spacing: 0.04em; }
.btn-excel { border-color: var(--green); color: var(--green); font-weight: 700; }
.btn-excel:hover { background: var(--green); color: #fff; border-color: var(--green); }

/* --- KPI strip ------------------------------------------------------------ */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 34px; }
.kpi {
  background: var(--ink); clip-path: var(--ch); padding: 20px 18px 18px;
  display: flex; flex-direction: column; gap: 7px; min-height: 132px;
  filter: drop-shadow(0 2px 5px rgba(0,37,50,0.18));
}
.kpi-value { font-weight: 800; font-size: 34px; line-height: 1; letter-spacing: -0.02em; color: #fff; }
.kpi-label { font-size: 13px; font-weight: 700; line-height: 1.25; color: #fff; }
.kpi-sub { font-size: 11.5px; color: var(--sand); line-height: 1.35; margin-top: auto; }

/* --- Breakdown ------------------------------------------------------------ */
.breakdown { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; margin-bottom: 18px; }
.panel { background: #fff; clip-path: var(--ch); padding: 21px 23px 23px; filter: drop-shadow(0 1px 3px rgba(0,37,50,0.10)); }
.panel-title { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 16px; }
.status-bar { display: flex; height: 16px; overflow: hidden; margin-bottom: 18px; clip-path: var(--chs); }
.status-bar > div { height: 100%; }
.status-list { display: flex; flex-direction: column; gap: 2px; }
.status-row {
  display: flex; align-items: center; gap: 11px; padding: 8px; border: none; background: transparent;
  cursor: pointer; text-align: left; width: 100%;
}
.status-row:hover { background: #F4F3EE; }
.status-row.active { /* bg set inline from status colour */ }
.status-swatch { width: 11px; height: 11px; flex: none; }
.status-row .name { font-size: 13.5px; font-weight: 600; flex: 1; color: var(--ink); }
.status-row .num { font-size: 13px; font-weight: 700; color: var(--muted); }
.unit-list { display: flex; flex-direction: column; gap: 11px; }
.unit-row { display: flex; align-items: center; gap: 12px; }
.unit-row .name { width: 64px; font-size: 13px; font-weight: 600; flex: none; }
.bar-track { flex: 1; height: 9px; background: var(--track); overflow: hidden; }
.bar-fill { height: 100%; background: var(--teal); }
.unit-row .num { font-size: 12.5px; font-weight: 700; color: var(--muted); width: 20px; text-align: right; flex: none; }

/* --- Tools ---------------------------------------------------------------- */
.tools-section { background: #fff; clip-path: var(--ch); padding: 21px 23px 23px; margin-bottom: 36px; filter: drop-shadow(0 1px 3px rgba(0,37,50,0.10)); }
.tools-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; }
.tools-head .hint { font-size: 11.5px; color: var(--sand); }
.tools-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 26px; }
.tool { display: flex; flex-direction: column; gap: 6px; }
.tool-top { display: flex; justify-content: space-between; align-items: baseline; }
.tool-top .name { font-size: 13px; font-weight: 600; }
.tool-top .num { font-size: 13px; font-weight: 700; color: var(--ink); }
.tool-track { height: 7px; background: var(--track); overflow: hidden; }
.tool-fill { height: 100%; background: var(--ink); }

/* --- Explorer controls ---------------------------------------------------- */
.explorer { display: flex; justify-content: space-between; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 18px; }
.explorer-left { display: flex; align-items: baseline; gap: 14px; }
.explorer h2 { font-weight: 800; font-size: 22px; letter-spacing: -0.01em; }
.explorer .count { font-size: 13px; font-weight: 600; color: var(--sand); }
.chip-clear { border: 1px solid var(--line); background: #fff; clip-path: var(--chs); padding: 5px 13px; font-size: 12px; cursor: pointer; color: var(--muted); font-weight: 600; }
.explorer-right { display: flex; gap: 12px; align-items: center; }
.search { border: 1px solid var(--line); background: #fff; padding: 9px 13px; font-size: 13px; font-family: inherit; width: 230px; color: var(--ink); clip-path: var(--chs); }
.tabs { display: flex; border: 1px solid var(--line); overflow: hidden; clip-path: var(--chs); }
.tab { border: none; padding: 9px 15px; font-size: 12.5px; font-weight: 700; cursor: pointer; background: #fff; color: var(--muted); }
.tab:hover { color: var(--ink); }
.tab.on { background: var(--ink); color: #fff; }
.ctl { display: flex; align-items: center; gap: 7px; }
.ctl-label { font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--sand); font-weight: 700; }

/* --- Groups & cards ------------------------------------------------------- */
.groups { display: flex; flex-direction: column; gap: 30px; }
.group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.group-swatch { width: 12px; height: 12px; flex: none; }
.group-head h3 { font-weight: 700; font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; }
.group-head .num { font-size: 12.5px; font-weight: 700; color: var(--sand); }
.group-rule { flex: 1; height: 1px; background: var(--line); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; }

.card {
  position: relative; background: #fff; border-left: 4px solid var(--sand); clip-path: var(--ch);
  padding: 16px 18px 15px; display: flex; flex-direction: column; gap: 11px;
  filter: drop-shadow(0 1px 3px rgba(0,37,50,0.10)); cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.card:hover { transform: translateY(-2px); filter: drop-shadow(0 6px 14px rgba(0,37,50,0.18)); }
.card-actions { position: absolute; top: 12px; right: 18px; display: flex; gap: 6px; }
.icon-btn { border: 1px solid var(--line); background: #fff; width: 28px; height: 28px; cursor: pointer; font-size: 13px; line-height: 1; color: var(--ink); }
.icon-btn.del { border-color: #E1C3BB; color: #B4452E; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-title { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; line-height: 1.15; color: var(--ink); }
.unit-badge { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700; padding: 3px 8px; background: var(--paper); color: var(--muted); flex: none; white-space: nowrap; }
.card-obj { font-size: 13.5px; font-weight: 500; line-height: 1.35; color: #3A4A50; }
.card-owner { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.avatar { width: 22px; height: 22px; border-radius: 50%; background: var(--teal); color: #fff; font-size: 9px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }
.card-owner .who { font-weight: 700; color: var(--ink); }
.card-owner .dot { color: var(--line); }
.card-owner .when { font-size: 11.5px; font-weight: 500; }
.card-owner .val { margin-left: auto; font-size: 11.5px; font-weight: 700; color: var(--green); }
.card-meta { border-top: 1px solid var(--paper); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.meta-row { display: flex; gap: 8px; }
.meta-key { font-size: 9.5px; letter-spacing: 0.08em; color: var(--sand); flex: none; width: 54px; padding-top: 2px; font-weight: 700; }
.meta-val { font-size: 12px; line-height: 1.4; color: var(--muted); }
.meta-val.strong { color: var(--ink); font-weight: 600; }
.card-tools { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 1px; }
.tool-tag { font-size: 10.5px; padding: 2px 8px; border: 1px solid var(--track); color: var(--muted); background: #fff; }

/* --- List views: thick rows & compact rows -------------------------------- */
.list { display: flex; flex-direction: column; }
.list.rows { gap: 12px; }
.list.compact {
  gap: 0; background: #fff; clip-path: var(--ch);
  filter: drop-shadow(0 1px 3px rgba(0,37,50,0.10)); overflow: hidden;
}

/* Thick rows */
.lrow {
  position: relative; background: #fff; border-left: 4px solid var(--sand); clip-path: var(--ch);
  padding: 15px 20px; display: grid; grid-template-columns: 1.35fr 1fr; gap: 8px 26px;
  filter: drop-shadow(0 1px 3px rgba(0,37,50,0.10)); cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.lrow:hover { transform: translateY(-1px); filter: drop-shadow(0 5px 12px rgba(0,37,50,0.16)); }
.lrow-main { display: flex; flex-direction: column; gap: 9px; min-width: 0; }
.lrow-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.lrow-client { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; color: var(--ink); }
.lrow-spacer { flex: 1; }
.lrow-val { font-size: 12px; font-weight: 700; color: var(--green); white-space: nowrap; }
.row-actions { display: flex; gap: 6px; }
.lrow-obj { font-size: 13.5px; font-weight: 500; line-height: 1.35; color: #3A4A50; }
.lrow-owner { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.lrow-owner .who { font-weight: 700; color: var(--ink); }
.lrow-owner .dot { color: var(--line); }
.lrow-owner .when { font-size: 11.5px; font-weight: 500; }
.lrow-meta { display: flex; flex-direction: column; gap: 7px; border-left: 1px solid var(--paper); padding-left: 22px; }

/* Compact rows */
.crow {
  display: flex; align-items: center; gap: 12px; padding: 9px 16px 9px 13px;
  border-left: 3px solid var(--sand); border-bottom: 1px solid var(--paper);
  cursor: pointer; font-size: 13px;
}
.crow:last-child { border-bottom: none; }
.crow:hover { background: #F4F3EE; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.crow-client { font-weight: 700; color: var(--ink); width: 150px; flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crow .unit-badge { flex: none; }
.crow-obj { flex: 1; min-width: 0; color: #3A4A50; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crow-owner { width: 130px; flex: none; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crow-status { width: 140px; flex: none; font-weight: 600; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crow-when { width: 112px; flex: none; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crow-val { width: 84px; flex: none; text-align: right; font-weight: 700; color: var(--green); font-size: 12px; white-space: nowrap; }
.crow-actions { display: flex; gap: 5px; flex: none; }
.icon-btn.sm { width: 24px; height: 24px; font-size: 12px; }

/* --- Roadmap -------------------------------------------------------------- */
.roadmap-section { margin-top: 46px; border-top: 1px solid var(--sand); padding-top: 28px; }
.roadmap-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; }
.roadmap-head h2 { font-weight: 800; font-size: 22px; letter-spacing: -0.01em; }
.roadmap-head .hint { font-size: 13px; font-weight: 600; color: var(--sand); }
.roadmap-head-spacer { flex: 1; }
.roadmap-lead { margin: 0 0 22px; font-size: 14px; color: var(--muted); max-width: 600px; }
.roadmap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.rcard {
  position: relative; background: #fff; clip-path: var(--chs); padding: 16px 17px;
  display: flex; flex-direction: column; gap: 12px; filter: drop-shadow(0 1px 3px rgba(0,37,50,0.08));
  cursor: pointer; transition: transform 0.12s ease, filter 0.12s ease;
}
.rcard:hover { transform: translateY(-2px); filter: drop-shadow(0 6px 14px rgba(0,37,50,0.16)); }
.rcard.dim { opacity: 0.82; }
.rcard.dim:hover { opacity: 1; }
.rcard-top { display: flex; justify-content: flex-start; align-items: center; gap: 8px; }
.rcard-spacer { flex: 1; }
.rcard-actions { display: flex; gap: 6px; }
.rcard-num { font-weight: 800; font-size: 13px; color: var(--teal); }
.rcrow-num { font-weight: 800; font-size: 12px; color: var(--teal); width: 26px; flex: none; }
.rcard-tag { font-size: 9.5px; letter-spacing: 0.07em; text-transform: uppercase; font-weight: 700; padding: 3px 8px; white-space: nowrap; }
.rcard-desc { font-size: 14px; font-weight: 600; line-height: 1.35; color: var(--ink); }
.rcard-meta { border-top: 1px solid var(--paper); padding-top: 10px; font-size: 12px; color: var(--muted); line-height: 1.6; }
.rcard-meta .k { color: var(--sand); }
.rcard-meta .v { font-weight: 700; color: var(--ink); }

footer { margin-top: 48px; font-size: 11px; color: var(--sand); text-align: center; letter-spacing: 0.04em; }

/* --- Modals --------------------------------------------------------------- */
.overlay {
  position: fixed; inset: 0; background: rgba(0,37,50,0.62);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 20px; z-index: 50; overflow-y: auto;
}
.modal { background: #fff; clip-path: var(--ch); width: 100%; max-width: 580px; padding: 26px 28px 24px; filter: drop-shadow(0 20px 50px rgba(0,0,0,0.35)); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-head h3 { font-weight: 800; font-size: 20px; }
.modal-close { border: none; background: transparent; font-size: 22px; cursor: pointer; color: var(--sand); line-height: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.field.full { grid-column: 1 / -1; }
.field input, .field select { border: 1px solid var(--line); padding: 9px 11px; font-size: 14px; font-family: inherit; color: var(--ink); text-transform: none; letter-spacing: 0; font-weight: 400; background: #fff; }
.field .note { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--sand); }
.form-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 22px; }
.form-actions .right { display: flex; gap: 10px; margin-left: auto; }
.btn-danger { border: 1px solid #E1C3BB; background: #fff; color: #B4452E; clip-path: var(--chs); padding: 9px 16px; font-size: 13px; font-weight: 700; cursor: pointer; }
.btn-ghost { border: 1px solid var(--line); background: #fff; clip-path: var(--chs); padding: 9px 18px; font-size: 13px; font-weight: 700; cursor: pointer; color: var(--muted); }
.btn-primary { border: none; background: var(--ink); color: #fff; clip-path: var(--chs); padding: 9px 22px; font-size: 13px; font-weight: 700; cursor: pointer; }

/* --- Detail modal --------------------------------------------------------- */
.detail { max-width: 620px; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 4px; }
.detail-title-wrap { display: flex; flex-direction: column; gap: 8px; }
.detail-badges { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.detail h3 { font-weight: 800; font-size: 24px; letter-spacing: -0.01em; line-height: 1.1; }
.status-pill { font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700; padding: 4px 10px; white-space: nowrap; }
.detail-owner { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); margin: 16px 0 4px; }
.detail-owner .who { font-weight: 700; color: var(--ink); }
.detail-owner .val { margin-left: auto; font-size: 13px; font-weight: 800; color: var(--green); }
.detail-rows { display: flex; flex-direction: column; }
.detail-row { border-top: 1px solid var(--paper); padding: 13px 0; display: flex; gap: 16px; }
.detail-row:first-child { border-top: none; }
.detail-key { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--sand); font-weight: 700; flex: none; width: 96px; padding-top: 2px; }
.detail-val { font-size: 14px; line-height: 1.5; color: var(--ink); flex: 1; }
.detail-val.muted { color: var(--muted); }
.detail-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.detail-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; gap: 12px; }
.detail-footer .updated { font-size: 11px; color: var(--sand); }

.login-modal { max-width: 380px; }
.login-modal p { font-size: 13px; color: var(--muted); margin: 0 0 14px; line-height: 1.5; }
.login-modal input { width: 100%; border: 1px solid var(--line); padding: 10px 12px; font-size: 14px; font-family: inherit; color: var(--ink); margin-bottom: 6px; }
.login-error { color: #B4452E; font-size: 12.5px; min-height: 16px; margin-bottom: 8px; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 20px; font-size: 13px; font-weight: 600;
  clip-path: var(--chs); z-index: 100; filter: drop-shadow(0 6px 16px rgba(0,0,0,0.3));
}

.hidden { display: none !important; }

/* --- Access gate ---------------------------------------------------------- */
.gate { min-height: 78vh; display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.gate-card {
  position: relative; background: var(--ink); color: #fff; clip-path: var(--chL);
  width: 100%; max-width: 420px; padding: 40px 38px 34px;
  filter: drop-shadow(0 20px 50px rgba(0,37,50,0.35));
}
.gate-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.gate-brand img { height: 30px; width: auto; display: block; }
.gate-kicker { font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase; color: #7FA0AD; font-weight: 600; }
.gate-title { font-weight: 800; font-size: 26px; letter-spacing: -0.02em; line-height: 1.05; }
.gate-sub { margin: 10px 0 22px; font-size: 13.5px; line-height: 1.5; color: var(--sand); }
.gate-input {
  width: 100%; border: 1px solid #3A5763; background: #013443; color: #fff;
  padding: 12px 14px; font-size: 15px; font-family: inherit; clip-path: var(--chs);
}
.gate-input::placeholder { color: #6f909c; }
.gate-input:focus { outline: 2px solid var(--sky); outline-offset: 0; }
.gate-error { color: #FF9E8C; font-size: 12.5px; min-height: 18px; margin: 8px 2px 0; }
.gate-btn {
  width: 100%; margin-top: 10px; border: none; background: var(--sky); color: var(--ink);
  clip-path: var(--chs); padding: 12px 18px; font-size: 14px; font-weight: 800; cursor: pointer;
  font-family: inherit; letter-spacing: 0.02em;
}
.gate-btn:hover { background: #9ad6e8; }

/* --- Responsive ------------------------------------------------------------ */
@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .breakdown { grid-template-columns: 1fr; }
  .tools-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .lrow { grid-template-columns: 1fr; gap: 9px; }
  .lrow-meta { border-left: none; border-top: 1px solid var(--paper); padding-left: 0; padding-top: 11px; }
  .crow-obj, .crow-owner { display: none; }
}

/* Toolbar stacking — search + GROUP/VIEW controls become full-width rows */
@media (max-width: 700px) {
  .explorer { flex-direction: column; align-items: stretch; gap: 10px; }
  .explorer-left { flex-wrap: wrap; row-gap: 6px; }
  .explorer-right { flex-direction: column; align-items: stretch; gap: 8px; }
  .search { width: 100%; }
  .ctl { width: 100%; }
  .ctl-label { width: 42px; flex: none; }
  .ctl .tabs { flex: 1; }
  .ctl .tab { flex: 1; padding: 10px 4px; text-align: center; }

  .manage-bar { flex-direction: column; align-items: stretch; gap: 10px; }
  .manage-left, .manage-right { flex-wrap: wrap; row-gap: 8px; }
  .storage-note { width: 100%; margin: 0 0 2px; }

  .roadmap-head .ctl { width: 100%; }
  .tools-grid { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
}

/* Phones */
@media (max-width: 620px) {
  body { padding: 14px 12px 44px; }

  .masthead { padding: 24px 18px 26px; }
  .masthead-top { margin-bottom: 18px; }
  .masthead-row { flex-direction: column; align-items: flex-start; gap: 14px; }
  .masthead-meta { text-align: left; line-height: 1.55; }
  .masthead p { font-size: 14px; }

  .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 24px; }
  .kpi { min-height: 104px; padding: 15px 13px 13px; }
  .kpi-value { font-size: 25px; }
  .kpi-label { font-size: 12px; }

  .panel { padding: 17px 16px 18px; }
  .tools-section { padding: 17px 16px 18px; margin-bottom: 26px; }
  .groups { gap: 24px; }
  .card { padding: 14px 14px 13px; }
  .lrow { padding: 13px 14px; }

  /* Compact rows on a phone: dot · client · unit · status · actions */
  .crow { gap: 9px; padding: 10px 12px 10px 11px; }
  .crow-client { width: auto; flex: 1; min-width: 0; }
  .crow-status { width: auto; flex: none; }
  .crow-when, .crow-val { display: none; }

  /* Touch targets */
  .icon-btn { width: 32px; height: 32px; }
  .icon-btn.sm { width: 30px; height: 30px; }

  /* Modals */
  .overlay { padding: 14px 10px; }
  .modal { padding: 20px 16px 18px; }
  .detail h3 { font-size: 20px; }
  .detail-key { width: 78px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-actions { flex-wrap: wrap; gap: 10px; }

  .roadmap-grid { grid-template-columns: 1fr; }
  .gate-card { padding: 30px 24px 26px; }
  .gate-title { font-size: 23px; }

  footer { margin-top: 34px; }
}

/* Very narrow phones */
@media (max-width: 380px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi-value { font-size: 22px; }
  .explorer-left h2 { font-size: 19px; }
  .unit-row .name { width: 56px; font-size: 12px; }
  .masthead-top { flex-wrap: wrap; row-gap: 8px; }
  .masthead-kicker { font-size: 10px; letter-spacing: 0.12em; min-width: 0; }
}
