/* Brotherhood Aid Vehicle Manager: app styles (clean & neutral) */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e3e6eb;
  --border-strong: #cfd4dc;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --accent: #2f5bd3;
  --accent-hover: #2449b3;
  --accent-soft: #eef2fd;
  --danger: #c0362c;
  --danger-soft: #fdf0ef;
  --warn: #a15c07;
  --warn-soft: #fff7e6;
  --ok: #157347;
  --ok-soft: #eaf6ef;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, .08);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 24px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; letter-spacing: 0.01em; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- top bar ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 1160px; margin: 0 auto; padding: 0 20px;
  height: 60px; display: flex; align-items: center; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); min-width: 0; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px; flex: none;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 14.5px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { display: flex; gap: 2px; height: 100%; }
.nav a {
  display: flex; align-items: center; padding: 0 12px;
  color: var(--muted); font-size: 14px; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a.active { color: var(--text); border-bottom-color: var(--accent); }

.user-menu { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.user-chip {
  display: flex; align-items: center; gap: 8px; color: var(--text-2);
  font-size: 13.5px; padding: 5px 8px; border-radius: var(--radius-sm);
}
.user-chip:hover { background: var(--surface-2); text-decoration: none; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 600; font-size: 12px; text-transform: uppercase;
}
.btn.menu-toggle { display: none; }

/* ---------- layout ---------- */
.container { width: 100%; max-width: 1160px; margin: 0 auto; padding: 28px 20px 64px; flex: 1; }
.container.narrow { max-width: 720px; }
.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.page-head p { margin-top: 4px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.breadcrumb a { color: var(--muted); }
.page-footer { text-align: center; font-size: 12px; color: var(--muted); padding: 18px; }

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.panel-head p { margin-top: 2px; }
.panel-body { padding: 18px; }
.panel-body > * + * { margin-top: 14px; }
.panel.empty { text-align: center; padding: 48px 20px; }
.panel.empty p { margin-bottom: 16px; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }

/* ---------- flash ---------- */
.flash {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 16px;
  font-size: 14px; border: 1px solid;
}
.flash-success { background: var(--ok-soft); border-color: #bfe3cd; color: #0f5132; }
.flash-error { background: var(--danger-soft); border-color: #f1c6c2; color: #8a231b; }
.flash-info { background: var(--accent-soft); border-color: #cdd8f7; color: #1f3d8f; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px;
  font: inherit; font-size: 14px; font-weight: 550; line-height: 1;
  color: var(--text-2); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  cursor: pointer; white-space: nowrap; box-shadow: var(--shadow);
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; border-color: #b8bfca; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(47, 91, 211, .25); outline-offset: 1px;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--text); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: #eab0ab; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }
form.inline { display: inline; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-weight: 550; font-size: 12px; color: var(--muted);
  padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fbfcfd; }
td.actions { text-align: right; white-space: nowrap; }
td.actions > * + * { margin-left: 4px; }
th.check, td.check { width: 40px; padding-right: 0; }
.cell-title { font-weight: 550; color: var(--text); }
.cell-sub { font-size: 12.5px; color: var(--muted); }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 550; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-active { background: var(--ok-soft); color: var(--ok); border-color: #c8e6d4; }
.badge-expiring { background: var(--warn-soft); color: var(--warn); border-color: #f5dcae; }
.badge-expired { background: var(--danger-soft); color: var(--danger); border-color: #f1c6c2; }
.badge-plain::before { display: none; }

/* ---------- dashboard ---------- */
.search-hero {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.search-hero h1 { margin-bottom: 4px; }
.search-form { display: flex; gap: 8px; margin-top: 14px; }
.search-input { position: relative; flex: 1; }
.search-input svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.search-input input { padding-left: 38px !important; height: 44px; font-size: 15px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); color: var(--text); display: block;
}
a.stat:hover { border-color: var(--border-strong); text-decoration: none; }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat-number { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat.warn .stat-number { color: var(--warn); }
.stat.bad .stat-number { color: var(--danger); }

/* ---------- forms ---------- */
.field { display: block; }
.field + .field, .form-row + .field, .field + .form-row, .form-row + .form-row { margin-top: 14px; }
.field > span, .label { display: block; font-size: 13px; font-weight: 550; color: var(--text-2); margin-bottom: 5px; }
.help { display: block; font-size: 12.5px; color: var(--muted); margin-top: 4px; font-weight: 400; }
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=search], input[type=tel], select, textarea {
  width: 100%; font: inherit; font-size: 14.5px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 8px 11px; min-height: 38px; box-shadow: var(--shadow);
  transition: border-color .12s;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(47, 91, 211, .15); }
input.mono { font-family: var(--mono); text-transform: uppercase; }
input[type=color] {
  width: 44px; height: 38px; padding: 3px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); cursor: pointer;
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.form-row > .field + .field { margin-top: 0; }
.form-actions {
  display: flex; gap: 10px; align-items: center;
  padding: 14px 18px; border-top: 1px solid var(--border); background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}
.form-actions .spacer { flex: 1; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 14px; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.input-unit { position: relative; }
.input-unit input { padding-right: 34px; }
.input-unit em { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 12.5px; color: var(--muted); pointer-events: none; }

.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: block; padding: 7px 12px; font-size: 13.5px; font-weight: 500; color: var(--muted);
  cursor: pointer; border-right: 1px solid var(--border); white-space: nowrap;
}
.segmented label:last-child span { border-right: 0; }
.segmented input:checked + span { background: var(--accent-soft); color: var(--accent); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

.policy-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px;
  background: var(--accent-soft); color: #1f3d8f; border-radius: var(--radius-sm); font-size: 13.5px;
}

/* ---------- settings ---------- */
.settings-layout { display: grid; grid-template-columns: 200px 1fr; gap: 28px; align-items: start; }
.tabs { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 84px; }
.tabs a {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 14px; font-weight: 500;
}
.tabs a svg { width: 17px; height: 17px; color: var(--muted); }
.tabs a:hover { background: #eceef2; text-decoration: none; }
.tabs a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); border: 1px solid var(--border); }
.tabs a.active svg { color: var(--accent); }
.tabs hr { border: 0; border-top: 1px solid var(--border); margin: 8px 4px; width: auto; }

.designer { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px); gap: 20px; align-items: start; }
.preview-col { position: sticky; top: 84px; }
.preview-stage {
  background: repeating-conic-gradient(#eef0f3 0% 25%, #f6f7f9 0% 50%) 50% / 16px 16px;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px 16px; display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.preview-label { font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); align-self: flex-start; margin-left: 4px; }
.preview-zoom { zoom: 1.2; }

.section-title { display: flex; align-items: center; gap: 10px; margin: 6px 0 2px; }
.section-title h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.section-title::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

.layout-card { scroll-margin-top: 84px; }
.layout-card .panel-head h2 { display: flex; align-items: center; gap: 8px; }
.panel-head h2 svg { width: 18px; height: 18px; color: var(--muted); }
.callout {
  font-size: 13.5px; color: var(--text-2); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px;
}
.callout ol, .callout ul { margin: 6px 0 0; padding-left: 20px; }
.callout li + li { margin-top: 3px; }
.nudge-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: start; }
.nudge-grid > .field + .field { margin-top: 0; }
.form-row { align-items: start; }

/* mini sheet diagram on printing tab */
.sheet-diagram { border: 1px solid var(--border-strong); background: #fff; position: relative; box-shadow: var(--shadow); }
.sheet-diagram .slot { position: absolute; background: var(--accent-soft); border: 1px solid #b9c7f2; border-radius: 2px; }
.sheet-diagram .slot b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 10px; color: var(--accent); font-weight: 600; }

/* ---------- batch ---------- */
.toolbar-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.toolbar-row .grow { flex: 1; min-width: 180px; }
.chip-group { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font: inherit; font-size: 13px; font-weight: 500; height: 30px; padding: 0 11px;
  border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-2); cursor: pointer;
}
.chip:hover { background: var(--surface-2); }
.chip.active { background: var(--text); border-color: var(--text); color: #fff; }
.print-bar {
  position: sticky; bottom: 0; z-index: 10;
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 12px 14px; margin-top: 16px;
}
.print-bar .count { font-weight: 600; }
.print-bar select { width: auto; }
.print-bar .spacer { flex: 1; }

summary.btn { list-style: none; }
summary.btn::-webkit-details-marker { display: none; }
.reset-pop {
  margin-top: 8px; width: 250px; padding: 12px; text-align: left; white-space: normal;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}

/* ---------- auth ---------- */
.auth-wrap { flex: 1; display: grid; place-items: center; padding: 40px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand { justify-content: center; margin-bottom: 22px; }
.auth-card .panel-body { padding: 24px; }

/* ---------- member detail ---------- */
.member-meta { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: 14px; margin-top: 6px; }
.member-meta span { display: inline-flex; align-items: center; gap: 6px; }
.member-meta svg { width: 15px; height: 15px; }
.danger-zone { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .designer { grid-template-columns: 1fr; }
  .preview-col { position: static; order: -1; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .topbar-inner { gap: 12px; height: 56px; }
  .btn.menu-toggle { display: inline-flex; margin-left: auto; }
  .nav, .user-menu { display: none; }
  .topbar.open .topbar-inner { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 10px; }
  .topbar.open .nav { display: flex; flex-direction: column; width: 100%; order: 3; }
  .topbar.open .nav a { padding: 10px 4px; border-bottom: 0; }
  .topbar.open .nav a.active { color: var(--accent); }
  .topbar.open .user-menu { display: flex; width: 100%; order: 4; margin: 0; border-top: 1px solid var(--border); padding-top: 8px; }
  .container { padding: 20px 16px 48px; }
  .settings-layout { grid-template-columns: 1fr; gap: 16px; }
  .tabs { flex-direction: row; overflow-x: auto; position: static; }
  .tabs hr { display: none; }
  .tabs a { white-space: nowrap; }
  .grid-2 { grid-template-columns: 1fr; }
  .nudge-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hide-sm { display: none; }
  .preview-zoom { zoom: 0.92; }
  .preview-stage { padding: 16px 8px; }
  .search-form { flex-direction: column; }
  td, th { padding: 10px; }
}
