/* ============================================================
   Cosad Rentals — design system  (v2)
   Google-inspired: Material colour roles, 8px rhythm, soft
   elevation, generous whitespace, one accent colour.

   Version marker: the content hash drives the asset filename, so
   bumping this issues a new URL. Needed once because a misconfigured
   nginx block had returned a *permanent* redirect for the previous
   filename, which browsers cache indefinitely.
   ============================================================ */

:root {
  /* Brand / primary */
  --blue-900: #174ea6;
  --blue-700: #1967d2;
  --blue-600: #1a73e8;
  --blue-100: #d2e3fc;
  --blue-50:  #e8f0fe;

  /* Status */
  --green-700: #137333;
  --green-600: #1e8e3e;
  --green-50:  #e6f4ea;
  --amber-700: #b06000;
  --amber-600: #e37400;
  --amber-50:  #fef7e0;
  --red-700:   #b31412;
  --red-600:   #d93025;
  --red-50:    #fce8e6;

  /* Neutrals */
  --grey-900: #202124;
  --grey-800: #303134;
  --grey-700: #3c4043;
  --grey-600: #5f6368;
  --grey-500: #80868b;
  --grey-400: #bdc1c6;
  --grey-300: #dadce0;
  --grey-200: #e8eaed;
  --grey-100: #f1f3f4;
  --grey-50:  #f8f9fa;

  /* Semantic */
  --bg:            var(--grey-50);
  --surface:       #ffffff;
  --surface-alt:   var(--grey-50);
  --border:        var(--grey-300);
  --border-subtle: var(--grey-200);
  --text:          var(--grey-900);
  --text-muted:    var(--grey-600);
  --text-faint:    var(--grey-500);
  --primary:       var(--blue-600);
  --primary-hover: var(--blue-700);
  --primary-soft:  var(--blue-50);
  --on-primary:    #ffffff;

  /* Elevation — Material-style, tight and low-contrast */
  --e1: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
  --e2: 0 1px 2px rgba(60,64,67,.3), 0 2px 6px 2px rgba(60,64,67,.15);
  --e3: 0 4px 8px 3px rgba(60,64,67,.15), 0 1px 3px rgba(60,64,67,.3);

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --radius-xl: 28px;

  --sidebar-w: 264px;
  --topbar-h: 64px;

  /* Native system stack: SF Pro on iOS, Roboto on Android, Segoe on Windows.
     No webfont download, and the app reads as native on each platform. */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, sans-serif;
}

/* ============================================================
   Icon font — self-hosted, subset to the 48 icons this app uses
   (7 KB, versus 5.2 MB for the full Material Symbols set).

   Self-hosted rather than loaded from fonts.googleapis.com so the
   installed PWA still shows icons offline, there is no third-party
   round-trip on mobile data, and no visitor IP is handed to a
   third party — which matters for an EU-facing site.

   font-display: block, not swap: with swap the browser paints the
   ligature *name* ("dashboard", "receipt_long") as text until the
   font arrives. block keeps it blank briefly instead.
   ============================================================ */
@font-face {
  font-family: "Material Symbols Rounded";
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url("../fonts/material-symbols-rounded.19b1d77c36b2.woff2") format("woff2");
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #17181a;
    --surface:       #202124;
    --surface-alt:   #28292c;
    --border:        #3c4043;
    --border-subtle: #303134;
    --text:          #e8eaed;
    --text-muted:    #9aa0a6;
    --text-faint:    #80868b;
    --primary:       #8ab4f8;
    --primary-hover: #aecbfa;
    --primary-soft:  rgba(138,180,248,.12);
    --on-primary:    #202124;
    --blue-50:       rgba(138,180,248,.12);
    --green-50:      rgba(129,201,149,.12);
    --amber-50:      rgba(253,214,99,.12);
    --red-50:        rgba(242,139,130,.12);
    --green-600:     #81c995;
    --green-700:     #81c995;
    --amber-600:     #fdd663;
    --amber-700:     #fdd663;
    --red-600:       #f28b82;
    --red-700:       #f28b82;
    --e1: 0 1px 2px rgba(0,0,0,.6), 0 1px 3px 1px rgba(0,0,0,.3);
    --e2: 0 1px 2px rgba(0,0,0,.6), 0 2px 6px 2px rgba(0,0,0,.3);
    --e3: 0 4px 8px 3px rgba(0,0,0,.3), 0 1px 3px rgba(0,0,0,.6);
  }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p, figure { margin: 0; }
img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }

/* Full declaration: previously this came from Google's stylesheet, so it has
   to be spelled out now that the font is self-hosted. Without font-family
   here, every icon renders as its literal ligature name. */
.material-symbols-rounded {
  font-family: "Material Symbols Rounded";
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  user-select: none;
}

/* ---------- Layout primitives ---------- */
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.stack     { display: flex; flex-direction: column; gap: 24px; }
.row       { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.wrap      { flex-wrap: wrap; }
.grow      { flex: 1; }
.muted     { color: var(--text-muted); }
.faint     { color: var(--text-faint); }
.small     { font-size: 13px; }
.tiny      { font-size: 12px; }
.center    { text-align: center; }
.mono      { font-family: "Roboto Mono", ui-monospace, "SF Mono", Menlo, monospace; }

/* ============================================================
   Public site
   ============================================================ */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border-subtle);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: var(--topbar-h); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 500; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--blue-600), #4285f4);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px;
}
.site-nav { display: flex; align-items: center; gap: 8px; }
/* :not(.btn) matters. `.site-nav a` is specificity (0,1,1) and `.btn` is
   (0,1,0), so without the exclusion the nav rule wins on colour and padding
   no matter the source order — which painted the header's "Tenant login"
   button grey-on-blue and un-styled its padding. */
.site-nav a:not(.btn) {
  padding: 8px 16px; border-radius: var(--radius-xl);
  color: var(--text-muted); font-weight: 500;
}
.site-nav a:not(.btn):hover {
  background: var(--grey-100); color: var(--text); text-decoration: none;
}

.hero { padding: 96px 0 72px; }
.hero h1 {
  font-size: clamp(36px, 6vw, 60px);
  line-height: 1.1; font-weight: 400; letter-spacing: -1.5px;
  max-width: 16ch;
}
.hero h1 em { font-style: normal; color: var(--primary); }
.hero p { margin-top: 24px; font-size: 18px; color: var(--text-muted); max-width: 56ch; }
.hero-actions { margin-top: 40px; display: flex; gap: 12px; flex-wrap: wrap; }

.feature-grid {
  display: grid; gap: 24px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.feature {
  background: var(--surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); padding: 28px;
}
.feature .material-symbols-rounded {
  font-size: 28px; color: var(--primary);
  background: var(--primary-soft); padding: 12px; border-radius: 50%;
}
.feature h3 { margin: 20px 0 8px; font-size: 17px; font-weight: 500; }
.feature p { color: var(--text-muted); }

.section { padding: 72px 0; }
.section-head { max-width: 60ch; margin-bottom: 40px; }
.section-head h2 { font-size: clamp(26px, 3.5vw, 36px); font-weight: 400; letter-spacing: -.5px; }
.section-head p { margin-top: 12px; color: var(--text-muted); font-size: 16px; }

.apartment-card {
  background: var(--surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); overflow: hidden; transition: box-shadow .2s;
}
.apartment-card:hover { box-shadow: var(--e2); }
.apartment-card .photo { aspect-ratio: 16/10; background: var(--grey-100); object-fit: cover; width: 100%; }
.apartment-card .photo-empty { display: grid; place-items: center; color: var(--grey-400); }
.apartment-card .photo-empty .material-symbols-rounded { font-size: 48px; }
.apartment-card .body { padding: 20px; }
.apartment-card h3 { font-size: 16px; font-weight: 500; }

.site-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 48px 0; margin-top: 40px; color: var(--text-muted);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 24px; border-radius: var(--radius-xl);
  border: 1px solid transparent; background: var(--primary); color: var(--on-primary);
  font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background .15s, box-shadow .15s, border-color .15s;
}
.btn:hover { background: var(--primary-hover); text-decoration: none; box-shadow: var(--e1); }
.btn:focus-visible { outline: 3px solid var(--blue-100); outline-offset: 1px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .material-symbols-rounded { font-size: 18px; }

.btn-outline { background: transparent; color: var(--primary); border-color: var(--border); }
.btn-outline:hover { background: var(--primary-soft); box-shadow: none; }
.btn-text { background: transparent; color: var(--primary); padding: 0 12px; }
.btn-text:hover { background: var(--primary-soft); box-shadow: none; }
.btn-danger { background: var(--red-600); }
.btn-danger:hover { background: var(--red-700); }
.btn-sm { height: 32px; padding: 0 16px; font-size: 13px; }
.btn-block { width: 100%; }

/* ============================================================
   Portal shell
   ============================================================ */
.portal { min-height: 100vh; }

.appbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h); display: flex; align-items: center; gap: 16px;
  padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--border-subtle);
}
.appbar .brand { font-size: 18px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent;
  color: var(--text-muted); display: grid; place-items: center; cursor: pointer;
}
.icon-btn:hover { background: var(--grey-100); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--primary);
  color: var(--on-primary); display: grid; place-items: center;
  font-size: 13px; font-weight: 600; flex-shrink: 0;
}

.portal-body { display: flex; align-items: flex-start; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; padding: 16px 12px;
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h)); overflow-y: auto;
}
.nav-item {
  display: flex; align-items: center; gap: 16px;
  height: 44px; padding: 0 16px; margin-bottom: 2px;
  border-radius: var(--radius-xl); color: var(--text-muted); font-weight: 500;
}
.nav-item:hover { background: var(--grey-100); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.nav-item .badge-count {
  margin-left: auto; background: var(--primary); color: var(--on-primary);
  border-radius: 10px; padding: 1px 7px; font-size: 11px; font-weight: 600;
}
.nav-section {
  padding: 20px 16px 8px; font-size: 11px; font-weight: 600;
  letter-spacing: .8px; text-transform: uppercase; color: var(--text-faint);
}

.content { flex: 1; min-width: 0; padding: 32px; max-width: 1100px; }
.page-head { margin-bottom: 28px; }
.page-head h1 { font-size: 28px; font-weight: 400; letter-spacing: -.3px; }
.page-head p { margin-top: 6px; color: var(--text-muted); }

/* ============================================================
   Cards, stats, tables
   ============================================================ */
.card {
  background: var(--surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); padding: 24px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; }
.card-head h2 { font-size: 16px; font-weight: 500; }
.card-flush { padding: 0; overflow: hidden; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.stat {
  background: var(--surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); padding: 20px;
}
.stat .label { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.stat .value { font-size: 34px; font-weight: 400; line-height: 1.2; margin-top: 10px; letter-spacing: -1px; }
.stat.accent .value { color: var(--primary); }
.stat.warn   .value { color: var(--amber-600); }
.stat.ok     .value { color: var(--green-600); }
.stat.muted-stat .value { color: var(--text-muted); }

.progress { height: 6px; border-radius: 3px; background: var(--grey-200); overflow: hidden; margin-top: 14px; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 3px; }

.list { list-style: none; margin: 0; padding: 0; }
.list-row {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px; border-bottom: 1px solid var(--border-subtle);
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--surface-alt); }
.list-row .material-symbols-rounded { color: var(--text-muted); flex-shrink: 0; }

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .4px;
  text-transform: uppercase; color: var(--text-faint);
  padding: 12px 16px; border-bottom: 1px solid var(--border-subtle);
}
td { padding: 14px 16px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-alt); }

/* ============================================================
   Badges / chips
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 12px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-blue  { background: var(--blue-50);  color: var(--blue-700); }
.badge-amber { background: var(--amber-50); color: var(--amber-700); }
.badge-green { background: var(--green-50); color: var(--green-700); }
.badge-red   { background: var(--red-50);   color: var(--red-700); }
.badge-grey  { background: var(--grey-100); color: var(--grey-700); }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 14px; border-radius: 16px;
  border: 1px solid var(--border); color: var(--text-muted);
  font-size: 13px; font-weight: 500; background: var(--surface);
}
.chip:hover { background: var(--grey-100); text-decoration: none; color: var(--text); }
.chip.active { background: var(--primary-soft); border-color: transparent; color: var(--primary); }
.chip .material-symbols-rounded { font-size: 16px; }

/* ============================================================
   Forms
   ============================================================ */
.field { margin-bottom: 20px; }
.field > label {
  display: block; margin-bottom: 6px;
  font-size: 13px; font-weight: 500; color: var(--text-muted);
}
.field input[type="text"], .field input[type="email"], .field input[type="password"],
.field input[type="number"], .field input[type="date"], .field input[type="file"],
.field textarea, .field select {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 96px; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.field .help { margin-top: 6px; font-size: 12px; color: var(--text-faint); }
.field .errors { margin: 6px 0 0; padding: 0; list-style: none; color: var(--red-600); font-size: 13px; }

/* Radio cards — used for the ticket Category picker */
.radio-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.radio-cards label {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 16px; border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; font-weight: 500; transition: border-color .15s, background .15s;
}
.radio-cards label:hover { background: var(--surface-alt); }
.radio-cards input { accent-color: var(--primary); width: 18px; height: 18px; margin: 0; }
.radio-cards input:checked + span { color: var(--primary); }
.radio-cards label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }

.checkbox-row { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.checkbox-row input { accent-color: var(--primary); width: 16px; height: 16px; }
.checkbox-row label { font-size: 13px; color: var(--text-muted); margin: 0; }

/* ============================================================
   Messages / empty states / alerts
   ============================================================ */
.messages { margin-bottom: 24px; display: flex; flex-direction: column; gap: 8px; }
.message {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 18px; border-radius: var(--radius); font-size: 14px;
}
.message-success { background: var(--green-50); color: var(--green-700); }
.message-error   { background: var(--red-50);   color: var(--red-700); }
.message-info    { background: var(--blue-50);  color: var(--blue-700); }
.message-warning { background: var(--amber-50); color: var(--amber-700); }

.empty { padding: 56px 24px; text-align: center; color: var(--text-muted); }
.empty .material-symbols-rounded { font-size: 44px; color: var(--grey-400); }
.empty h3 { margin: 16px 0 6px; font-size: 16px; font-weight: 500; color: var(--text); }

.alert-strip {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border-radius: var(--radius);
  background: var(--amber-50); color: var(--amber-700); font-size: 14px;
}
.alert-strip.info { background: var(--blue-50); color: var(--blue-700); }

/* ============================================================
   Tickets
   ============================================================ */
.ticket-row { display: flex; align-items: center; gap: 16px; padding: 16px 24px; border-bottom: 1px solid var(--border-subtle); }
.ticket-row:last-child { border-bottom: 0; }
.ticket-row:hover { background: var(--surface-alt); }
.ticket-row .ref { font-size: 12px; color: var(--text-faint); }
.ticket-row .subject { font-weight: 500; color: var(--text); }
.ticket-row .subject:hover { color: var(--primary); }

.timeline { position: relative; padding-left: 32px; }
.timeline::before {
  content: ""; position: absolute; left: 11px; top: 6px; bottom: 6px;
  width: 2px; background: var(--border-subtle);
}
.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-item::before {
  content: ""; position: absolute; left: -26px; top: 5px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--grey-400);
}
.timeline-item.is-status::before { border-color: var(--primary); }

.comment { display: flex; gap: 14px; padding: 18px 0; border-bottom: 1px solid var(--border-subtle); }
.comment:last-child { border-bottom: 0; }
.comment-body { flex: 1; min-width: 0; }
.comment-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.comment-author { font-weight: 500; }
.comment-text { white-space: pre-wrap; word-wrap: break-word; }
.comment.internal { background: var(--amber-50); border-radius: var(--radius); padding: 18px; margin: 8px 0; border-bottom: 0; }

.attachment-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius-xl);
  font-size: 13px; color: var(--text-muted); background: var(--surface);
}
.attachment-chip:hover { background: var(--grey-100); text-decoration: none; }

/* ============================================================
   Auth pages
   ============================================================ */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  padding: 44px 40px; box-shadow: var(--e1);
}
.auth-card h1 { font-size: 24px; font-weight: 400; text-align: center; }
.auth-card .sub { text-align: center; color: var(--text-muted); margin: 8px 0 32px; }

/* ============================================================
   Bank details block
   ============================================================ */
.detail-list { display: grid; gap: 0; }
.detail-item {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 14px 0; border-bottom: 1px solid var(--border-subtle);
}
.detail-item:last-child { border-bottom: 0; }
.detail-item dt { color: var(--text-muted); font-size: 13px; }
.detail-item dd { margin: 0; font-weight: 500; text-align: right; word-break: break-all; }

/* ============================================================
   Two-column splits that must collapse on small screens
   ============================================================ */
.split, .split-narrow {
  display: grid; gap: 20px; align-items: start;
}
.split        { grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr); }
.split-narrow { grid-template-columns: minmax(280px, 1fr) minmax(0, 2fr); }

/* ============================================================
   Mobile app shell: bottom navigation + FAB
   Hidden on desktop, where the sidebar does this job.
   ============================================================ */
.bottom-nav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 46;
  background: var(--surface);
  border-top: 1px solid var(--border-subtle);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav a {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 2px 6px;
  color: var(--text-muted); font-size: 11px; font-weight: 500;
  text-decoration: none; -webkit-tap-highlight-color: transparent;
}
.bottom-nav a:hover { text-decoration: none; }
.bottom-nav a .material-symbols-rounded {
  font-size: 22px; padding: 3px 18px; border-radius: 16px;
  transition: background .18s;
}
/* The subset is a static instance, so the active tab is signalled by the
   pill background and colour rather than the variable FILL axis. */
.bottom-nav a.active { color: var(--primary); }
.bottom-nav a.active .material-symbols-rounded { background: var(--primary-soft); }
.bottom-nav .label {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.fab {
  display: none;
  position: fixed; right: 16px; z-index: 47;
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  width: 56px; height: 56px; border-radius: 18px;
  background: var(--primary); color: var(--on-primary);
  align-items: center; justify-content: center;
  box-shadow: var(--e3); border: 0; cursor: pointer;
}
.fab:hover { text-decoration: none; background: var(--primary-hover); }
.fab .material-symbols-rounded { font-size: 26px; }

/* ============================================================
   Responsive
   ============================================================ */

/* Wide content scrolls inside its own container, never the page. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: var(--topbar-h); bottom: 0; z-index: 48;
    width: min(86vw, var(--sidebar-w));
    background: var(--surface); border-right: 1px solid var(--border-subtle);
    transform: translateX(-100%); transition: transform .22s ease; height: auto;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--e3); }
  .scrim { position: fixed; inset: var(--topbar-h) 0 0; background: rgba(32,33,36,.45); z-index: 47; }

  .bottom-nav { display: flex; }
  .fab { display: flex; }

  /* Leave room for the bottom bar so nothing is trapped underneath. */
  .content {
    padding: 16px 16px calc(84px + env(safe-area-inset-bottom, 0px));
  }

  .appbar { padding: 0 8px; gap: 8px; }
  .appbar .brand span:last-child { font-size: 16px; }

  .split, .split-narrow { grid-template-columns: 1fr; }
  .grid { gap: 14px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .card { padding: 18px; border-radius: var(--radius); }
  .page-head h1 { font-size: 23px; }
  .stat .value { font-size: 28px; }

  .site-nav a.hide-sm { display: none; }
  .hero { padding: 48px 0 36px; }
  .section { padding: 44px 0; }
  .container { padding: 0 16px; }

  /* Comfortable thumb targets everywhere. */
  .btn { height: 44px; }
  .btn-sm { height: 36px; }
  .nav-item { height: 48px; }
  .chip { height: 36px; }
  .list-row, .ticket-row { padding: 14px 16px; }

  /* 16px stops iOS Safari zooming in when a field is focused. */
  .field input[type="text"], .field input[type="email"], .field input[type="password"],
  .field input[type="number"], .field input[type="date"], .field input[type="file"],
  .field textarea, .field select { font-size: 16px; padding: 13px 14px; }

  /* Stack the ticket-row badges instead of squeezing them. */
  .ticket-row { flex-wrap: wrap; }
  .ticket-row .grow { flex-basis: 100%; }

  .detail-item { flex-direction: column; align-items: flex-start; gap: 2px; }
  .detail-item dd { text-align: left; }
}

@media (min-width: 901px) {
  .menu-toggle, .scrim, .bottom-nav, .fab { display: none; }
}

/* Tables become stacked cards on narrow screens: no pinch-zooming to read. */
@media (max-width: 720px) {
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr {
    border: 1px solid var(--border-subtle); border-radius: var(--radius);
    margin: 0 0 12px; padding: 8px 14px;
  }
  .table-cards tr:hover { background: transparent; }
  .table-cards td {
    border: 0; padding: 8px 0; display: flex; gap: 16px;
    align-items: center; justify-content: space-between; text-align: right;
  }
  .table-cards td::before {
    content: attr(data-label);
    color: var(--text-faint); font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .4px;
    text-align: left; flex-shrink: 0;
  }
  .table-cards td:empty { display: none; }
  .table-cards td[data-label=""]::before { content: none; }
}

/* Standalone (installed to home screen): pad for the status bar. */
@media (display-mode: standalone) {
  .appbar { padding-top: env(safe-area-inset-top, 0px); height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px)); }
  .sidebar, .scrim { top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px)); }
}

@media print {
  .sidebar, .appbar, .site-header, .site-footer, .btn, .bottom-nav, .fab { display: none !important; }
  .content { padding: 0; }
}

/* Respect a user's reduced-motion preference. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
