/* ==========================================================================
   EstateOS — Application Design System (app.css)
   Premium light SaaS theme. White-label ready: brand tokens below are
   FALLBACKS. At runtime the layout injects Branding::cssVars() in a
   <style> tag AFTER this file, overriding any --brand-* token.
   No dark mode. Mobile-first.
   ========================================================================== */

:root {
  /* Brand (overridden at runtime by Branding::cssVars()) */
  --brand-primary: #0A1628;          /* deep navy */
  --brand-primary-600: #13263f;
  --brand-primary-700: #0c1a30;
  --brand-secondary: #B8922A;        /* gold */
  --brand-secondary-600: #a37f21;
  --brand-accent: #2E7CF6;

  /* Surfaces & text */
  --bg: #F4F6FA;
  --surface: #FFFFFF;
  --surface-2: #FAFBFD;
  --border: #E4E9F2;
  --border-strong: #CFD8E5;
  --text: #101C2E;
  --muted: #5D6D84;
  --faint: #8A97AB;

  /* Status */
  --green: #15803D;  --green-bg: #E7F6EC;
  --amber: #B45309;  --amber-bg: #FDF1DE;
  --red: #B91C1C;    --red-bg: #FBEAEA;
  --blue: #1D4ED8;   --blue-bg: #E8F0FE;
  --gray: #475569;   --gray-bg: #EEF2F7;

  /* Shape & depth */
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 6px 20px -6px rgba(16, 24, 40, .10);
  --shadow-lg: 0 12px 40px -8px rgba(10, 22, 40, .22);

  /* Layout */
  --sidebar-w: 250px;
  --topbar-h: 64px;
  --bottomnav-h: 64px;

  /* Type */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75em; }
.muted { color: var(--muted); }
.small { font-size: .83rem; }
.nowrap { white-space: nowrap; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, var(--brand-primary) 0%, var(--brand-primary-700) 100%);
  color: #E8EDF5;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  transition: transform .32s cubic-bezier(.2, .7, .25, 1);
  will-change: transform;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255,255,255,.10);
}
.sidebar-brand img { height: 34px; width: 34px; object-fit: contain; border-radius: 8px; background: #fff; }
.sidebar-brand .name { font-weight: 700; font-size: 1.02rem; color: #fff; line-height: 1.2; }
.sidebar-brand .sub { font-size: .72rem; color: rgba(255,255,255,.55); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 10px 20px; }
.nav-section {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .09em;
  color: rgba(255,255,255,.45); padding: 14px 10px 6px; font-weight: 700;
}
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.82); font-size: .93rem; font-weight: 500;
  min-height: 44px;
}
.nav-link:hover { background: rgba(255,255,255,.08); text-decoration: none; color: #fff; }
.nav-link.active {
  background: rgba(255,255,255,.12); color: #fff; font-weight: 650;
  box-shadow: inset 3px 0 0 var(--brand-secondary);
}
.nav-link .ico { width: 20px; text-align: center; font-size: 1.05rem; flex: 0 0 20px; }
.sidebar-foot {
  padding: 12px 16px; font-size: .72rem; color: rgba(255,255,255,.45);
  border-top: 1px solid rgba(255,255,255,.10);
}
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; z-index: 55;
  background: rgba(10, 22, 40, .5);
}

/* Main column */
.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }

/* Topbar */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 50;
}
.hamburger {
  display: none; border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius-sm); width: 44px; height: 44px;
  font-size: 1.25rem; cursor: pointer; color: var(--text);
}
.topbar-search { flex: 1; max-width: 420px; }
.topbar-search input {
  width: 100%; height: 42px; border: 1px solid var(--border); border-radius: 999px;
  padding: 0 16px 0 40px; font-size: .92rem; background: var(--surface-2);
  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='%238A97AB' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.3-4.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 14px center;
}
.topbar-search input:focus { outline: 2px solid var(--brand-secondary); border-color: var(--brand-secondary); background-color: #fff; }
.topbar-spacer { flex: 1; }
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 1.15rem; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); text-decoration: none; }
.icon-btn .dot {
  position: absolute; top: 2px; right: 2px; min-width: 20px; height: 20px;
  padding: 0 5px; border-radius: 999px; background: var(--red); color: #fff;
  font-size: .68rem; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
/* user menu (pure <details> dropdown — no JS needed) */
.user-menu { position: relative; }
.user-menu summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 6px 6px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); min-height: 44px;
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--surface-2); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 34px;
  background: var(--brand-primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem;
}
.user-menu .who { line-height: 1.2; }
.user-menu .who .n { font-weight: 650; font-size: .88rem; display: block; }
.user-menu .who .r { font-size: .72rem; color: var(--muted); display: block; }
.user-menu .drop {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 210px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px; z-index: 70;
}
.user-menu .drop a {
  display: block; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text); font-size: .92rem; min-height: 44px;
}
.user-menu .drop a:hover { background: var(--surface-2); text-decoration: none; }

/* Content */
.content { padding: 24px; width: 100%; max-width: 1280px; margin: 0 auto; }
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 18px; flex-wrap: wrap;
}
.page-head h1 { margin: 0; }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.footer {
  margin-top: auto; padding: 18px 24px; text-align: center;
  color: var(--faint); font-size: .78rem; border-top: 1px solid var(--border);
  background: var(--surface);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font-size: .93rem; font-weight: 650; font-family: var(--font);
  cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand-primary); color: #fff; }
.btn-primary:hover { background: var(--brand-primary-600); color: #fff; }
.btn-accent { background: var(--brand-secondary); color: #1a1405; }
.btn-accent:hover { background: var(--brand-secondary-600); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #991b1b; color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-outline { background: #fff; border-color: var(--brand-primary); color: var(--brand-primary); }
.btn-outline:hover { background: var(--brand-primary); color: #fff; }
.btn-sm { min-height: 38px; padding: 7px 12px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .55; cursor: not-allowed; }
.link-danger { color: var(--red); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  margin-bottom: 18px; overflow: hidden;
}
.card-pad { padding: 20px; }
.card-head {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface-2);
}
.card-head h3 { margin: 0; font-size: 1rem; }
.card-body { padding: 20px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }

/* Stat cards */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--brand-secondary);
}
.stat .label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 650; }
.stat .value { font-size: 1.65rem; font-weight: 750; margin: 4px 0 2px; letter-spacing: -0.02em; }
.stat .hint { font-size: .8rem; color: var(--muted); }
.stat.stat-navy { background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-600)); color: #fff; border: none; }
.stat.stat-navy .label, .stat.stat-navy .hint { color: rgba(255,255,255,.7); }
.stat.stat-gold::before { background: var(--brand-secondary); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; min-width: 640px; }
.table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2); text-align: left;
  padding: 12px 14px; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 700; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody td { padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #F8FAFD; }
.table .row-actions { white-space: nowrap; text-align: right; }
.table tfoot td { padding: 12px 14px; font-weight: 700; background: var(--surface-2); }
.table a.sort { color: var(--muted); }
.table a.sort:hover { color: var(--text); text-decoration: none; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px;
  font-size: .75rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap;
}
.b-green { background: var(--green-bg); color: var(--green); }
.b-amber { background: var(--amber-bg); color: var(--amber); }
.b-red { background: var(--red-bg); color: var(--red); }
.b-blue { background: var(--blue-bg); color: var(--blue); }
.b-gray { background: var(--gray-bg); color: var(--gray); }
.b-navy { background: var(--brand-primary); color: #fff; }
.b-gold { background: #FBF3DC; color: #8a6d1a; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 650; font-size: .88rem; margin-bottom: 6px; }
.form-group .req { color: var(--red); }
.form-control, input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="datetime-local"], input[type="tel"],
input[type="url"], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: .95rem; font-family: var(--font); color: var(--text); background: #fff;
}
textarea { min-height: 110px; resize: vertical; }
.form-control:focus, input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand-secondary); border-color: var(--brand-secondary);
}
.form-hint { font-size: .8rem; color: var(--muted); margin-top: 5px; }
.form-error { font-size: .83rem; color: var(--red); margin-top: 5px; font-weight: 600; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
fieldset.form-fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 0 0 18px; }
fieldset.form-fieldset legend { padding: 0 8px; font-weight: 700; font-size: .9rem; }
.checkbox-row { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.checkbox-row input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--brand-primary); }
.inline-form { display: inline; }

/* Filter bar */
.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 16px;
}
.filters .form-group { margin-bottom: 0; min-width: 150px; flex: 1 1 150px; }
.filters .btn { min-height: 44px; }

/* ---------- Alerts ---------- */
.alert {
  padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 16px;
  font-size: .92rem; border: 1px solid transparent;
  display: flex; gap: 10px; align-items: flex-start;
}
.alert-success { background: var(--green-bg); border-color: #BFE6CB; color: #14532D; }
.alert-error, .alert-danger { background: var(--red-bg); border-color: #F3C2C2; color: #7F1D1D; }
.alert-warning { background: var(--amber-bg); border-color: #F0D9A8; color: #78350F; }
.alert-info { background: var(--blue-bg); border-color: #BFD4F8; color: #1E3A8A; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 6px; align-items: center; justify-content: center; margin: 20px 0 6px; flex-wrap: wrap; }
.pagination a, .pagination span {
  min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: .9rem;
}
.pagination a:hover { background: var(--surface-2); text-decoration: none; }
.pagination .current { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }
.pagination .meta { border: none; background: none; color: var(--muted); font-weight: 500; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a {
  padding: 12px 16px; font-weight: 650; font-size: .92rem; color: var(--muted);
  border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; min-height: 44px;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--brand-primary); border-bottom-color: var(--brand-secondary); }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 9px; top: 8px; bottom: 8px; width: 2px; background: var(--border); }
.timeline li { position: relative; padding: 0 0 18px 34px; }
.timeline li::before {
  content: ""; position: absolute; left: 3px; top: 5px; width: 14px; height: 14px;
  border-radius: 50%; background: var(--surface); border: 3px solid var(--brand-secondary);
}
.timeline .t-time { font-size: .76rem; color: var(--faint); }
.timeline .t-title { font-weight: 650; }
.timeline .t-detail { font-size: .88rem; color: var(--muted); }

/* ---------- Key/value detail grid ---------- */
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 24px; }
.kv .k { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.kv .v { font-size: .98rem; font-weight: 600; margin-top: 2px; }

/* ---------- Modal (lite) ---------- */
.modal-backdrop {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 22, 40, .55); padding: 20px;
  align-items: flex-start; justify-content: center; overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px; margin: 8vh auto; overflow: hidden;
}
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: var(--surface-2); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--muted); width: 44px; height: 44px; }

/* ---------- Login / auth pages ---------- */
.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-600) 60%, #1d3350 100%);
}
.auth-card {
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 420px; padding: 36px 32px;
}
.auth-card .logo { text-align: center; margin-bottom: 18px; }
.auth-card .logo img { height: 56px; width: 56px; object-fit: contain; border-radius: 12px; }
.auth-card h1 { text-align: center; font-size: 1.35rem; margin-bottom: 4px; }
.auth-card .sub { text-align: center; color: var(--muted); font-size: .9rem; margin-bottom: 22px; }
.auth-card .btn-block { margin-top: 6px; }
.auth-links { text-align: center; margin-top: 16px; font-size: .88rem; }
.auth-foot { text-align: center; margin-top: 22px; font-size: .75rem; color: var(--faint); }

/* ---------- Empty states ---------- */
.empty {
  text-align: center; padding: 44px 20px; color: var(--muted);
  border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface);
}
.empty .big { font-size: 2.2rem; margin-bottom: 8px; }

/* ---------- Bottom nav (mobile) ---------- */
.bottomnav {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  height: var(--bottomnav-h); background: var(--surface);
  border-top: 1px solid var(--border); box-shadow: 0 -2px 12px rgba(16,24,40,.08);
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--muted); font-size: .68rem; font-weight: 600; min-height: var(--bottomnav-h);
}
.bottomnav a .ico { font-size: 1.3rem; }
.bottomnav a.active { color: var(--brand-primary); }
.bottomnav a:hover { text-decoration: none; }

/* ---------- Toast-ish dismissible alerts ---------- */
.alert[data-autodismiss] { transition: opacity .4s; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .content { padding: 18px 16px; }
  .form-row-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-105%); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .sidebar-backdrop { display: block; }
  .main { margin-left: 0; }
  .hamburger { display: inline-flex; align-items: center; justify-content: center; }
  .topbar-search { display: none; } /* search lives on list pages on mobile */
  .user-menu .who { display: none; }
}

@media (max-width: 768px) {
  body { padding-bottom: var(--bottomnav-h); }
  .bottomnav { display: flex; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 1.3rem; }
  .page-head .actions .btn { flex: 1 1 auto; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat .value { font-size: 1.35rem; }

  /* Tables -> labelled card rows. Pages must add data-label="..." on each <td>. */
  .table.responsive-cards { min-width: 0; }
  .table.responsive-cards thead { display: none; }
  .table.responsive-cards, .table.responsive-cards tbody,
  .table.responsive-cards tr, .table.responsive-cards td { display: block; width: 100%; }
  .table.responsive-cards tr {
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    margin-bottom: 10px; background: var(--surface); padding: 6px 0;
  }
  .table.responsive-cards tbody tr:hover { background: var(--surface); }
  .table.responsive-cards td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    border: none; border-bottom: 1px solid var(--border); padding: 10px 14px;
    text-align: right;
  }
  .table.responsive-cards td:last-child { border-bottom: none; }
  .table.responsive-cards td::before {
    content: attr(data-label); font-weight: 700; font-size: .78rem;
    text-transform: uppercase; letter-spacing: .04em; color: var(--muted); text-align: left;
  }
  .table.responsive-cards td.no-label::before { content: none; }
  .table.responsive-cards td.no-label { justify-content: flex-end; }
  .table.responsive-cards .row-actions { text-align: right; }
}

@media (max-width: 420px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .auth-card { padding: 28px 20px; }
}

/* ---------- Print ---------- */
@media print {
  .sidebar, .topbar, .bottomnav, .page-head .actions, .pagination, .footer { display: none !important; }
  .main { margin-left: 0; }
  body { background: #fff; padding-bottom: 0; }
  .card, .table-wrap { box-shadow: none; }
}

/* ==========================================================================
   POLISH PASS — premium-SaaS refinement (judged on a 360px phone)
   Spacing scale used throughout: 4 / 6 / 8 / 10 / 12 / 14 / 16 / 18 / 20 / 24 / 32 / 44
   (44px = minimum touch target; never smaller for anything tappable).
   ========================================================================== */

/* Crisp, consistent keyboard focus ring */
:focus-visible {
  outline: 2px solid var(--brand-secondary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Buttons: subtle depth on the primary action */
.btn-primary { box-shadow: 0 2px 10px -2px rgba(10, 22, 40, .40); }
.btn-accent  { box-shadow: 0 2px 10px -2px rgba(184, 146, 42, .55); }
.btn-primary:hover, .btn-accent:hover { box-shadow: 0 4px 14px -2px rgba(10, 22, 40, .35); }

/* Stat cards: lift on hover, tighter type */
.stat { transition: transform .16s ease, box-shadow .16s ease; }
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat .value { font-variant-numeric: tabular-nums; }
.stat .label { margin-bottom: 2px; }

/* Cards: slightly stronger separation on small screens */
.card { box-shadow: var(--shadow); }
.card-head h3 { display: flex; align-items: center; gap: 8px; }

/* Empty states: softer, more deliberate */
.empty { background: var(--surface-2); border-style: dashed; }
.empty .big { font-size: 2.4rem; margin-bottom: 10px; line-height: 1; }

/* Alerts: gentle shadow so they sit above content */
.alert { box-shadow: var(--shadow-sm); }

/* Table polish: row dividers breathe, header stays crisp */
.table tbody td { border-bottom-color: #EDF1F7; }
.table thead th { background: #F7F9FC; }

/* Demo countdown pill — subtle, sticky, fixed bottom-right (above the mobile
   bottom nav). Rendered by layout.php only when Demo::bannerInfo() is non-null. */
.demo-pill {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 36px);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(10, 22, 40, .92);
  color: #fff;
  border: 1px solid rgba(184, 146, 42, .55);
  box-shadow: 0 6px 20px -4px rgba(10, 22, 40, .45);
  font-size: .78rem;
  font-weight: 650;
  letter-spacing: .01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.demo-pill-dot {
  width: 8px; height: 8px; flex: 0 0 8px;
  border-radius: 50%;
  background: var(--brand-secondary);
  box-shadow: 0 0 6px var(--brand-secondary);
}
.demo-pill.expired { background: rgba(185, 28, 28, .94); border-color: rgba(255, 255, 255, .35); }
.demo-pill.expired .demo-pill-dot { background: #fff; box-shadow: none; }
@media (max-width: 768px) {
  .demo-pill {
    right: 12px;
    bottom: calc(var(--bottomnav-h) + 10px); /* clears the mobile bottom nav */
    font-size: .72rem;
    padding: 7px 12px;
  }
}

/* Auth card: entrance motion + brand accent bar */
.auth-card {
  position: relative;
  overflow: hidden;
  animation: authRise .45s cubic-bezier(.2, .7, .3, 1);
}
.auth-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--brand-secondary), #E3C565 50%, var(--brand-secondary));
}
@keyframes authRise {
  from { opacity: 0; transform: translateY(16px) scale(.99); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .auth-card { animation: none; }
  .sidebar { transition: none; }
  .stat:hover { transform: none; }
}

/* Modal entrance */
.modal-backdrop.open .modal { animation: authRise .28s cubic-bezier(.2, .7, .3, 1); }

/* Sidebar links: smoother hover */
.nav-link { transition: background .14s ease, color .14s ease; }

/* 360px-specific tightening */
@media (max-width: 400px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .content { padding: 14px 12px; }
  .card-pad, .card-body { padding: 16px; }
  .page-head { margin-bottom: 14px; }
  .stat { padding: 13px; }
  .stat .value { font-size: 1.25rem; }
}

/* ---------- Permission matrix (per-user overrides) ---------- */
.perm-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 4px; border-bottom: 1px solid var(--border); min-height: 48px;
}
.perm-row:last-child { border-bottom: none; }
.perm-name { font-weight: 600; font-size: .92rem; }
.perm-opts { display: flex; gap: 6px; flex-wrap: wrap; }
.perm-opt {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .8rem; font-weight: 600; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 12px; cursor: pointer; min-height: 36px;
  transition: all .12s ease;
}
.perm-opt input { accent-color: var(--brand-primary); width: 16px; height: 16px; margin: 0; }
.perm-opt:has(input:checked) { border-color: var(--brand-primary); color: var(--brand-primary); background: #F0F4FA; }
.perm-opt.perm-grant:has(input:checked) { border-color: var(--green); color: var(--green); background: var(--green-bg); }
.perm-opt.perm-deny:has(input:checked) { border-color: var(--red); color: var(--red); background: var(--red-bg); }
@media (max-width: 640px) {
  .perm-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .perm-opts { display: grid; grid-template-columns: 1fr 1fr 1fr; }
  .perm-opt { justify-content: center; }
}
