/* Louisa — property management UI
   Clean, calm, professional: soft blue-grey canvas, white cards, blue/green/teal actions. */

:root {
  --canvas: #e6ecf3;
  --bg: #f4f6fa;
  --card: #ffffff;
  --line: #e2e7ef;
  --line-2: #edf0f5;
  --ink: #101828;
  --text: #2a3445;
  --muted: #667085;
  --subtle: #98a2b3;

  --primary: #1f5fae;
  --primary-600: #194f92;
  --primary-700: #143f75;
  --primary-50: #e9f1fb;
  --primary-100: #d6e5f8;

  --green: #1f8a4c;
  --green-600: #19733f;
  --green-50: #e4f5ea;
  --green-100: #cdebd8;
  --teal: #1d8796;
  --teal-600: #16707d;
  --teal-50: #e1f3f6;
  --red: #d63c3c;
  --red-600: #b92f2f;
  --red-50: #fdecec;
  --amber: #b26b00;
  --amber-50: #fff4dc;
  --purple: #6a4fbf;
  --purple-50: #f0ecfb;

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --sh-1: 0 1px 2px rgba(16, 24, 40, .05);
  --sh-2: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --sh-3: 0 12px 32px -8px rgba(16, 24, 40, .18), 0 4px 10px -4px rgba(16, 24, 40, .08);
  --side-w: 236px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--text);
  background: var(--canvas); -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01";
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-600); }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { color: var(--ink); margin: 0; letter-spacing: -.01em; }
p { margin: 0 0 .7em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
small { font-size: 12px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.ic { flex: none; vertical-align: middle; }
.inline { display: inline; }
.muted { color: var(--muted); }
.subtle { color: var(--subtle); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.strong { font-weight: 600; color: var(--ink); }
.pos { color: var(--green); }
.neg { color: var(--red); }
.hide { display: none !important; }
.mt0 { margin-top: 0 !important; } .mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.mb0 { margin-bottom: 0 !important; } .mb8 { margin-bottom: 8px; } .mb16 { margin-bottom: 16px; }
.gap8 { gap: 8px; } .gap12 { gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-b { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 16px; }

/* ---------------------------------------------------------------- shell */
body.app { padding: 18px; min-height: 100vh; background:
  radial-gradient(1200px 600px at 10% -10%, #f3f7fc 0%, rgba(243,247,252,0) 60%),
  radial-gradient(900px 500px at 110% 110%, #dfe7f1 0%, rgba(223,231,241,0) 60%), var(--canvas); }
.shell {
  display: flex; min-height: calc(100vh - 36px); border-radius: 18px; overflow: hidden; overflow: clip;
  background: linear-gradient(90deg, #fff 0, #fff calc(var(--side-w) - 1px), var(--line) calc(var(--side-w) - 1px), var(--line) var(--side-w), var(--bg) var(--side-w));
  box-shadow: 0 30px 60px -30px rgba(23, 43, 77, .35), 0 0 0 1px rgba(16, 24, 40, .06);
  max-width: 1680px; margin: 0 auto;
}
.side {
  width: var(--side-w); flex: none; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column;
  padding: 18px 14px 14px; position: sticky; top: 18px; align-self: flex-start; height: calc(100vh - 36px); overflow-y: auto; border-radius: 18px 0 0 18px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 18px; color: var(--ink); }
.brand-t { display: flex; flex-direction: column; line-height: 1.1; }
.brand-t b { font-size: 18px; font-weight: 700; letter-spacing: -.02em; color: #173b6c; }
.brand-t small { font-size: 12.5px; color: #3b5c86; font-weight: 500; margin-top: 2px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-i {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 8px; color: #344054; font-weight: 500;
  cursor: pointer; list-style: none; user-select: none; transition: background .12s, color .12s;
}
.nav-i::-webkit-details-marker { display: none; }
.nav-i:hover { background: #f2f5f9; color: var(--ink); }
.nav-i .ic { color: #475467; }
.nav-i.on { background: var(--primary-50); color: var(--primary-700); font-weight: 600; box-shadow: inset 0 0 0 1px var(--primary-100); }
.nav-i.on .ic, .nav-i.in .ic { color: var(--primary); }
.nav-i.in { color: var(--ink); font-weight: 600; }
.nav-i span { flex: 1; }
.nav-g .chev { color: var(--subtle); transition: transform .15s; }
.nav-g[open] > summary .chev { transform: rotate(180deg); }
.nav-sub { display: flex; flex-direction: column; margin: 2px 0 6px 21px; padding-left: 12px; border-left: 1px solid var(--line); }
.nav-sub a { padding: 6px 10px; border-radius: 6px; color: var(--muted); font-size: 13.5px; }
.nav-sub a:hover { color: var(--ink); background: #f5f7fa; }
.nav-sub a.on { color: var(--primary-700); background: var(--primary-50); font-weight: 600; }
.side-foot { border-top: 1px solid var(--line-2); padding-top: 10px; margin-top: 12px; }
.me { display: flex; align-items: center; gap: 10px; padding: 10px 6px 2px; }
.me-t { flex: 1; min-width: 0; line-height: 1.2; }
.me-t b { display: block; font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-t small { color: var(--muted); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 14px; padding: 22px 28px 6px; }
.top-t { flex: 1; min-width: 0; }
.top h1 { font-size: 24px; font-weight: 700; letter-spacing: -.025em; }
.top .sub { margin: 4px 0 0; color: var(--muted); }
.crumb { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.crumb a { color: var(--muted); } .crumb a:hover { color: var(--primary); }
.top-a { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.content { padding: 14px 28px 28px; }
.imp { background: #172b4d; color: #fff; padding: 9px 28px; display: flex; gap: 10px; align-items: center; font-size: 13px; flex-wrap: wrap; }
.imp b { color: #fff; }
.only-m, .icon-btn.only-m { display: none; }
.scrim { display: none; }
.mbar, .tabbar, .side .side-x { display: none; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 15px; border-radius: 8px;
  border: 1px solid transparent; font: 600 13.5px/1 var(--font); cursor: pointer; white-space: nowrap; transition: background .12s, box-shadow .12s, border-color .12s, color .12s;
  text-decoration: none; color: var(--ink); background: #fff;
}
.btn:focus-visible, .icon-btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(31, 95, 174, .25); outline-offset: 1px; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(20, 63, 117, .3), inset 0 1px 0 rgba(255,255,255,.12); }
.btn-primary:hover { background: var(--primary-600); color: #fff; }
.btn-green { background: var(--green); color: #fff; box-shadow: 0 1px 2px rgba(25, 115, 63, .3), inset 0 1px 0 rgba(255,255,255,.12); }
.btn-green:hover { background: var(--green-600); color: #fff; }
.btn-teal { background: var(--teal); color: #fff; box-shadow: 0 1px 2px rgba(22, 112, 125, .3), inset 0 1px 0 rgba(255,255,255,.12); }
.btn-teal:hover { background: var(--teal-600); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: var(--red-600); color: #fff; }
.btn-outline { background: #fff; border-color: #cfd7e3; color: #243247; box-shadow: var(--sh-1); }
.btn-outline:hover { background: #f6f8fb; border-color: #b8c3d3; color: var(--ink); }
.btn-ghost { background: transparent; color: var(--primary); padding: 0 10px; }
.btn-ghost:hover { background: var(--primary-50); }
.btn-white { background: #fff; color: var(--ink); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 7px; }
.btn-xs { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 6px; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .55; pointer-events: none; }
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; color: #475467; cursor: pointer; list-style: none; box-shadow: var(--sh-1);
}
.icon-btn::-webkit-details-marker { display: none; }
.icon-btn:hover { color: var(--ink); background: #f8fafc; }
.side .icon-btn { width: 32px; height: 32px; box-shadow: none; border-color: transparent; }
.dot { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px #fff; }

/* ---------------------------------------------------------------- popovers */
.pop { position: relative; }
.pop > summary { list-style: none; }
.pop > summary::-webkit-details-marker { display: none; }
.pop-m {
  position: absolute; z-index: 40; top: calc(100% + 8px); left: 0; min-width: 230px; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--sh-3); padding: 6px; animation: pop .12s ease-out;
}
.pop-r { left: auto; right: 0; }
.bell .pop-m { width: 340px; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.pop-h { font-weight: 700; color: var(--ink); padding: 8px 10px 6px; font-size: 13px; }
.pop-e { padding: 10px; color: var(--muted); }
.pop-i { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.pop-i:hover { background: #f4f7fb; color: var(--ink); }
.pop-i b { display: block; font-weight: 500; font-size: 13px; color: var(--ink); }
.pop-i small { color: var(--muted); }
.pop-i .ic { color: var(--muted); }

/* ---------------------------------------------------------------- cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-2); min-width: 0; }
a.card { display: block; color: inherit; }
a.card:hover { border-color: #cdd6e3; box-shadow: var(--sh-2), 0 0 0 3px rgba(31, 95, 174, .06); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px 10px; }
.card-h h2 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-h h2 .ic { color: var(--muted); }
.card-h .more { color: var(--muted); display: inline-flex; padding: 4px; border-radius: 6px; }
.card-h .more:hover { background: #f2f5f9; color: var(--ink); }
.card-b { padding: 4px 18px 16px; }
.card-b.flush { padding: 0; }
.card-f { padding: 10px 18px; border-top: 1px solid var(--line-2); font-size: 13px; }
.section-t { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 2px 0 8px; }

.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)); }
.g-main { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.g-side { grid-template-columns: 300px minmax(0, 1fr); align-items: start; }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }

/* KPI */
.kpi { padding: 14px 16px 15px; }
.kpi-label { font-size: 12.5px; color: #344054; font-weight: 500; }
.kpi-value { font-size: 21px; font-weight: 700; color: var(--ink); margin-top: 5px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 13px; font-weight: 500; color: #475467; letter-spacing: 0; }
.kpi-sub .hot { color: var(--red); font-weight: 600; }
.bar { height: 6px; border-radius: 6px; background: #e9edf3; margin-top: 10px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 6px; }
.bar-green > span { background: linear-gradient(90deg, #2aa45f, #1f8a4c); }
.bar-blue > span { background: linear-gradient(90deg, #3b7fd0, #1f5fae); }
.bar-red > span { background: linear-gradient(90deg, #e05a5a, #d13b3b); }
.bar-amber > span { background: #e3a008; }
.bar-teal > span { background: var(--teal); }

.stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; min-width: 130px; box-shadow: var(--sh-1); }
.stat-v { font-size: 18px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat-l { font-size: 12px; color: var(--muted); }
.stat-green .stat-v { color: var(--green); } .stat-red .stat-v { color: var(--red); } .stat-blue .stat-v { color: var(--primary); }

/* ---------------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 11.5px;
  font-weight: 600; white-space: nowrap; line-height: 1; letter-spacing: .005em;
}
.badge .ic { margin-left: -2px; }
.badge-gray { background: #eef1f5; color: #475467; }
.badge-blue { background: var(--primary-50); color: #255fa4; box-shadow: inset 0 0 0 1px #d3e2f6; }
.badge-green { background: var(--green-50); color: #1c7a44; box-shadow: inset 0 0 0 1px #c9e8d4; }
.badge-teal { background: var(--teal-50); color: #17707d; box-shadow: inset 0 0 0 1px #c6e6eb; }
.badge-amber { background: var(--amber-50); color: #8f5600; box-shadow: inset 0 0 0 1px #f3dfb0; }
.badge-red { background: var(--red-50); color: #b52f2f; box-shadow: inset 0 0 0 1px #f6cfcf; }
.badge-red-solid { background: var(--red); color: #fff; }
.badge-purple { background: var(--purple-50); color: #5a3fb0; box-shadow: inset 0 0 0 1px #ddd3f6; }
.pill-check { display: inline-flex; width: 16px; height: 16px; border-radius: 50%; background: var(--green); color: #fff; align-items: center; justify-content: center; }

.avatar {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; font-size: 12.5px;
  font-weight: 700; flex: none; letter-spacing: .02em;
}
.av0 { background: #e3edfa; color: #1f5fae; } .av1 { background: #e2f4ea; color: #1f8a4c; } .av2 { background: #fdf0dc; color: #a35f00; }
.av3 { background: #efe9fb; color: #6a4fbf; } .av4 { background: #e0f2f5; color: #17707d; } .av5 { background: #fde9ee; color: #b4325a; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line);
  background: #fafbfd; white-space: nowrap; position: sticky; top: 0;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafcff; }
.table td.right, .table th.right { text-align: right; }
.table .t-main { font-weight: 600; color: var(--ink); }
.table .t-sub { font-size: 12.5px; color: var(--muted); }
.table tfoot td { font-weight: 700; color: var(--ink); background: #fafbfd; border-top: 1px solid var(--line); }
.card > .table-wrap .table th:first-child, .card > .table-wrap .table td:first-child { padding-left: 18px; }
.card > .table-wrap .table th:last-child, .card > .table-wrap .table td:last-child { padding-right: 18px; }
.card > .table-wrap:first-child .table th { border-top-left-radius: var(--r-lg); }
tr.is-link { cursor: pointer; }

/* ---------------------------------------------------------------- lists */
.list { display: flex; flex-direction: column; }
.li { display: flex; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line-2); }
.li:last-child { border-bottom: 0; }
.li-ic { width: 34px; height: 34px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; flex: none; background: var(--primary-50); color: var(--primary); }
.li-ic.green { background: var(--green-50); color: var(--green); } .li-ic.red { background: var(--red-50); color: var(--red); }
.li-ic.teal { background: var(--teal-50); color: var(--teal); } .li-ic.amber { background: var(--amber-50); color: var(--amber); }
.li-ic.gray { background: #eef1f5; color: #475467; } .li-ic.purple { background: var(--purple-50); color: var(--purple); }
.li-t { flex: 1; min-width: 0; }
.li-t b { display: block; color: var(--ink); font-weight: 600; font-size: 13.5px; }
.li-t small { color: var(--muted); display: block; }
.li-a { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* Directory rows (dashboard) */
.dir { display: flex; flex-direction: column; gap: 10px; max-height: 340px; overflow-y: auto; padding-right: 2px; }
.dir-r { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line); border-radius: 11px; padding: 12px 13px; background: #fff; transition: border-color .12s, box-shadow .12s; color: inherit; }
.dir-r:hover { border-color: #c9d4e3; box-shadow: 0 2px 8px -4px rgba(16, 24, 40, .12); color: inherit; }
.dir-ic { width: 34px; height: 34px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; background: #e9f1fb; color: var(--primary); flex: none; }
.dir-ic.house { background: #e4f5ea; color: var(--green); }
.dir-m { flex: 1; min-width: 0; }
.dir-m b { color: var(--ink); font-weight: 600; display: block; }
.dir-m .u { color: #344054; font-size: 13px; margin-top: 2px; }
.dir-m .d { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.dir-a { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }

/* Timeline (recent payments / tasks) */
.tl { position: relative; display: flex; flex-direction: column; }
.tl-item { position: relative; display: flex; gap: 12px; padding: 0 0 16px; }
.tl-item:not(:last-child)::before { content: ""; position: absolute; left: 13px; top: 30px; bottom: 4px; width: 1px; background: var(--line); }
.tl-ic { width: 27px; height: 27px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.tl-green { background: var(--green-50); color: var(--green); box-shadow: inset 0 0 0 1px #c9e8d4; }
.tl-red { background: var(--red-50); color: var(--red); box-shadow: inset 0 0 0 1px #f6cfcf; }
.tl-blue { background: var(--primary-50); color: var(--primary); box-shadow: inset 0 0 0 1px #d3e2f6; }
.tl-teal { background: var(--teal-50); color: var(--teal); }
.tl-amber { background: var(--amber-50); color: var(--amber); }
.tl-gray { background: #eef1f5; color: #475467; }
.tl-b { flex: 1; min-width: 0; padding-top: 3px; }
.tl-b b { display: block; font-weight: 600; color: var(--ink); font-size: 13.5px; line-height: 1.3; }
.tl-b small { color: var(--muted); display: block; margin-top: 2px; }
.tl-b .tl-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.thumb { width: 92px; height: 66px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); margin-top: 8px; background: #eef2f7; }
.thumb-link { display: inline-block; }
.thumb-cap { font-size: 12px; color: var(--primary); margin-top: 4px; display: block; }

/* Mini tiles (utilities card) */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: #f5f8fc; border: 1px solid #e3e9f2; border-radius: 10px; padding: 11px 12px; color: inherit; display: block; }
a.tile:hover { border-color: #c9d4e3; color: inherit; }
.tile b { display: block; color: var(--ink); font-weight: 600; font-size: 13px; line-height: 1.3; }
.tile .big { font-size: 18px; font-weight: 700; color: var(--ink); margin-top: 6px; letter-spacing: -.01em; }
.tile small { color: var(--muted); display: block; margin-top: 2px; }
.tile .tile-ic { margin-top: 8px; color: var(--primary); display: flex; justify-content: center; }

/* Quick action bar */
.actionbar {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; padding: 14px; background: #fff; border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-2); margin-top: 16px;
}
.actionbar .btn { height: 46px; font-size: 14px; border-radius: 9px; }

/* ---------------------------------------------------------------- forms */
.form { max-width: 880px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .lbl { font-size: 13px; font-weight: 600; color: #344054; }
.field .help, .help { font-size: 12.5px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=time],
input[type=tel], input[type=url], input[type=search], input[type=month], input:not([type]), select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid #cfd7e3; border-radius: 8px; background: #fff; color: var(--ink);
  font: 400 14px var(--font); box-shadow: var(--sh-1); transition: border-color .12s, box-shadow .12s;
}
textarea { height: auto; min-height: 96px; padding: 10px 12px; line-height: 1.5; resize: vertical; }
select { padding-right: 32px; appearance: none; 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='%23667085' stroke-width='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 10px center; }
input:focus, select:focus, textarea:focus { border-color: #7aa6dc; box-shadow: 0 0 0 3px rgba(31, 95, 174, .14); outline: none; }
input[type=file] { font: 13px var(--font); color: var(--muted); max-width: 100%; }
input[type=file]::file-selector-button { font: 600 13px var(--font); border: 1px solid #cfd7e3; background: #fff; border-radius: 7px; padding: 7px 12px; margin-right: 10px; cursor: pointer; color: var(--ink); }
.check { display: flex; gap: 9px; align-items: flex-start; font-size: 13.5px; color: var(--text); cursor: pointer; }
.check input { margin-top: 2px; width: 16px; height: 16px; accent-color: var(--primary); flex: none; }
.input-group { display: flex; align-items: stretch; }
.input-group .pre { display: inline-flex; align-items: center; padding: 0 11px; border: 1px solid #cfd7e3; border-right: 0; border-radius: 8px 0 0 8px; background: #f6f8fb; color: var(--muted); font-weight: 500; }
.input-group input { border-radius: 0 8px 8px 0; }
.input-group .post { display: inline-flex; align-items: center; padding: 0 11px; border: 1px solid #cfd7e3; border-left: 0; border-radius: 0 8px 8px 0; background: #f6f8fb; color: var(--muted); }
.input-group input:has(+ .post) { border-radius: 8px 0 0 8px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 6px; flex-wrap: wrap; }
.fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: #fbfcfe; }
.fieldset > legend, .fieldset-t { font-weight: 700; color: var(--ink); font-size: 14px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type=search], .toolbar select, .toolbar input[type=month], .toolbar input[type=date] { width: auto; min-width: 160px; height: 36px; }
.toolbar .search { position: relative; }
.toolbar .search .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--subtle); }
.toolbar .search input { padding-left: 34px; min-width: 240px; }
.seg { display: inline-flex; background: #eef1f6; border-radius: 9px; padding: 3px; gap: 2px; }
.seg a, .seg button { padding: 6px 12px; border-radius: 7px; color: #475467; font-weight: 600; font-size: 13px; border: 0; background: transparent; cursor: pointer; font-family: var(--font); }
.seg a.on, .seg button.on { background: #fff; color: var(--ink); box-shadow: var(--sh-1); }
.radio-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.radio-card { position: relative; border: 1px solid #cfd7e3; border-radius: 12px; padding: 14px; cursor: pointer; background: #fff; display: flex; gap: 12px; align-items: flex-start; transition: border-color .12s, box-shadow .12s; }
.radio-card input { position: absolute; opacity: 0; pointer-events: none; }
.radio-card:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31, 95, 174, .14); background: #fbfdff; }
.radio-card b { display: block; color: var(--ink); }
.radio-card small { color: var(--muted); }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--primary); border-bottom-color: var(--primary); }

/* definition list */
.dl { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 9px 14px; font-size: 13.5px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; color: var(--ink); font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

/* flashes & notes */
.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 10px; font-size: 13.5px; border: 1px solid; }
.flash span { flex: 1; }
.flash-success { background: #effaf3; border-color: #c5e8d2; color: #165e35; }
.flash-error { background: #fef1f1; border-color: #f5c9c9; color: #9b2626; }
.flash-info { background: #eef5fd; border-color: #cfe0f5; color: #1c4d8c; }
.flash-x { background: none; border: 0; color: inherit; opacity: .6; cursor: pointer; padding: 0; }
.note { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; background: #f4f8fd; border: 1px solid #d9e6f6; color: #284a73; font-size: 13px; }
.note .ic { color: var(--primary); margin-top: 1px; }
.note.amber { background: #fff8e8; border-color: #f2e0b5; color: #7a4d00; } .note.amber .ic { color: var(--amber); }
.note.green { background: #f0faf4; border-color: #cdeadb; color: #1a5e37; } .note.green .ic { color: var(--green); }
.note.red { background: #fef3f3; border-color: #f4d0d0; color: #8c2424; } .note.red .ic { color: var(--red); }

/* empty states */
.empty { text-align: center; padding: 34px 20px; color: var(--muted); }
.empty-ic { width: 48px; height: 48px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; background: var(--primary-50); color: var(--primary); margin-bottom: 12px; }
.empty h3 { font-size: 15px; margin-bottom: 4px; }
.empty p { max-width: 420px; margin: 0 auto 14px; }

/* photo grid */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.photos a, .photos img { border-radius: 10px; }
.photos img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border: 1px solid var(--line); background: #eef2f7; }

/* progress steps */
.steps { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.step { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.step i { width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: #eef1f5; font-style: normal; font-size: 11px; color: #475467; }
.step.done i { background: var(--green); color: #fff; } .step.done { color: var(--green-600); }
.step.cur i { background: var(--primary); color: #fff; } .step.cur { color: var(--primary-700); }
.step-sep { width: 18px; height: 1px; background: var(--line); }

/* signature pad */
.sigpad { border: 1.5px dashed #b8c4d6; border-radius: 12px; background: #fff; touch-action: none; width: 100%; height: 170px; display: block; cursor: crosshair; }
.doc { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 34px 40px; font-family: Georgia, "Times New Roman", serif; font-size: 15px; line-height: 1.65; color: #1d2433; max-height: 560px; overflow-y: auto; }
.doc h1, .doc h2, .doc h3 { font-family: var(--font); }
.doc h1 { font-size: 20px; text-align: center; margin-bottom: 18px; }
.doc h2 { font-size: 15px; margin: 18px 0 6px; }

/* ---------------------------------------------------------------- bare (auth / public) */
body.bare { background: var(--bg); }
.bare-main { min-height: 100vh; }
.auth { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }
.auth-art {
  position: relative; overflow: hidden; color: #fff; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(160deg, #1d5aa6 0%, #17467f 55%, #123764 100%);
}
.auth-art::before { content: ""; position: absolute; inset: auto -20% -35% -20%; height: 70%; background: radial-gradient(closest-side, rgba(42, 163, 122, .55), rgba(42, 163, 122, 0)); }
.auth-art::after { content: ""; position: absolute; right: -120px; top: -120px; width: 420px; height: 420px; border-radius: 50%; background: radial-gradient(closest-side, rgba(255, 255, 255, .16), rgba(255, 255, 255, 0)); }
.auth-art > * { position: relative; z-index: 1; }
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand b { font-size: 22px; letter-spacing: -.02em; display: block; }
.auth-brand small { opacity: .8; font-size: 13px; }
.auth-art h2 { color: #fff; font-size: 34px; line-height: 1.15; letter-spacing: -.03em; max-width: 520px; font-weight: 700; }
.auth-art p.lead { color: rgba(255, 255, 255, .82); font-size: 16px; max-width: 460px; margin-top: 14px; }
.auth-feats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 560px; margin-top: 28px; }
.auth-feat { display: flex; gap: 10px; align-items: flex-start; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .14); border-radius: 12px; padding: 12px; backdrop-filter: blur(4px); }
.auth-feat .ic { color: #9fe0c4; margin-top: 1px; }
.auth-feat b { display: block; font-size: 13.5px; }
.auth-feat small { color: rgba(255, 255, 255, .72); }
.auth-foot { font-size: 12.5px; color: rgba(255, 255, 255, .6); }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 26px; letter-spacing: -.025em; }
.auth-card .sub { color: var(--muted); margin: 6px 0 24px; }
.auth-card .field { margin-bottom: 14px; }
.auth-card input { height: 44px; }
.auth-card .btn { height: 46px; }

.public { max-width: 1120px; margin: 0 auto; padding: 0 22px 60px; }
.pub-top { display: flex; align-items: center; justify-content: space-between; padding: 20px 0; }
.pub-hero { background: linear-gradient(150deg, #1d5aa6, #143f75); color: #fff; border-radius: 18px; padding: 36px; margin-bottom: 22px; position: relative; overflow: hidden; }
.pub-hero h1 { color: #fff; font-size: 30px; letter-spacing: -.025em; }
.pub-hero p { color: rgba(255, 255, 255, .82); margin: 8px 0 0; font-size: 15px; }
.lcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.lcard { background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: var(--sh-2); color: inherit; display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s; }
.lcard:hover { transform: translateY(-2px); box-shadow: var(--sh-3); color: inherit; }
.lcard img { width: 100%; aspect-ratio: 16/10; object-fit: cover; background: #dde5ef; }
.lcard-b { padding: 14px 16px 16px; }
.lcard-b .price { font-size: 20px; font-weight: 700; color: var(--ink); }
.lcard-b .price small { font-size: 13px; color: var(--muted); font-weight: 500; }
.lcard-b h3 { font-size: 15px; margin: 4px 0; }
.lcard-meta { display: flex; gap: 12px; color: var(--muted); font-size: 13px; margin-top: 6px; flex-wrap: wrap; }
.lcard-meta span { display: inline-flex; gap: 5px; align-items: center; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.slot { position: relative; }
.slot input { position: absolute; opacity: 0; }
.slot span { display: block; text-align: center; padding: 9px 6px; border: 1px solid #cfd7e3; border-radius: 9px; font-weight: 600; font-size: 13px; cursor: pointer; background: #fff; }
.slot input:checked + span { background: var(--primary); color: #fff; border-color: var(--primary); }
.slot input:disabled + span { opacity: .4; text-decoration: line-through; cursor: not-allowed; }

.section-t.mt8 { margin-top: 8px; } .section-t.mt12 { margin-top: 12px; } .section-t.mt16 { margin-top: 16px; } .section-t.mt24 { margin-top: 24px; }

/* demo bar */
.demo-bar { max-width: 1680px; margin: 0 auto 12px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 9px 12px 9px 10px; border-radius: 12px;
  background: linear-gradient(90deg, #13345f, #1d5aa6); color: #fff; font-size: 13px; box-shadow: 0 8px 20px -12px rgba(19, 52, 95, .6); }
.demo-tag { display: inline-flex; align-items: center; gap: 5px; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.25); padding: 3px 9px; border-radius: 999px; font-weight: 700; letter-spacing: .02em; }
.demo-txt { flex: 1; min-width: 200px; color: rgba(255,255,255,.88); }
.demo-views { display: inline-flex; background: rgba(0,0,0,.18); border-radius: 9px; padding: 3px; gap: 2px; }
.demo-views a { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 7px; color: rgba(255,255,255,.85); font-weight: 600; }
.demo-views a:hover { color: #fff; background: rgba(255,255,255,.1); }
.demo-views a.on { background: #fff; color: #143f75; }
@media (max-width: 900px) { .demo-bar { margin: 0; border-radius: 0; } }

/* tenant portal */
.portal-amt { font-size: 40px; font-weight: 800; color: var(--ink); letter-spacing: -.035em; line-height: 1.1; margin-top: 6px; font-variant-numeric: tabular-nums; }
.portal-amt.pos { color: var(--green); }
.portal-hero { background: linear-gradient(135deg, #ffffff 0%, #f3f8fe 100%); }
.pay-amount { font-size: 28px !important; height: 56px !important; font-weight: 700; letter-spacing: -.02em; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid #cfd7e3; background: #fff; font-weight: 600; font-size: 12.5px; color: #344054; cursor: pointer; font-family: var(--font); }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.lock-note { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12.5px; }

/* receipts / print */
.receipt { max-width: 640px; margin: 0 auto; }
.receipt .amount { font-size: 34px; font-weight: 800; color: var(--ink); letter-spacing: -.03em; }
@media print {
  body.app { padding: 0; background: #fff; }
  .side, .top-a, .imp, .no-print, .flashes, .scrim, .only-m, .mbar, .tabbar, .demo-bar { display: none !important; }
  body.has-tabbar .content { padding-bottom: 0 !important; }
  .shell { box-shadow: none; border-radius: 0; background: #fff; }
  .card { box-shadow: none; }
  .content { padding: 0; }
}

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1280px) {
  .g-main { grid-template-columns: minmax(0, 1fr) 300px; }
}
@media (max-width: 1100px) {
  .g-main, .g-2-1, .g-side { grid-template-columns: minmax(0, 1fr); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  body.app { padding: 0; }
  .shell { border-radius: 0; min-height: 100vh; background: var(--bg); }
  .only-m, .icon-btn.only-m { display: inline-flex; }
  .top { padding: 16px 16px 4px; align-items: flex-start; }
  .top h1 { font-size: 20px; }
  .content { padding: 12px 16px 24px; }
  .imp { padding: 9px 16px; }
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  .form-grid, .form-grid.g3 { grid-template-columns: minmax(0, 1fr); }
  .actionbar { grid-template-columns: 1fr 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { padding: 28px 22px; }
  .auth-art h2 { font-size: 24px; }
  .auth-feats { display: none; }
  .dl { grid-template-columns: 120px minmax(0, 1fr); }
  .doc { padding: 20px; }
  .toolbar .search input { min-width: 0; }
  .bell .pop-m { width: 300px; }
}
@media (max-width: 520px) {
  .dir-r { flex-wrap: wrap; }
  .dir-a { flex-direction: row; flex-wrap: wrap; width: 100%; padding-left: 46px; align-items: center; }
  .portal-amt { font-size: 32px; }
  .actionbar { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr; }
  .top-a .btn span.btn-l { display: none; }
}

/* ================================================================ mobile app shell
   ≤900px: sticky app bar + off-canvas drawer. ≤640px: bottom tab bar, card tables,
   bottom-sheet menus, 44px tap targets, 16px inputs (no iOS zoom). */
@media (max-width: 900px) {
  .shell { overflow: visible; }
  .main { min-height: 100vh; min-height: 100dvh; }

  /* app bar */
  .mbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 50;
    min-height: 58px; padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
    background: rgba(255, 255, 255, .97); border-bottom: 1px solid var(--line); box-shadow: 0 6px 18px -16px rgba(16, 24, 40, .35);
  }
  .mbar .icon-btn { width: 42px; height: 42px; border-radius: 12px; border-color: transparent; box-shadow: none; background: transparent; color: #344054; }
  .mbar .icon-btn:active { background: #eef2f7; }
  .mbar-brand { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; color: var(--ink); }
  .mbar-brand > span { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
  .mbar-brand b { font-size: 16px; font-weight: 700; letter-spacing: -.02em; color: #173b6c; }
  .mbar-brand small { font-size: 11.5px; color: #3b5c86; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mbar-a { display: flex; align-items: center; gap: 4px; }
  .mbar-me { border: 0; background: none; padding: 4px; cursor: pointer; border-radius: 50%; }
  .mbar-me .avatar { width: 34px; height: 34px; }
  .mbar .dot { top: 9px; right: 10px; }
  .top-a .bell-d { display: none; }

  /* off-canvas drawer */
  .side {
    position: fixed; z-index: 80; left: 0; top: 0; bottom: 0; width: min(86vw, 320px); height: auto; max-height: none; align-self: stretch;
    padding: calc(14px + env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    border-radius: 0 22px 22px 0; border-right: 0; box-shadow: 0 24px 60px -12px rgba(16, 24, 40, .35);
    transform: translateX(-105%); visibility: hidden; overscroll-behavior: contain;
    transition: transform .26s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .26s;
  }
  body.side-open .side { transform: none; visibility: visible; transition: transform .26s cubic-bezier(.2, .8, .2, 1), visibility 0s; }
  .side-top { display: flex; align-items: flex-start; gap: 8px; }
  .side-top .brand { flex: 1; min-width: 0; }
  .side .side-x { display: inline-flex; width: 38px; height: 38px; border-radius: 11px; background: #f2f5f9; color: #475467; flex: none; }
  .side .nav-i { padding: 11px 12px; font-size: 15px; border-radius: 10px; }
  .side .nav-sub a { padding: 9px 12px; font-size: 14.5px; }
  .side .me .icon-btn { width: 40px; height: 40px; }
  .scrim {
    display: block; position: fixed; inset: 0; z-index: 75; background: rgba(15, 26, 46, .42);
    opacity: 0; pointer-events: none; transition: opacity .22s ease; -webkit-tap-highlight-color: transparent;
  }
  body.side-open .scrim { opacity: 1; pointer-events: auto; }
  body.side-open { overflow: hidden; }

  /* demo bar: one compact row */
  .demo-bar { flex-wrap: nowrap; gap: 10px; padding: calc(7px + env(safe-area-inset-top)) 12px 7px; }
  .demo-txt { display: none; }
  .demo-views { margin-left: auto; }
}

@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .content { padding: 10px 14px 28px; }
  body.has-tabbar .content { padding-bottom: calc(92px + env(safe-area-inset-bottom)); }

  /* demo bar */
  .demo-bar { padding: calc(6px + env(safe-area-inset-top)) 10px 6px; gap: 8px; }
  .demo-tag { padding: 3px 8px; font-size: 12px; flex: none; }
  .demo-views { flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; justify-content: space-between; }
  .demo-views::-webkit-scrollbar { display: none; }
  .demo-views a { flex: 1 0 auto; justify-content: center; padding: 6px 9px; font-size: 12.5px; white-space: nowrap; }
  .demo-views .dv-x { display: none; }

  /* page header: title left, compact actions right (wrap under when wide) */
  .top { flex-wrap: wrap; padding: 16px 14px 6px; gap: 10px 10px; align-items: flex-start; }
  .top-t { flex: 1 1 200px; }
  .top-a { width: auto; flex: 0 1 auto; justify-content: flex-end; gap: 8px; }
  .top h1 { font-size: 22px; line-height: 1.2; letter-spacing: -.025em; overflow-wrap: anywhere; }
  .top .sub { font-size: 13.5px; }
  .crumb { flex-wrap: nowrap; white-space: nowrap; overflow-x: auto; scrollbar-width: none; margin-bottom: 6px; }
  .crumb::-webkit-scrollbar { display: none; }
  .top-a .btn, .top-a .icon-btn, .top-a .pop > summary.btn { height: 42px; }
  .top-a .icon-btn { width: 42px; border-radius: 11px; }
  .top-a .btn { padding: 0 14px; border-radius: 11px; }

  /* tap targets */
  .btn { height: 44px; border-radius: 10px; font-size: 14px; }
  .btn-sm { height: 38px; font-size: 13.5px; border-radius: 9px; }
  .btn-xs { height: 32px; font-size: 12.5px; }
  .btn-lg { height: 52px; }
  .btn-ghost { padding: 0 12px; }
  .icon-btn { width: 42px; height: 42px; }
  .card-h .more { padding: 9px; margin: -6px -8px -6px 0; }
  .flash-x { padding: 6px; margin: -6px -6px -6px 0; }

  /* forms: 16px text prevents iOS focus-zoom */
  input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=time],
  input[type=tel], input[type=url], input[type=search], input[type=month], input:not([type]), select, textarea { font-size: 16px; height: 46px; border-radius: 10px; }
  textarea { height: auto; }
  input[type=date], input[type=month], input[type=datetime-local], input[type=time] { min-width: 0; -webkit-appearance: none; appearance: none; text-align: left; }
  .pay-amount { font-size: 28px !important; height: 58px !important; }
  .input-group .pre, .input-group .post { border-radius: 10px 0 0 10px; }
  .input-group .post { border-radius: 0 10px 10px 0; }
  .input-group input { border-radius: 0 10px 10px 0; }
  input[type=file] { width: 100%; min-width: 0; }
  .check { font-size: 14.5px; padding: 3px 0; }
  .check input { width: 20px; height: 20px; margin-top: 0; }
  .form-actions { gap: 10px; }
  .form-actions > .btn, .form-actions > a.btn, .form-actions > button, .form-actions > form { flex: 1 1 140px; }
  .form-actions > form > .btn { width: 100%; }
  .field > label, .lbl { font-size: 13.5px; }
  .fieldset { padding: 14px; }
  .radio-cards { grid-template-columns: minmax(0, 1fr); }
  .chip { height: 36px; padding: 0 14px; font-size: 13px; }
  .slot span { padding: 12px 6px; }

  /* toolbars & filters */
  .toolbar { gap: 8px; }
  .toolbar .search { flex: 1 1 100%; }
  .toolbar .search input { width: 100%; min-width: 0; }
  .toolbar > select, .toolbar > form, .toolbar > input[type=month], .toolbar > input[type=date] { flex: 1 1 140px; min-width: 0; }
  .toolbar input[type=search], .toolbar select, .toolbar input[type=month], .toolbar input[type=date] { height: 44px; min-width: 0; }
  .toolbar form.row { flex-wrap: wrap; gap: 8px; }
  .toolbar form.row > select, .toolbar form.row > input { flex: 1 1 140px; width: auto; }
  .seg { display: flex; max-width: 100%; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .seg::-webkit-scrollbar { display: none; }
  .seg a, .seg button { flex: none; white-space: nowrap; padding: 8px 13px; }
  .tabs { scrollbar-width: none; margin-left: -14px; margin-right: -14px; padding: 0 14px; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { padding: 12px 12px; }

  /* cards, grids, stats */
  .card-h { flex-wrap: wrap; padding: 14px 16px 10px; }
  .card-h h2 { flex: 1 1 auto; min-width: 0; }
  .card-b { padding: 4px 16px 16px; }
  .card-f { padding: 10px 16px; }
  .stack > * + * { margin-top: 14px; }
  .grid { gap: 14px; }
  .stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { min-width: 0; padding: 11px 13px; border-radius: 13px; }
  .stats > .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .grid.g3:has(> .kpi), .grid.g4:has(> .kpi), .grid.g2:has(> .kpi) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .grid:has(> .kpi) > .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .kpi { padding: 13px 14px 14px; border-radius: 14px; }
  .kpi-label { font-size: 12px; line-height: 1.3; }
  .kpi-value { font-size: 20px; }
  .kpi-sub { font-size: 12.5px; }
  .dl { grid-template-columns: minmax(96px, 38%) minmax(0, 1fr); gap: 8px 12px; }
  .li { gap: 11px; }
  .li-a { max-width: 50%; }
  .note { padding: 11px 12px; }
  .empty { padding: 28px 16px; }
  .doc { padding: 18px 16px; font-size: 15.5px; }
  .photos { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .auth-panel { padding: 28px 18px 40px; }
  .auth-art { gap: 20px; padding: calc(24px + env(safe-area-inset-top)) 20px 26px; }
  .auth-art h2 { font-size: 23px; }
  .public { padding: 0 16px 48px; }
  .pub-hero { padding: 24px 20px; border-radius: 16px; }
  .pub-hero h1 { font-size: 25px; }

  /* dashboard */
  .dash .grid.g3:has(> .kpi) > .kpi:nth-child(2) { order: -1; grid-column: 1 / -1; }
  .dash .grid.g3:has(> .kpi) > .kpi:nth-child(3) { grid-column: auto; }
  .grid:has(> .kpi) > .kpi .kpi-sub { display: block; margin-top: 3px; }
  .grid:has(> .kpi) > .kpi:last-child:nth-child(odd) .kpi-sub, .dash .grid.g3:has(> .kpi) > .kpi:nth-child(2) .kpi-sub { display: inline; margin: 0; }
  .dash .grid.g3:has(> .kpi) > .kpi:nth-child(3) .kpi-sub { display: block; margin-top: 3px; }
  .dash .row-b:has(> .seg) { flex-wrap: wrap; }
  .dash .row-b:has(> .seg) > .section-t { display: none; }
  .dash .row-b > .seg { width: 100%; }
  .dash .row-b > .seg button { flex: 1 0 auto; }
  .dir { max-height: 420px; }
  .actionbar { padding: 12px; gap: 10px; grid-template-columns: 1fr 1fr; }
  .actionbar .btn { height: 50px; font-size: 13.5px; white-space: normal; text-align: center; line-height: 1.2; padding: 0 10px; }

  /* menus become bottom sheets */
  .pop[open] > .pop-m {
    position: fixed; left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); top: auto;
    bottom: calc(10px + env(safe-area-inset-bottom)); width: auto !important; min-width: 0; max-width: none; max-height: 72vh; max-height: 72dvh;
    overflow-y: auto; overscroll-behavior: contain; z-index: 92; border-radius: 18px; padding: 8px; border: 0;
    box-shadow: 0 -10px 40px -10px rgba(16, 24, 40, .35); animation: sheet .22s cubic-bezier(.2, .8, .2, 1);
  }
  .pop[open] > summary::before { content: ""; position: fixed; inset: 0; z-index: 91; background: rgba(15, 26, 46, .42); animation: fade .2s ease-out; cursor: default; }
  .pop-m .pop-h { font-size: 14px; padding: 10px 12px 8px; }
  .pop-i { padding: 12px; border-radius: 11px; font-size: 15px; align-items: center; min-height: 48px; }
  .pop-i b { font-size: 14.5px; }

  /* bottom tab bar */
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    padding: 6px max(6px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    background: rgba(255, 255, 255, .94); -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
    border-top: 1px solid rgba(16, 24, 40, .08); box-shadow: 0 -8px 24px -18px rgba(16, 24, 40, .35);
  }
  .tabbar a {
    flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 52px; padding: 3px 2px; color: #667085; font-size: 11px; font-weight: 600; letter-spacing: .01em; -webkit-tap-highlight-color: transparent;
  }
  .tb-ic { display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 30px; border-radius: 15px; transition: background .15s, color .15s; }
  .tb-l { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tabbar a.on { color: var(--primary-700); }
  .tabbar a.on .tb-ic { background: var(--primary-50); color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary-100); }
  .tabbar a:active .tb-ic { background: #eef2f7; }
}
@keyframes sheet { from { transform: translateY(24px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

@media (min-width: 641px) and (max-width: 900px) {
  .grid.g3:has(> .kpi) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid.g4:has(> .kpi) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table.t-cards td.c-det { flex-basis: calc(33.333% - 8px) !important; }
  .table.t-cards td.c-det.c-wide { flex-basis: calc(66.666% - 4px) !important; }
}

/* ---------------------------------------------------------------- phone tables
   app.js adds .t-cards to any .table that would overflow on a phone. Each row becomes a
   card: [media] title … lead amount ›, then labelled details two-up, then actions.
   Opt out per table with data-mobile="scroll" (sticky first column) or data-mobile="keep". */
@media (max-width: 900px) {
  .table.t-cards, .table.t-cards > tbody, .table.t-cards > tfoot { display: block; width: 100%; }
  .table.t-cards > thead { display: none; }
  .table.t-cards tr {
    display: flex; flex-wrap: wrap; align-items: flex-start; column-gap: 12px; position: relative;
    padding: 13px 16px 14px; border-bottom: 1px solid var(--line-2);
  }
  .table.t-cards > tbody > tr:last-child { border-bottom: 0; }
  .table.t-cards td {
    display: block; padding: 0 !important; border: 0 !important; min-width: 0; text-align: left !important;
    white-space: normal !important; background: transparent !important; overflow-wrap: anywhere; width: auto !important; max-width: none;
  }
  .table.t-cards td.c-kick { order: -1; flex: 0 0 100%; margin-bottom: 3px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
  .table.t-cards td.c-kick * { display: inline; font-size: inherit !important; color: inherit !important; font-weight: inherit !important; }
  .table.t-cards td.c-kick .t-sub::before, .table.t-cards td.c-kick small::before { content: " · "; }
  .table.t-cards td.c-media { order: 0; flex: none; align-self: center; }
  .table.t-cards td.c-media img { max-width: 56px; }
  .table.t-cards td.c-title { order: 1; flex: 1 1 0; align-self: center; font-size: 14.5px; }
  .table.t-cards td.c-lead { order: 2; flex: none; max-width: 48%; text-align: right !important; font-weight: 700; color: var(--ink); font-size: 15px; align-self: center; }
  .table.t-cards td.c-lead .t-sub, .table.t-cards td.c-lead small { font-weight: 500; }
  .table.t-cards tr[data-href]::before {
    content: ""; order: 3; flex: none; align-self: center; width: 16px; height: 16px; margin-right: -4px; background: var(--subtle);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  }
  .table.t-cards tr::after { content: ""; order: 4; flex: 0 0 100%; height: 0; }
  .table.t-cards td.c-det { order: 5; flex: 0 0 calc(50% - 6px); margin-top: 9px; font-size: 13.5px; line-height: 1.4; color: var(--text); }
  .table.t-cards td.c-det.c-wide { flex-basis: 100%; }
  .table.t-cards td.c-det::before {
    content: attr(data-label); display: block; margin-bottom: 2px; font-size: 10.5px; font-weight: 700; letter-spacing: .06em;
    text-transform: uppercase; color: var(--subtle); line-height: 1.3;
  }
  .table.t-cards td.c-det[data-label=""]::before { display: none; }
  .table.t-cards td.c-act { order: 6; flex: 0 0 100%; margin-top: 12px; padding-top: 12px !important; border-top: 1px dashed var(--line) !important; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
  .table.t-cards td.c-act > .btn, .table.t-cards td.c-act > form, .table.t-cards td.c-act > a { flex: 1 1 auto; }
  .table.t-cards td.c-act form .btn { width: 100%; }
  .table.t-cards td.c-act.c-act-i { order: 3; flex: none; display: block; margin: -6px -8px -6px 0; padding: 0 !important; border: 0 !important; align-self: center; }
  .table.t-cards tr:has(> td.c-act-i)::before { display: none; }
  .table.t-cards td.c-empty { display: none; }
  .table.t-cards tr.c-group { padding: 10px 16px; background: #f6f8fb; border-bottom: 1px solid var(--line); }
  .table.t-cards tr.c-group td { flex: 1 1 100%; font-weight: 700; color: var(--ink); }
  .table.t-cards tr.c-group::after, .table.t-cards tr.c-group::before { display: none; }
  .table.t-cards > tfoot tr { background: #fafbfd; border-top: 1px solid var(--line); }
  .table.t-cards > tfoot td { font-weight: 700; }
  .table.t-cards tbody tr:hover td { background: transparent !important; }
  .table.t-cards tr[data-href]:active { background: #f4f7fb; }
  .table.t-cards .badge { white-space: normal; height: auto; min-height: 22px; padding-top: 4px; padding-bottom: 4px; line-height: 1.2; max-width: 100%; }
  .table.t-cards .nowrap, .table.t-cards .lx-names { white-space: normal !important; }
  .table.t-cards td .row { flex-wrap: wrap; min-width: 0; }
  .table.t-cards input:not([type=checkbox]):not([type=radio]), .table.t-cards select { width: 100%; }
  .card > .table-wrap:has(> .t-cards) { overflow: visible; }

  /* opt-in horizontal scroll with a sticky first column */
  .table[data-mobile=scroll] td:first-child, .table[data-mobile=scroll] th:first-child {
    position: sticky; left: 0; z-index: 1; background: #fff; box-shadow: 1px 0 0 var(--line-2);
  }
  .table[data-mobile=scroll] th:first-child { background: #fafbfd; z-index: 2; }
}
