
:root{
  --bg:#faf7f5; --surface:#ffffff; --surface-2:#f6f0ec; --line:#e9e0da; --line-strong:#d6c8bf;
  --text:#241e1c; --text-1:var(--text); --text-2:#6b5f58; --text-3:#9c8d84;
  --brand:#a23b5c; --brand-dark:#7e2d47; --brand-tint:#faedf1;
  --good:#4b7a5c; --good-tint:#eaf3ec;
  --warn:#b3792c; --warn-tint:#faf1e1;
  --bad:#b3453a; --bad-tint:#fbebe8;
  --info:#6a6bb0; --info-tint:#eeeef9;
  --radius:16px; --radius-sm:9px;
  --shadow:0 1px 2px rgba(60,40,30,.05), 0 3px 10px rgba(60,40,30,.045);
  --shadow-lg:0 14px 36px rgba(60,40,30,.16);
  --sidebar:236px;
  --mono:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,monospace;
  --font-sans:-apple-system,BlinkMacSystemFont,"Segoe UI",Inter,Roboto,Helvetica,Arial,sans-serif;
  /* Categorical chart palette — validated (CVD-safe) fixed hue order, kept
     distinct from the brand/status colors above so a series never impersonates
     a status. Do not reorder or hand-edit individual slots; see the data-viz
     palette reference this was validated against. */
  --cat-1:#2a78d6; --cat-2:#eb6834; --cat-3:#1baf7a; --cat-4:#eda100;
  --cat-5:#e87ba4; --cat-6:#008300; --cat-7:#4a3aa7; --cat-8:#e34948;
}
[data-theme="dark"]{
  --bg:#1a1513; --surface:#241d1b; --surface-2:#2c2320; --line:#3d322d; --line-strong:#54443d;
  --text:#f3ece8; --text-1:var(--text); --text-2:#bdaea6; --text-3:#8c7d75;
  --brand:#d16b8f; --brand-dark:#e89ab5; --brand-tint:#3a2530;
  --good:#7fc198; --good-tint:#1c2b21;
  --warn:#e0ac5c; --warn-tint:#2e2416;
  --bad:#e2897d; --bad-tint:#33211d;
  --info:#a5a5e6; --info-tint:#26253f;
  --shadow:0 1px 2px rgba(0,0,0,.45); --shadow-lg:0 16px 40px rgba(0,0,0,.55);
  --cat-1:#3987e5; --cat-2:#d95926; --cat-3:#199e70; --cat-4:#c98500;
  --cat-5:#d55181; --cat-6:#008300; --cat-7:#9085e9; --cat-8:#e66767;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  background:var(--bg); color:var(--text);
  font:14px/1.56 var(--font-sans);
  -webkit-font-smoothing:antialiased;
}
a{color:var(--brand); text-decoration:none; transition:color .15s ease}
a:hover{text-decoration:underline}
h1,h2,h3,h4{margin:0; font-weight:620; letter-spacing:-.015em}
h1{font-size:25px; font-weight:600; letter-spacing:-.025em}
h2{font-size:16px}
h3{font-size:14px}
hr{border:0;border-top:1px solid var(--line);margin:18px 0}
code,.mono{font-family:var(--mono);font-size:.92em}

.btn,.nav a,.chip,.badge,.tabs a,.userchip,.demo-users .du,summary{
  transition:background-color .15s ease,border-color .15s ease,color .15s ease,
    box-shadow .15s ease,opacity .15s ease,transform .15s ease}

/* ---------- app shell ---------- */
.app{display:flex;min-height:100vh}
.sidebar{
  width:var(--sidebar); flex:0 0 var(--sidebar); background:var(--surface);
  border-right:1px solid var(--line); display:flex; flex-direction:column;
  position:sticky; top:0; height:100vh; overflow-y:auto;
}
.brand{display:flex;align-items:center;gap:9px;padding:17px 16px 15px;border-bottom:1px solid var(--line)}
.brand-mark{
  width:28px;height:28px;border-radius:8px;background:linear-gradient(140deg,var(--brand),#5c2a44);
  display:grid;place-items:center;color:#fff;font-weight:800;font-size:14px;flex:0 0 28px
}
.brand-name{font-weight:660;font-size:15px;letter-spacing:-.02em}
.brand-sub{font-size:10.5px;color:var(--text-3);text-transform:uppercase;letter-spacing:.08em}
/* The entity profile switch, directly above the navigation. */
.entity-switch{padding:12px 12px 11px;border-bottom:1px solid var(--line);background:var(--surface-2,transparent)}
.entity-switch-label{font-size:10.5px;text-transform:uppercase;letter-spacing:.08em;color:var(--text-3);font-weight:640;margin-bottom:5px}
.entity-switch select{
  width:100%;padding:7px 8px;font-size:12.5px;font-weight:560;border-radius:8px;
  border:1px solid var(--line);background:var(--surface);color:var(--text-1);cursor:pointer
}
.entity-switch select:focus{outline:none;box-shadow:0 0 0 3px var(--brand-tint);border-color:var(--brand)}
.entity-switch-hint{font-size:10.5px;color:var(--text-3);margin-top:6px;line-height:1.35}
.nav{padding:10px 8px;flex:1}
.nav-group{margin-bottom:14px}
.nav-label{
  font-size:10.5px;text-transform:uppercase;letter-spacing:.08em;color:var(--text-3);
  padding:4px 8px 6px;font-weight:640;display:flex;align-items:center;justify-content:space-between;
  width:100%;background:none;border:0;cursor:pointer;font-family:inherit;border-radius:6px;
}
.nav-label:hover{color:var(--text-2)}
.nav-chevron{font-size:9px;opacity:.6;transition:transform .15s ease}
.nav-group.collapsed .nav-chevron{transform:rotate(-90deg)}
.nav-group.collapsed .nav-items{display:none}
.nav a{
  display:flex;align-items:center;gap:9px;padding:7px 10px;border-radius:10px;
  color:var(--text-2);font-weight:520;font-size:13.2px;margin-bottom:1px
}
.nav a:hover{background:var(--surface-2);color:var(--text);text-decoration:none}
.nav a.active{background:var(--brand-tint);color:var(--brand);font-weight:620}
.nav .ico{width:16px;text-align:center;font-size:13px;opacity:.9;flex:0 0 16px}
.nav .count{margin-left:auto;font-size:11px;background:var(--line);color:var(--text-2);
  padding:1px 6px;border-radius:9px;font-weight:640}
.nav a.active .count{background:var(--brand);color:#fff}
.sidebar-foot{padding:10px;border-top:1px solid var(--line)}
.userchip{display:flex;align-items:center;gap:9px;padding:6px;border-radius:10px}
.userchip:hover{background:var(--surface-2)}
.avatar{width:28px;height:28px;border-radius:50%;background:var(--brand-tint);color:var(--brand);
  display:grid;place-items:center;font-weight:700;font-size:11.5px;flex:0 0 28px}
.userchip .who{min-width:0}
.userchip .who b{display:block;font-size:12.5px;font-weight:620;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.userchip .who span{display:block;font-size:11px;color:var(--text-3);text-transform:capitalize}

.main{flex:1;min-width:0;display:flex;flex-direction:column}
.topbar{
  display:flex;align-items:center;gap:14px;padding:0 24px;height:58px;
  background:var(--surface);border-bottom:1px solid var(--line);position:sticky;top:0;z-index:20
}
.topbar .search{flex:1;max-width:420px;position:relative}
.topbar .search input{width:100%;padding:7px 11px 7px 30px;border:1px solid var(--line);
  border-radius:10px;background:var(--surface-2);color:var(--text);font-size:13px}
.topbar .search input:focus{outline:none;box-shadow:0 0 0 3px var(--brand-tint);border-color:var(--brand);background:var(--surface)}
.topbar .search::before{content:"⌕";position:absolute;left:10px;top:5px;color:var(--text-3);font-size:15px}
.topbar-actions{margin-left:auto;display:flex;align-items:center;gap:8px}
.content{padding:26px;flex:1;max-width:1500px;width:100%}

.page-head{display:flex;align-items:flex-start;gap:16px;margin-bottom:22px;flex-wrap:wrap}
.page-head .grow{flex:1;min-width:220px}
.page-head p.sub{margin:4px 0 0;color:var(--text-2);font-size:13px}
.page-actions{display:flex;gap:8px;flex-wrap:wrap}

/* ---------- buttons ---------- */
.btn{
  display:inline-flex;align-items:center;gap:6px;padding:7px 14px;border-radius:var(--radius-sm);
  border:1px solid var(--line-strong);background:var(--surface);color:var(--text);
  font-size:13px;font-weight:560;cursor:pointer;line-height:1.35;white-space:nowrap
}
.btn:hover{background:var(--surface-2);text-decoration:none;border-color:var(--text-3)}
.btn-primary{background:var(--brand);border-color:var(--brand);color:#fff}
.btn-primary:hover{background:var(--brand-dark);border-color:var(--brand-dark);color:#fff}
.btn-danger{background:var(--bad);border-color:var(--bad);color:#fff}
.btn-danger:hover{opacity:.9;color:#fff}
.btn-ghost{border-color:transparent;background:transparent;color:var(--text-2)}
.btn-ghost:hover{background:var(--surface-2)}
.btn-sm{padding:4px 10px;font-size:12px}
.btn[disabled]{opacity:.5;pointer-events:none}

/* ---------- cards ---------- */
.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);margin-bottom:18px}
.card-head{display:flex;align-items:center;gap:12px;padding:14px 18px;border-bottom:1px solid var(--line)}
.card-head h2{flex:1;font-size:14.5px}
.card-head .hint{font-size:12px;color:var(--text-3);font-weight:500}
.card-body{padding:18px}
.card-body.tight{padding:0}
.card-foot{padding:12px 18px;border-top:1px solid var(--line);background:var(--surface-2);
  border-radius:0 0 var(--radius) var(--radius);font-size:12.5px;color:var(--text-2)}

.grid{display:grid;gap:16px}
.g2{grid-template-columns:repeat(2,minmax(0,1fr))}
.g3{grid-template-columns:repeat(3,minmax(0,1fr))}
.g4{grid-template-columns:repeat(4,minmax(0,1fr))}
.g5{grid-template-columns:repeat(5,minmax(0,1fr))}
.g23{grid-template-columns:minmax(0,2fr) minmax(0,3fr)}
.g32{grid-template-columns:minmax(0,3fr) minmax(0,2fr)}
@media(max-width:1200px){.g5,.g4{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:980px){.g2,.g3,.g23,.g32{grid-template-columns:1fr}
  .sidebar{position:fixed;left:-260px;z-index:60;transition:left .2s}
  .sidebar.open{left:0;box-shadow:var(--shadow-lg)}
  .content{padding:14px}}

/* ---------- stat tiles ---------- */
.tile{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);
  padding:16px 18px;box-shadow:var(--shadow)}
.tile .label{font-size:11.5px;text-transform:uppercase;letter-spacing:.06em;color:var(--text-3);font-weight:640}
.tile .value{font-size:23px;font-weight:660;letter-spacing:-.02em;margin-top:5px;line-height:1.15}
.tile .meta{font-size:12px;color:var(--text-2);margin-top:4px;display:flex;align-items:center;gap:5px}
.tile.accent-good .value{color:var(--good)}
.tile.accent-bad .value{color:var(--bad)}
.tile.accent-warn .value{color:var(--warn)}
.tile.accent-brand .value{color:var(--brand)}
.delta{font-size:11.5px;font-weight:640;padding:1px 5px;border-radius:4px}
.delta.up{color:var(--good);background:var(--good-tint)}
.delta.down{color:var(--bad);background:var(--bad-tint)}

/* ---------- tables ---------- */
.table-wrap{overflow-x:auto}
table.tbl{width:100%;border-collapse:collapse;font-size:13px}
table.tbl th{
  text-align:left;font-weight:640;font-size:11.5px;text-transform:uppercase;letter-spacing:.05em;
  color:var(--text-3);padding:9px 14px;border-bottom:1px solid var(--line);background:var(--surface-2);
  white-space:nowrap;position:sticky;top:0
}
table.tbl td{padding:10px 14px;border-bottom:1px solid var(--line);vertical-align:middle}
table.tbl tbody tr:last-child td{border-bottom:0}
table.tbl tbody tr{transition:background-color .12s ease}
table.tbl tbody tr:hover{background:var(--surface-2)}
table.tbl td.num,table.tbl th.num{text-align:right;font-variant-numeric:tabular-nums;font-family:var(--mono);font-size:12.4px}
table.tbl td.strong{font-weight:620}
table.tbl tr.total td{font-weight:700;border-top:2px solid var(--line-strong);background:var(--surface-2)}
table.tbl tr.subtotal td{font-weight:640;background:var(--surface-2)}
/* Sortable column headings (see ui/sorttable.js). The marker has a fixed
   width so the heading does not jump sideways as the arrow appears. */
table.tbl th[data-sortable]{cursor:pointer;user-select:none}
table.tbl th[data-sortable]:hover{color:var(--text)}
table.tbl th[data-sortable]:focus-visible{outline:2px solid var(--brand);outline-offset:-2px}
table.tbl th .sort-mark{display:inline-block;min-width:1em;margin-left:4px;font-size:9px;color:var(--brand)}
@media print{ table.tbl th .sort-mark{display:none} }

/* A category heading that folds its own lines away (see ui/collapse.js). */
table.tbl tr.group-head:hover td{background:var(--surface-3,var(--surface-2));filter:brightness(1.04)}
table.tbl tr.group-head:focus-visible{outline:2px solid var(--brand);outline-offset:-2px}
table.tbl tr.section td{font-weight:680;font-size:12px;text-transform:uppercase;letter-spacing:.05em;color:var(--text-2);background:var(--surface-2)}
.t-sub{display:block;font-size:11.5px;color:var(--text-3);margin-top:1px}
.indent-1{padding-left:32px !important}
.indent-2{padding-left:52px !important}

/* ---------- expandable property groups (units list) ---------- */
.unit-group{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);
  margin-bottom:10px;overflow:hidden}
.unit-group>summary{list-style:none;cursor:pointer;user-select:none;
  display:flex;align-items:center;gap:12px;padding:14px 18px}
.unit-group>summary::-webkit-details-marker{display:none}
.unit-group>summary:hover{background:var(--surface-2)}
.unit-group .chev{display:inline-flex;flex:none;width:14px;justify-content:center;
  color:var(--text-3);font-size:11px;transition:transform .15s ease}
.unit-group[open]>summary .chev{transform:rotate(90deg)}
.unit-group .grp-stats{display:flex;gap:16px;align-items:center;font-size:12.5px;
  color:var(--text-2);white-space:nowrap}
.unit-group .grp-stats b{color:var(--text-1)}
.unit-group .table-wrap{border-top:1px solid var(--line)}

/* ---------- badges ---------- */
.badge{display:inline-flex;align-items:center;gap:4px;padding:2px 9px;border-radius:20px;
  font-size:11.5px;font-weight:640;line-height:1.6;white-space:nowrap}
.badge.neutral{background:var(--line);color:var(--text-2)}
.badge.good{background:var(--good-tint);color:var(--good)}
.badge.warn{background:var(--warn-tint);color:var(--warn)}
.badge.bad{background:var(--bad-tint);color:var(--bad)}
.badge.info{background:var(--info-tint);color:var(--info)}
.badge.brand{background:var(--brand-tint);color:var(--brand)}
.dot{width:7px;height:7px;border-radius:50%;background:currentColor;display:inline-block}

/* ---------- forms ---------- */
.field{margin-bottom:14px}
.field label,.lbl{display:block;font-size:12.5px;font-weight:620;margin-bottom:5px;color:var(--text-2)}
.field .help{font-size:11.5px;color:var(--text-3);margin-top:4px}
input[type=text],input[type=email],input[type=password],input[type=number],input[type=date],
input[type=tel],select,textarea{
  width:100%;padding:8px 11px;border:1px solid var(--line-strong);border-radius:var(--radius-sm);
  background:var(--surface);color:var(--text);font-size:13.5px;font-family:inherit;
  transition:border-color .15s ease,box-shadow .15s ease
}
input:focus,select:focus,textarea:focus{outline:none;box-shadow:0 0 0 3px var(--brand-tint);border-color:var(--brand)}
textarea{min-height:88px;resize:vertical}
select{appearance:none;background-image:linear-gradient(45deg,transparent 50%,var(--text-3) 50%),linear-gradient(135deg,var(--text-3) 50%,transparent 50%);
  background-position:calc(100% - 15px) 15px,calc(100% - 10px) 15px;background-size:5px 5px;background-repeat:no-repeat;padding-right:30px}
/* dd/mm/yyyy date entry (see ui/dateinput.js). The native <input type=date>
   stays in the DOM carrying the real ISO value — it is only moved out of
   sight, so what the form posts is unchanged whether or not the script ran.
   The calendar button opens the native picker through showPicker(). */
.dmy{position:relative;display:flex;align-items:center}
.dmy-native{position:absolute;opacity:0;pointer-events:none;height:0;width:0;padding:0;border:0;margin:0}
.dmy-input{padding-right:32px}
.dmy-cal{position:absolute;right:1px;top:1px;bottom:1px;width:29px;display:flex;align-items:center;
  justify-content:center;border:0;background:transparent;color:var(--text-3);cursor:pointer;
  font-size:14px;border-radius:0 var(--radius-sm) var(--radius-sm) 0}
.dmy-cal:hover{color:var(--brand);background:var(--brand-tint)}

/* Type-to-search dropdown (see ui/combo.js). The native <select> stays in the
   DOM carrying the real name and value — it is only moved out of sight, so
   what the form posts is unchanged whether or not the script ran. */
.combo{position:relative}
.combo-native{position:absolute;opacity:0;pointer-events:none;height:0;width:0;padding:0;border:0;margin:0}
.combo-input{background-image:linear-gradient(45deg,transparent 50%,var(--text-3) 50%),linear-gradient(135deg,var(--text-3) 50%,transparent 50%);
  background-position:calc(100% - 15px) 15px,calc(100% - 10px) 15px;background-size:5px 5px;background-repeat:no-repeat;padding-right:30px}
.combo-list{display:none;position:absolute;z-index:60;left:0;right:0;top:calc(100% + 3px);
  max-height:230px;overflow-y:auto;background:var(--surface);border:1px solid var(--line-strong);
  border-radius:var(--radius-sm);box-shadow:var(--shadow-lg)}
.combo-list.open{display:block}
.combo-opt{padding:7px 11px;font-size:13.5px;cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.combo-opt:hover,.combo-opt.active{background:var(--brand-tint);color:var(--brand)}
.combo-opt.blank{color:var(--text-3)}
.combo-group{padding:6px 11px 3px;font-size:10.5px;text-transform:uppercase;letter-spacing:.07em;
  color:var(--text-3);font-weight:640}
.combo-empty{padding:8px 11px;font-size:12.5px;color:var(--text-3)}
.form-row{display:grid;gap:14px;grid-template-columns:repeat(2,minmax(0,1fr))}
.form-row.c3{grid-template-columns:repeat(3,minmax(0,1fr))}
.form-row.c4{grid-template-columns:repeat(4,minmax(0,1fr))}
@media(max-width:760px){.form-row,.form-row.c3,.form-row.c4{grid-template-columns:1fr}}
.check{display:flex;align-items:center;gap:8px;font-size:13px}
.check input{width:auto}
input[type=file]{width:100%;padding:9px 11px;border:1px dashed var(--line-strong);border-radius:var(--radius-sm);
  background:var(--surface-2);color:var(--text);font-size:13px;cursor:pointer}
input[type=file]:hover{border-color:var(--brand)}
input[type=month]{width:100%;padding:8px 11px;border:1px solid var(--line-strong);
  border-radius:var(--radius-sm);background:var(--surface);color:var(--text);font-size:13.5px}
input[type=color]{width:100%;height:38px;padding:3px;border:1px solid var(--line-strong);
  border-radius:var(--radius-sm);background:var(--surface);cursor:pointer;transition:border-color .15s ease,box-shadow .15s ease}
input[type=color]:focus{outline:none;box-shadow:0 0 0 3px var(--brand-tint);border-color:var(--brand)}
input[type=color]::-webkit-color-swatch-wrapper{padding:0}
input[type=color]::-webkit-color-swatch{border:none;border-radius:6px}

/* photo gallery */
.gallery{display:grid;grid-template-columns:repeat(auto-fill,minmax(168px,1fr));gap:12px}
.shot{border:1px solid var(--line);border-radius:var(--radius);overflow:hidden;background:var(--surface)}
.shot img{width:100%;height:128px;object-fit:cover;display:block;background:var(--surface-2)}
.shot .meta{padding:8px 10px}
.shot .meta b{font-size:12.5px;display:block;line-height:1.3}
.shot .meta span{font-size:11px;color:var(--text-3)}
.inline-form{display:flex;gap:8px;align-items:flex-end;flex-wrap:wrap}
.inline-form .field{margin-bottom:0}
fieldset{border:1px solid var(--line);border-radius:var(--radius);padding:14px;margin:0 0 16px}
legend{font-size:12px;font-weight:680;text-transform:uppercase;letter-spacing:.05em;color:var(--text-2);padding:0 6px}

/* ---------- filters ---------- */
.filters{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin-bottom:14px}
.filters select,.filters input{width:auto;min-width:130px;padding:6px 10px;font-size:12.5px}
.chips{display:flex;gap:6px;flex-wrap:wrap}
.chip{padding:4px 12px;border-radius:20px;border:1px solid var(--line-strong);background:var(--surface);
  font-size:12.5px;font-weight:560;color:var(--text-2)}
.chip:hover{text-decoration:none;background:var(--surface-2)}
.chip.on{background:var(--brand);border-color:var(--brand);color:#fff}

/* ---------- misc ---------- */
.empty{text-align:center;padding:44px 20px;color:var(--text-3)}
.empty .big{font-size:30px;margin-bottom:8px;opacity:.5}
.empty h3{color:var(--text-2);margin-bottom:5px}
.flash{padding:11px 16px;border-radius:12px;margin-bottom:16px;font-size:13.5px;font-weight:540;
  border:1px solid transparent}
.flash.ok{background:var(--good-tint);color:var(--good);border-color:currentColor}
.flash.err{background:var(--bad-tint);color:var(--bad);border-color:currentColor}
.flash.info{background:var(--brand-tint);color:var(--brand);border-color:currentColor}
.flash.warn{background:var(--warn-tint);color:var(--warn);border-color:currentColor}
.bar{height:6px;border-radius:4px;background:var(--line);overflow:hidden}
.bar>i{display:block;height:100%;background:var(--brand);border-radius:4px}
.bar.good>i{background:var(--good)} .bar.warn>i{background:var(--warn)} .bar.bad>i{background:var(--bad)}
.kv{display:grid;grid-template-columns:auto 1fr;gap:8px 18px;font-size:13px}
.kv dt{color:var(--text-3);font-weight:560}
.kv dd{margin:0;font-weight:540}
.tabs{display:flex;gap:2px;border-bottom:1px solid var(--line);margin-bottom:18px;overflow-x:auto}
.tabs a{padding:9px 14px;font-size:13.2px;font-weight:580;color:var(--text-2);
  border-bottom:2px solid transparent;white-space:nowrap}
.tabs a:hover{color:var(--text);text-decoration:none}
.tabs a.on{color:var(--brand);border-bottom-color:var(--brand)}
.breadcrumb{font-size:12.5px;color:var(--text-3);margin-bottom:6px}
.breadcrumb a{color:var(--text-3)}
.muted{color:var(--text-3)}
.small{font-size:12px}
.right{text-align:right}
.nowrap{white-space:nowrap}
.pill-row{display:flex;gap:14px;flex-wrap:wrap;font-size:12.5px;color:var(--text-2)}
.stack{display:flex;flex-direction:column;gap:3px}
.row{display:flex;align-items:center;gap:10px}
.spacer{flex:1}
.hidden{display:none !important}
.thumb{width:38px;height:38px;border-radius:9px;display:grid;place-items:center;font-size:15px;flex:0 0 38px}
.timeline{list-style:none;margin:0;padding:0}
.timeline li{position:relative;padding:0 0 16px 20px;border-left:2px solid var(--line);margin-left:5px}
.timeline li:last-child{border-left-color:transparent;padding-bottom:0}
.timeline li::before{content:"";position:absolute;left:-6px;top:3px;width:10px;height:10px;
  border-radius:50%;background:var(--brand);border:2px solid var(--surface)}
.timeline .when{font-size:11.5px;color:var(--text-3)}

/* ---------- modal ---------- */
.modal{position:fixed;inset:0;background:rgba(30,20,16,.45);display:none;z-index:100;
  align-items:flex-start;justify-content:center;padding:40px 16px;overflow-y:auto}
.modal.open{display:flex}
.modal-box{background:var(--surface);border-radius:16px;box-shadow:var(--shadow-lg);
  width:100%;max-width:620px;border:1px solid var(--line)}
.modal-box.wide{max-width:860px}
.modal-head{display:flex;align-items:center;padding:16px 20px;border-bottom:1px solid var(--line)}
.modal-head h2{flex:1}
.modal-body{padding:20px}
.modal-foot{padding:14px 20px;border-top:1px solid var(--line);display:flex;gap:8px;justify-content:flex-end;
  background:var(--surface-2);border-radius:0 0 16px 16px}
.x{background:none;border:0;font-size:20px;color:var(--text-3);cursor:pointer;line-height:1;padding:0 4px}

/* ---------- charts ---------- */
.chart{width:100%}
.chart .grid-line{stroke:var(--line);stroke-width:1}
.chart .axis-text{fill:var(--text-3);font-size:10.5px}
.chart .bar-a{fill:var(--brand)}
.chart .bar-b{fill:var(--text-3);opacity:.45}
.legend{display:flex;gap:14px;font-size:12px;color:var(--text-2);margin-top:8px;flex-wrap:wrap}
.legend i{width:10px;height:10px;border-radius:3px;display:inline-block;margin-right:5px;vertical-align:-1px}

/* ---------- auth page ---------- */
.auth-wrap{min-height:100vh;display:grid;place-items:center;padding:24px;
  background:linear-gradient(150deg,var(--brand-tint),var(--bg) 55%)}
.auth-card{width:100%;max-width:410px;background:var(--surface);border:1px solid var(--line);
  border-radius:18px;box-shadow:var(--shadow-lg);padding:30px}
.auth-card .brand{border:0;padding:0 0 18px;justify-content:center}
.demo-users{margin-top:18px;border-top:1px solid var(--line);padding-top:14px}
.demo-users .du{display:flex;align-items:center;gap:10px;padding:7px 9px;border-radius:10px;
  font-size:12.5px;color:var(--text-2);width:100%;text-align:left;border:1px solid transparent;
  background:none;cursor:pointer;font-family:inherit}
.demo-users .du:hover{background:var(--surface-2);border-color:var(--line)}

/* ---------- property cards (Settings > Appearance) ------------------------
   Size and colour are per browser, stamped on <body> by layout.js. Only the
   properties grid is affected; every other g3 on the site keeps its layout.

   The small sizes use auto-fill rather than a fixed column count, so a wide
   monitor gets more cards rather than wider ones — which is the whole point
   of asking for smaller. Fixed counts were why "compact" still looked big:
   four columns of a 1440px window is a 340px card, which is not compact,
   it is Standard with an extra column. */
.prop-banner{height:76px;border-radius:9px 9px 0 0;display:flex;align-items:flex-end;padding:10px 14px}
.prop-banner.brand{background:linear-gradient(135deg,var(--brand),var(--brand-dark))}

@media(min-width:981px){
  /* Tiny: no picture strip at all. At this size the band is a stripe of
     colour taking room from the only thing being read — the name and what
     is owed — so it goes, and the type badge sits in the body instead. */
  body.props-xs .prop-grid{grid-template-columns:repeat(auto-fill,minmax(186px,1fr));gap:10px}
  body.props-xs .prop-banner{height:6px;padding:0;border-radius:9px 9px 0 0}
  body.props-xs .prop-banner .badge{display:none}
  body.props-xs .prop-grid .card-body{padding:10px 12px}
  body.props-xs .prop-grid h2{font-size:14px;line-height:1.3}
  body.props-xs .prop-grid .small,body.props-xs .prop-grid .muted{font-size:11px}
  body.props-xs .prop-grid .pill-row{margin-top:8px;font-size:11.5px}
  /* "Single rental" is the one line that pushes this row onto two and leaves
     a ragged grid. At this size the badge beside it already says Let or
     Vacant, which is the part being read. */
  body.props-xs .prop-grid .pill-row .muted{display:none}

  body.props-sm .prop-grid{grid-template-columns:repeat(auto-fill,minmax(248px,1fr));gap:12px}
  body.props-sm .prop-banner{height:38px;padding:6px 10px}
  body.props-sm .prop-banner .badge{font-size:10px;padding:1px 6px}
  body.props-sm .prop-grid .card-body{padding:12px 14px}
  body.props-sm .prop-grid h2{font-size:16px}
  body.props-sm .prop-grid .small,body.props-sm .prop-grid .muted{font-size:11.5px}

  body.props-lg .prop-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  body.props-lg .prop-banner{height:118px}
  body.props-lg .prop-grid h2{font-size:21px}
}

/* ==========================================================================
   Phone mode
   --------------------------------------------------------------------------
   Applied when the SERVER decided this is a phone (see src/ui/view.js) and
   put .phone on <body> — not on a width guess, because the mode changes what
   is in the HTML, not only how it is arranged. The width query further down
   is a separate, additive safety net for a narrow window on a desktop.
   ========================================================================== */
body.phone{-webkit-text-size-adjust:100%}
body.phone .sidebar{display:none}
body.phone .main{width:100%}
body.phone .content{padding:14px 14px 84px}   /* room for the tab bar */
body.phone .topbar{padding:0 12px;gap:8px;position:sticky;top:0;z-index:40}
body.phone .ph-brand{display:flex;align-items:center}
body.phone .ph-brand .brand-mark{width:30px;height:30px;font-size:15px}
body.phone .topbar .search{max-width:none}
body.phone h1{font-size:21px;line-height:1.25}
body.phone h2{font-size:16px}

/* Touch targets. 44px is the smallest a fingertip reliably hits. */
body.phone .btn{min-height:44px;padding:10px 14px;font-size:14px}
body.phone .btn-sm{min-height:38px}
body.phone input,body.phone select,body.phone textarea{
  min-height:44px;font-size:16px}   /* 16px stops iOS zooming the page on focus */
body.phone .page-actions{display:flex;flex-wrap:wrap;gap:8px;width:100%;margin-top:10px}
body.phone .page-actions .btn{flex:1 1 calc(50% - 4px);justify-content:center}
body.phone .page-head{flex-direction:column;align-items:stretch}
body.phone .filters{flex-direction:column;align-items:stretch}
body.phone .filters>*{width:100%}
/* Two-up for the small stat tiles, one-up for anything with real content in
   it. Stacking the tiles one per row pushed the actual list — the thing the
   page is for — two full screens down. */
body.phone .g4,body.phone .g5{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
body.phone .g2,body.phone .g3,body.phone .g23,body.phone .g32{grid-template-columns:1fr}
body.phone .tile{padding:11px 12px}
body.phone .tile .value{font-size:17px;line-height:1.25;word-break:break-word}
body.phone .tile .label{font-size:10.5px}
body.phone .tile .meta{font-size:11px}
body.phone .page-head .sub{font-size:12.5px}
body.phone .form-row,body.phone .form-row.c3,body.phone .form-row.c4{grid-template-columns:1fr}

/* Modals become full-height sheets — a centred box on a phone leaves the
   keyboard covering the field you are typing into. */
body.phone .modal{align-items:flex-end}
body.phone .modal-box{max-width:none;width:100%;max-height:92vh;border-radius:16px 16px 0 0;
  display:flex;flex-direction:column}
/* The box is capped at 92vh, so the BODY has to be the part that scrolls —
   otherwise the sheet runs off the bottom of the screen taking its buttons
   with it, which is how a menu ends up with no way to sign out. */
body.phone .modal-head,body.phone .modal-foot{flex:0 0 auto}
body.phone .modal-body{flex:1 1 auto;min-height:0;overflow-y:auto;-webkit-overflow-scrolling:touch}
body.phone .modal-head{justify-content:space-between;align-items:center}

/* --- tables become cards -------------------------------------------------
   A nine-column rent roll on a 390px screen is a horizontal scrollbar nobody
   finds. Each row becomes a card; each cell carries its own heading from the
   data-label the table component writes. */
body.phone .tbl thead{display:none}
body.phone .tbl,body.phone .tbl tbody,body.phone .tbl tr,body.phone .tbl td{display:block;width:auto}
body.phone .table-wrap{overflow:visible}
body.phone .tbl tr{background:var(--surface);border:1px solid var(--line);border-radius:12px;
  padding:10px 12px;margin-bottom:10px}
body.phone .tbl td{border:0;padding:5px 0;display:flex;justify-content:space-between;
  align-items:baseline;gap:14px;text-align:right}
body.phone .tbl td::before{content:attr(data-label);color:var(--text-3);font-size:11.5px;
  text-transform:uppercase;letter-spacing:.04em;text-align:left;flex:0 0 auto}
body.phone .tbl td:empty{display:none}
body.phone .tbl td[data-label=""]::before{display:none}
body.phone .tbl td .t-sub{display:block}
body.phone .tbl tr.total{background:var(--surface-2)}

/* --- bottom tab bar ------------------------------------------------------ */
.ph-tabs{position:fixed;left:0;right:0;bottom:0;z-index:50;display:flex;
  background:var(--surface);border-top:1px solid var(--line);
  padding-bottom:env(safe-area-inset-bottom)}
.ph-tabs a,.ph-tabs button{flex:1;display:flex;flex-direction:column;align-items:center;gap:2px;
  padding:8px 2px 7px;font-size:10.5px;color:var(--text-3);background:none;border:0;
  font-family:inherit;cursor:pointer;min-height:52px;justify-content:center}
.ph-tabs a.on{color:var(--brand)}
.ph-tab-ico{font-size:18px;line-height:1}

/* --- the More sheet ------------------------------------------------------ */
.ph-sheet .modal-box{padding-bottom:0}
.ph-sheet .nav{padding:0}
.ph-sheet .search,.ph-sheet .search input{width:100%;max-width:none;display:block}
.ph-sheet .ph-foot{display:flex;gap:8px}
.ph-nav .nav-items a{min-height:44px}

/* --- phone home ---------------------------------------------------------- */
.ph-greet{margin-bottom:14px}
.ph-greet h1{margin:0}
.ph-stats{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-bottom:16px}
.ph-stat{background:var(--surface);border:1px solid var(--line);border-radius:12px;
  padding:10px 8px;text-align:center}
.ph-stat b{display:block;font-size:15px;line-height:1.3}
.ph-stat span{display:block;font-size:10.5px;color:var(--text-3);margin-top:2px}
.ph-stat.warn b{color:var(--warn,#b8791f)}
.ph-stat.good b{color:var(--good)}
.ph-actions{display:flex;flex-direction:column;gap:8px;margin-bottom:20px}
.ph-action{display:flex;align-items:center;gap:12px;background:var(--surface);
  border:1px solid var(--line);border-radius:14px;padding:14px;color:var(--text);min-height:64px}
.ph-action:active{background:var(--surface-2)}
.ph-ico{width:40px;height:40px;flex:0 0 40px;display:grid;place-items:center;font-size:18px;
  background:var(--brand-tint);color:var(--brand);border-radius:11px}
.ph-act-text{flex:1;min-width:0}
.ph-act-text b{display:block;font-size:15px}
.ph-act-text span{display:block;font-size:12px;color:var(--text-3);margin-top:1px}
.ph-chev{color:var(--text-3);font-size:20px;line-height:1}
.ph-section{margin-bottom:20px}
.ph-head{display:flex;justify-content:space-between;align-items:baseline;margin-bottom:8px}
.ph-head h2{margin:0}
.ph-head a{font-size:12.5px}
.ph-row{display:flex;align-items:center;gap:10px;background:var(--surface);
  border:1px solid var(--line);border-radius:12px;padding:12px;margin-bottom:8px;
  color:var(--text);min-height:58px}
.ph-row-main{flex:1;min-width:0}
.ph-row-main b{display:block;font-size:14px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ph-row-main span{display:block;font-size:11.5px;color:var(--text-3);margin-top:2px}

/* --- login: choosing your interface -------------------------------------- */
.view-pick{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-bottom:16px}
.view-pick label{display:flex;flex-direction:column;align-items:center;gap:4px;padding:11px 8px;
  border:1px solid var(--line);border-radius:12px;cursor:pointer;font-size:12.5px;
  color:var(--text-2);background:var(--surface)}
.view-pick input{position:absolute;opacity:0;pointer-events:none}
.view-pick label .vp-ico{font-size:19px;line-height:1}
.view-pick input:checked+span{color:var(--brand)}
.view-pick label:has(input:checked){border-color:var(--brand);background:var(--brand-tint);color:var(--brand)}

/* A narrow desktop window gets the card-table treatment too — separate from
   phone MODE, which is about what the server rendered. */
@media(max-width:640px){
  .tbl thead{display:none}
  .tbl,.tbl tbody,.tbl tr,.tbl td{display:block;width:auto}
  .table-wrap{overflow:visible}
  .tbl tr{background:var(--surface);border:1px solid var(--line);border-radius:12px;
    padding:10px 12px;margin-bottom:10px}
  .tbl td{border:0;padding:5px 0;display:flex;justify-content:space-between;gap:14px;text-align:right}
  .tbl td::before{content:attr(data-label);color:var(--text-3);font-size:11.5px;
    text-transform:uppercase;letter-spacing:.04em;text-align:left}
  .tbl td:empty{display:none}
}

/* ---------- print ---------- */
@media print{
  .sidebar,.topbar,.page-actions,.filters,.btn,.ph-tabs,.ph-sheet{display:none !important}
  .content{padding:0} body{background:#fff}
  .card{box-shadow:none;border-color:#ccc;break-inside:avoid}
  /* A folded category prints open regardless. collapse.js already unfolds
     on beforeprint; this covers the browsers that never fire it. A printed
     "Total repairs" with no repairs under it cannot be checked. */
  tr.group-row[hidden]{display:table-row !important}
  tr.group-head [data-group-caret]{display:none !important}
}
