/* ─── Design tokens ─────────────────────────────────────────────────────── */
:root {
  --bg-1:     #060913;
  --bg-2:     #0f1629;
  --glass:    rgba(255,255,255,0.06);
  --glass-hov:rgba(255,255,255,0.10);
  --stroke:   rgba(255,255,255,0.14);
  --text:     #e4f0ff;
  --muted:    #8aa0c0;
  --primary:  #4db6ff;
  --success:  #39d98a;
  --danger:   #ff6b7a;
  --warning:  #f5c451;
  --radius:   14px;
  --shadow:   0 16px 40px rgba(0,0,0,0.4);
  --sidebar-w:268px;
}

/* ─── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: "Segoe UI", "Inter", system-ui, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 12% 8%, #1a2e5a 0%, var(--bg-1) 45%, var(--bg-2) 100%);
  min-height: 100vh;
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: monospace; font-size: 0.85em; color: var(--primary); }
hr.detail-hr { border: none; border-top: 1px solid var(--stroke); margin: 8px 0; }

/* ─── App shell ─────────────────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ─── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
  border-right: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(77,182,255,0.08) 0%, rgba(10,16,30,0.90) 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 18px;
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-logo-icon {
  flex-shrink: 0;
  border-radius: 11px;
  box-shadow: 0 4px 16px rgba(77,182,255,0.35);
  display: block;
}
.brand-logo-full {
  display: block;
  width: 100%;
  max-width: 200px;
  height: auto;
  max-height: 60px;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(77,182,255,0.3));
}
.brand-name {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.brand-sub {
  display: block;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
/* Legacy fallback (kept in case old markup is referenced elsewhere) */
.brand-mark {
  width: 42px; height: 42px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(145deg, #2f7dff, #4db6ff);
  color: #fff; font-weight: 700; font-size: 13px;
  display: grid; place-items: center;
  box-shadow: 0 4px 16px rgba(77,182,255,0.4);
}
.brand h1 { font-size: 15px; font-weight: 700; color: var(--text); }
.brand p  { font-size: 11px; color: var(--muted); }

.menu { display: grid; gap: 3px; flex: 1; }
.menu-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border-radius: 10px;
  color: #c8d8f0;
  background: transparent;
  border: 1px solid transparent;
  font-size: 13.5px;
  transition: background 0.15s, border-color 0.15s;
}
.menu-icon { font-size: 15px; width: 20px; text-align: center; }
.menu-link:hover { background: var(--glass-hov); text-decoration: none; }
.menu-link.active {
  background: rgba(77,182,255,0.18);
  border-color: rgba(77,182,255,0.35);
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--stroke);
  padding-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(145deg, #2f7dff, #4db6ff);
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--muted); }
.logout-btn {
  margin-left: auto;
  color: var(--muted);
  font-size: 16px;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color 0.15s;
}
.logout-btn:hover { color: var(--danger); text-decoration: none; }

/* ─── Main area ─────────────────────────────────────────────────────────── */
.main-area { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }

/* ─── Topbar ────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
}
.topbar-title h2 { font-size: 18px; font-weight: 700; }
.topbar-title p  { font-size: 11px; color: var(--muted); }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.mobile-menu-btn { display: none; }

/* ─── Glass card ────────────────────────────────────────────────────────── */
.glass {
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.card { padding: 18px; }
.card h3 { font-size: 15px; margin-bottom: 14px; color: var(--text); }
.muted { color: var(--muted); font-size: 13px; }

/* ─── Page content ──────────────────────────────────────────────────────── */
.page-content { display: flex; flex-direction: column; gap: 16px; }

/* ─── Stat cards ────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}
.stat-card {
  padding: 16px 18px;
  border-radius: var(--radius);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
a.stat-card:hover { transform: translateY(-2px); border-color: rgba(77,182,255,0.4); }
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; }

/* ─── Two-column grid ───────────────────────────────────────────────────── */
.grid-two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ─── Snapshot items ────────────────────────────────────────────────────── */
.snapshot-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 10px; margin-bottom: 12px; }
.snapshot-item { text-align: center; padding: 12px 8px; border-radius: 10px; background: var(--glass); border: 1px solid var(--stroke); }
.snapshot-val  { font-size: 24px; font-weight: 700; }
.snapshot-lbl  { font-size: 11px; color: var(--muted); margin-top: 2px; }
.snapshot-link { display: block; text-decoration: none; transition: border-color 0.15s, transform 0.12s; cursor: pointer; }
.snapshot-link:hover { border-color: rgba(77,182,255,0.5); transform: translateY(-2px); text-decoration: none; }
.snapshot-item.overdue .snapshot-val      { color: var(--danger); }
.snapshot-item.partial .snapshot-val      { color: var(--warning); }
.snapshot-item.paid .snapshot-val         { color: var(--success); }
.snapshot-item.advance-paid .snapshot-val { color: var(--primary); }
.snapshot-item.upcoming .snapshot-val     { color: var(--muted); }

/* ─── Notifications list ────────────────────────────────────────────────── */
.notif-list { list-style: none; display: grid; gap: 8px; }
.notif-list li { padding: 8px 10px; border-radius: 8px; background: var(--glass); border: 1px solid var(--stroke); font-size: 13px; }
.notif-list li strong { display: block; }
.notif-list li small  { color: var(--muted); }

/* ─── Forms ─────────────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  gap: 12px;
}
.form-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.form-inline .field-group { flex: 1; min-width: 160px; }

.field-group { display: flex; flex-direction: column; gap: 4px; }
.field-group label,
label { font-size: 11px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.field-hint { font-size: 11px; color: var(--muted); margin-top: 2px; }
.field-hint-box { justify-content: center; }
.hint-value { font-size: 18px; font-weight: 700; color: var(--primary); }

input, select, textarea {
  font: inherit;
  border-radius: 9px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(8,13,28,0.70);
  color: var(--text);
  padding: 9px 12px;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(77,182,255,0.6);
  box-shadow: 0 0 0 3px rgba(77,182,255,0.15);
}
input:disabled, select:disabled { opacity: 0.5; cursor: not-allowed; }

.form-actions { display: flex; gap: 10px; align-items: center; padding-top: 4px; }

/* ─── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 8px 14px;
  border-radius: 9px;
  color: var(--text);
  background: rgba(255,255,255,0.09);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  white-space: nowrap;
  transition: filter 0.15s, background 0.15s;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.1); text-decoration: none; }
.btn-primary { background: linear-gradient(145deg, #2060e0, #4db6ff); border: none; color: #fff; }
.btn-danger  { background: linear-gradient(145deg, #c0283c, #ff6b7a); border: none; color: #fff; }
.btn-sm      { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-block   { width: 100%; }

/* ─── Badges ────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; border-radius: 999px;
  padding: 3px 10px; font-size: 11px; font-weight: 600;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.22);
}
.badge.overdue, .badge.status-overdue { background: rgba(255,107,122,0.18); border-color: rgba(255,107,122,0.4); color: #ffb3bc; }
.badge.partial                        { background: rgba(245,196,81,0.18);  border-color: rgba(245,196,81,0.4);  color: #fde8a0; }
.badge.paid                           { background: rgba(57,217,138,0.18);  border-color: rgba(57,217,138,0.4);  color: #a2f0cc; }
.badge.advance-paid                   { background: rgba(77,182,255,0.18);  border-color: rgba(77,182,255,0.4);  color: #a8d8ff; }
.badge.upcoming                       { background: rgba(255,255,255,0.10); }
.badge.status-vacant                  { background: rgba(57,217,138,0.15);  border-color: rgba(57,217,138,0.35); color: #a2f0cc; }
.badge.status-occupied                { background: rgba(255,107,122,0.15); border-color: rgba(255,107,122,0.35); color: #ffb3bc; }
.badge.status-maintenance             { background: rgba(245,196,81,0.15);  border-color: rgba(245,196,81,0.35);  color: #fde8a0; }

/* ─── Alerts ────────────────────────────────────────────────────────────── */
.alert {
  padding: 11px 14px; border-radius: 10px;
  border: 1px solid transparent; font-size: 13.5px;
}
.alert-success { background: rgba(57,217,138,0.12); border-color: rgba(57,217,138,0.3); }
.alert-error   { background: rgba(255,107,122,0.12); border-color: rgba(255,107,122,0.3); }

/* ─── Tables ────────────────────────────────────────────────────────────── */
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid rgba(255,255,255,0.07); }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
tr:hover td { background: rgba(255,255,255,0.03); }
.actions-cell { white-space: nowrap; }
/* Row actions sit on one line with a real gap. Without this the anchors are
   plain inline elements and wrap onto a line each in a narrow column. */
.actions-cell { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }
.actions-cell .btn { flex: 0 0 auto; }
/* Receipt numbers are long and hyphenated, so a narrow column broke them across
   three lines; keep them intact and let the column size to them. */
.receipt-no { white-space: nowrap; }
.receipt-no code { font-size: 11.5px; }
/* Short, self-contained values (dates, building/room) that read badly when
   broken across lines in a narrow table. */
td.nowrap { white-space: nowrap; }
/* Keep row content aligned with the action buttons rather than floating above
   them when a neighbouring cell is taller. */
.table-wrap table td { vertical-align: middle; }

/* ─── Receipt detail ────────────────────────────────────────────────────── */
.receipt-detail { font-size: 13.5px; }
.receipt-detail p { margin: 5px 0; }
.receipt-detail strong { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; display: inline-block; min-width: 130px; }

/* ─── Auth pages ────────────────────────────────────────────────────────── */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 440px; padding: 28px; }

/* Logo on auth pages */
.auth-brand     { display: flex; justify-content: center; margin-bottom: 20px; }
.auth-logo      { display: block; max-width: 200px; height: auto; }
.auth-title     { font-size: 22px; font-weight: 700; margin: 0 0 4px; text-align: center; }
.auth-subtitle  { color: var(--muted); font-size: 13px; margin: 0 0 18px; text-align: center; }

.auth-card .form-grid { margin: 8px 0 16px; }
.auth-card .form-grid label { color: var(--muted); font-size: 12px; }
.auth-link { text-align: center; margin-top: 14px; font-size: 13px; color: var(--muted); }

/* ─── Print ─────────────────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .btn, .alert, .mobile-menu-btn, .no-print { display: none !important; }
  .app-shell { grid-template-columns: 1fr; }
  body { background: #fff; color: #000; }
  .glass, .card, .stat-card { border: 1px solid #ccc; box-shadow: none; background: #fff; }
}

/* ─── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .grid-two       { grid-template-columns: 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr 1fr; }
  .form-grid.cols-4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: -300px;
    height: 100vh; width: 268px;
    z-index: 1000;
    transition: left 0.22s ease;
  }
  .sidebar.open { left: 0; }
  .mobile-menu-btn {
    display: inline-flex;
    background: rgba(255,255,255,0.12);
    color: var(--text);
    border: 1px solid rgba(255,255,255,0.22);
    padding: 8px 11px;
    border-radius: 9px;
    cursor: pointer;
    font-size: 18px;
  }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid.cols-2,
  .form-grid.cols-3,
  .form-grid.cols-4 { grid-template-columns: 1fr; }

  /* Phase 5.2: larger touch targets on the highest-traffic field/mobile screens */
  .btn { min-height: 40px; padding: 9px 16px; }
  .btn-sm { min-height: 34px; }

  /* Phase 5.2: card-based responsive tables (opt-in via .table-responsive-cards
     on the <table>, with data-label="..." on each <td>) — turns a wide table
     into a stack of labelled key/value cards instead of horizontal-scrolling.
     Applied only to the highest-traffic field tables; every other table keeps
     the existing .table-wrap horizontal-scroll behavior unchanged. */
  .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 {
    background: var(--glass);
    border: 1px solid var(--stroke);
    border-radius: 12px;
    margin-bottom: 10px;
    padding: 8px 12px;
  }
  .table-responsive-cards tr:hover td { background: transparent; }
  .table-responsive-cards td {
    border-bottom: 1px solid rgba(255,255,255,0.06);
    padding: 7px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    text-align: right;
  }
  .table-responsive-cards td:last-child { border-bottom: none; }
  .table-responsive-cards td::before {
    content: attr(data-label);
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    text-align: left;
    flex-shrink: 0;
  }
  .table-responsive-cards td.actions-cell { justify-content: flex-end; }
  .table-responsive-cards td.actions-cell::before { display: none; }
}

@media (max-width: 480px) {
  .main-area { padding: 14px 12px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .snapshot-grid { grid-template-columns: 1fr; }
}

/* ─── Report period filter ─────────────────────────────────────── */
/* One row of controls that wraps on narrow screens; the month/year/range inputs
   are shown or hidden by the page script depending on the chosen period type. */
.report-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}
.report-filter .field { margin: 0; min-width: 150px; }
.report-filter .field > span {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 4px;
}
.report-filter .filter-actions { display: flex; gap: 8px; min-width: 0; }

/* Summary row at the foot of a report table. */
tr.highlight td { background: var(--glass-hov); border-top: 1px solid var(--stroke); }

@media (max-width: 640px) {
  .report-filter .field { min-width: 100%; }
  .report-filter .filter-actions { width: 100%; }
}

/* ─── Breadcrumbs ───────────────────────────────────────────────────────────── */
.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 14px;
}
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--primary); text-decoration: none; }
.breadcrumbs .sep { opacity: 0.6; }

/* ─── Phase 2: filter bar / live search ─────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 14px;
}
.filter-bar .field-group { min-width: 150px; margin-bottom: 0; }
.filter-bar .field-group.grow { flex: 1; min-width: 220px; }
.search-live { position: relative; }
.search-live input { padding-right: 30px; }
.search-live::after {
  content: "🔍";
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 12px; opacity: 0.6; pointer-events: none;
}

/* ─── Phase 2: pagination ────────────────────────────────────────────────────── */
.pagination { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; align-items: center; }
.pagination a.btn, .pagination span.btn { min-width: 34px; text-align: center; padding: 6px 10px; }
.pagination .btn.active { background: var(--primary); border-color: var(--primary); color: #06121f; font-weight: 700; }
.pagination .btn.disabled { opacity: 0.4; pointer-events: none; }
.pagination-info { color: var(--muted); font-size: 12px; margin-right: 8px; }

/* ─── Phase 2: bulk-select cell ──────────────────────────────────────────────── */
.select-cell { width: 34px; text-align: center; }

/* ─── Phase 2: tabs (profile pages) ──────────────────────────────────────────── */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--stroke); margin-bottom: 16px; }
.tab-link {
  padding: 9px 14px; font-size: 13px; color: var(--muted);
  border: 1px solid transparent; border-bottom: none;
  border-radius: 10px 10px 0 0; background: transparent;
}
.tab-link:hover { color: var(--text); text-decoration: none; }
.tab-link.active { color: var(--text); background: var(--glass); border-color: var(--stroke); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── Phase 2: profile header ────────────────────────────────────────────────── */
.profile-header { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin-bottom: 4px; }
.profile-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #2a6fd6);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: #06121f; flex-shrink: 0;
}
.profile-meta { display: flex; flex-direction: column; gap: 2px; }
.profile-meta h2 { font-size: 19px; }
.profile-meta .muted { font-size: 12.5px; }
.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.stat-mini { background: var(--glass); border: 1px solid var(--stroke); border-radius: 10px; padding: 10px 12px; }
.stat-mini .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.stat-mini .val { font-size: 17px; font-weight: 700; margin-top: 2px; }

/* ─── Phase 2: activity timeline ─────────────────────────────────────────────── */
.timeline { list-style: none; display: flex; flex-direction: column; gap: 0; }
.timeline li {
  position: relative; padding: 10px 0 10px 22px; border-left: 2px solid var(--stroke);
  font-size: 13px;
}
.timeline li::before {
  content: ""; position: absolute; left: -6px; top: 14px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--primary); border: 2px solid var(--bg-2);
}
.timeline li:last-child { border-left-color: transparent; }
.timeline .t-when { color: var(--muted); font-size: 11.5px; }

/* ─── Phase 2: document cards ────────────────────────────────────────────────── */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.doc-card {
  background: var(--glass); border: 1px solid var(--stroke); border-radius: 10px;
  padding: 10px; font-size: 12px; display: flex; flex-direction: column; gap: 6px;
}
.doc-card .doc-icon { font-size: 26px; }
.doc-card .doc-name { word-break: break-word; font-weight: 600; }
.doc-card .doc-meta { color: var(--muted); font-size: 11px; }

/* ─── Phase 2: modal (native <dialog>) ───────────────────────────────────────── */
dialog.modal {
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: var(--bg-2);
  color: var(--text);
  padding: 20px;
  width: min(560px, 92vw);
  box-shadow: var(--shadow);
}
dialog.modal::backdrop { background: rgba(4,8,18,0.65); backdrop-filter: blur(2px); }
dialog.modal h3 { margin-bottom: 12px; }
dialog.modal .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ─── Phase 2: import preview ────────────────────────────────────────────────── */
.import-row-error { background: rgba(255,107,122,0.10); }
.import-row-ok { background: rgba(57,217,138,0.06); }

/* ─── Phase 2: key/value detail table (profile pages) ───────────────────────── */
.detail-table { width: 100%; border-collapse: collapse; }
.detail-table th, .detail-table td { text-align: left; padding: 7px 6px; font-size: 13px; border-bottom: 1px solid var(--stroke); }
.detail-table th { width: 38%; color: var(--muted); font-weight: 500; text-transform: none; letter-spacing: normal; }
.detail-table tr:last-child th, .detail-table tr:last-child td { border-bottom: none; }

/* ─── Phase 6: quick action cards ────────────────────────────────────────────── */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}
.quick-action-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 14px;
  border-radius: var(--radius);
  text-align: center;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.quick-action-card:hover { transform: translateY(-3px); border-color: rgba(77,182,255,0.5); text-decoration: none; }
.quick-action-icon { font-size: 26px; }
.quick-action-label { font-size: 13px; font-weight: 600; }

/* ─── Phase 6: misc utility ──────────────────────────────────────────────────── */
.hidden { display: none !important; }
.checkbox-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; text-transform: none; letter-spacing: normal;
  color: var(--text); cursor: pointer;
}
.checkbox-label input[type="checkbox"] { width: auto; }
.input-with-action { display: flex; gap: 6px; align-items: center; }
.input-with-action input { flex: 1; }
.input-action-btn {
  flex-shrink: 0; padding: 8px 12px; font-size: 12px;
  border-radius: 9px; border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.09); color: var(--text); cursor: pointer;
}
.input-action-btn:hover { filter: brightness(1.1); }
.breadcrumbs .current { color: var(--text); font-weight: 600; }

/* ─── Phase 5.2: Field Operations components ─────────────────────────────── */
.field-card { padding: 16px; }
.field-dash-header { padding: 4px 2px; }

.field-status-banner {
  padding: 10px 14px; border-radius: 10px; font-size: 13px; font-weight: 600;
  margin-bottom: 12px; background: rgba(77,182,255,0.15); border: 1px solid rgba(77,182,255,0.35);
}
.field-status-banner.success { background: rgba(57,217,138,0.15); border-color: rgba(57,217,138,0.4); }
.field-status-banner.error   { background: rgba(255,107,122,0.15); border-color: rgba(255,107,122,0.4); }
.field-status-banner.warn    { background: rgba(245,196,81,0.15); border-color: rgba(245,196,81,0.4); }

.field-meter-list { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; }
.field-meter-item {
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  padding: 12px 14px; min-height: 44px;
  border-radius: 12px; border: 1px solid var(--stroke); background: var(--glass);
  color: var(--text); font: inherit; cursor: pointer;
}
.field-meter-item:hover, .field-meter-item:active { border-color: rgba(77,182,255,0.5); background: var(--glass-hov); }
.field-meter-item strong { font-size: 14px; }
.field-meter-item .muted { font-size: 12px; }

.field-selected-card {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 14px; border-radius: 12px; background: rgba(77,182,255,0.12);
  border: 1px solid rgba(77,182,255,0.35); margin-bottom: 14px;
}

.field-photo-preview {
  display: block; max-width: 220px; max-height: 220px; border-radius: 10px;
  margin: 8px 0; border: 1px solid var(--stroke);
}

.field-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.field-touch-btn { min-height: 46px; font-size: 15px; }

.field-pending-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.field-pending-item {
  display: flex; align-items: center; gap: 10px; padding: 10px;
  border-radius: 10px; border: 1px solid var(--stroke); background: var(--glass);
}
.field-pending-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.field-pending-info { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }

.field-sync-summary { display: flex; gap: 18px; flex-wrap: wrap; margin: 10px 0; }
.field-sync-summary > div { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.field-sync-summary .muted { text-transform: uppercase; letter-spacing: 0.04em; font-size: 10.5px; }

@media (max-width: 480px) {
  .field-meter-list { max-height: 50vh; }
}

/* ─── Construction module ───────────────────────────────────────────────────── */
.badge.con-status-planning  { background: rgba(255,255,255,0.10); }
.badge.con-status-active    { background: rgba(57,217,138,0.18);  border-color: rgba(57,217,138,0.4);  color: var(--success); }
.badge.con-status-on_hold   { background: rgba(245,196,81,0.18);  border-color: rgba(245,196,81,0.4);  color: var(--warning); }
.badge.con-status-completed { background: rgba(77,182,255,0.18);  border-color: rgba(77,182,255,0.4);  color: var(--primary); }
.badge.con-status-archived  { background: transparent; color: var(--muted); }

.con-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.con-head h3 { margin: 0; font-size: 17px; }
.con-head .spacer { flex: 1; }
.con-money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-value.con-money { font-size: 22px; }
.stat-note { font-size: 11px; color: var(--muted); margin-top: 2px; }

.con-kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.con-kv dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.con-kv dd { font-size: 14px; margin-top: 2px; overflow-wrap: anywhere; }
.con-prose { white-space: pre-line; font-size: 14px; overflow-wrap: anywhere; }

.con-empty { text-align: center; padding: 34px 18px; }
.con-empty p { color: var(--muted); max-width: 46ch; margin: 6px auto 16px; }

details.con-details > summary { cursor: pointer; font-size: 15px; font-weight: 600; list-style-position: inside; }
details.con-details[open] > summary { margin-bottom: 14px; }

.con-change { font-size: 12px; overflow-wrap: anywhere; }
.con-change del { color: var(--danger); text-decoration: none; }
.con-change ins { color: var(--success); text-decoration: none; }

/* ─── Phone: keep the top bar inside the screen ─────────────────────────────── */
/* The top bar's buttons and user name were wider than a phone and, because a grid
   column will not shrink below its content, pushed every page sideways. */
@media (max-width: 860px) {
  .main-area { min-width: 0; }
  .topbar { gap: 8px; }
  .topbar-title { min-width: 0; flex: 1; }
  .topbar-title h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-user { margin-left: 0; flex-shrink: 0; }
  .topbar-user > span { display: none; }   /* name is already in the sidebar footer */
  .filter-bar .field-group, .form-inline .field-group { min-width: 0; flex-basis: 100%; }
}
/* Money figures do not wrap, so two-up cards are too narrow for them on a phone. */
@media (max-width: 560px) {
  .stats-grid.con-stats { grid-template-columns: 1fr; }
}
/* A short menu (the construction section) should sit at the top, not stretch. */
.menu { align-content: start; }

/* Install-the-app prompt (assets/js/pwa.js) */
[hidden] { display: none !important; }
.pwa-banner {
  position: fixed; z-index: 1000; left: 16px; right: 16px; bottom: 16px; margin: 0 auto; max-width: 560px;
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px;
  background: rgba(15,22,41,0.97); border: 1px solid rgba(77,182,255,0.45); box-shadow: 0 12px 32px rgba(0,0,0,0.45);
  animation: pwa-up .25s ease-out;
}
.pwa-banner-icon { width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0; }
.pwa-banner-text { flex: 1; min-width: 0; display: grid; gap: 2px; font-size: 13px; }
.pwa-banner-text span { color: var(--muted); line-height: 1.4; }
.pwa-banner-actions { display: flex; gap: 6px; flex-shrink: 0; }
.pwa-share { display: inline-block; padding: 0 3px; border: 1px solid var(--stroke); border-radius: 4px; font-size: 11px; }
@keyframes pwa-up { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 480px) {
  .pwa-banner { flex-wrap: wrap; }
  .pwa-banner-actions { width: 100%; justify-content: flex-end; }
}
/* Installed app on iPhone: keep content clear of the status bar and home bar. */
@media (display-mode: standalone) {
  body { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
}
