:root {
  --ink: #17202a;
  --muted: #6d7885;
  --line: #dfe6ee;
  --panel: #ffffff;
  --page: #f4f7fa;
  --brand: #123c69;
  --brand-strong: #0a2847;
  --accent: #1f8a70;
  --warn: #b26a00;
  --danger: #b42318;
  --shadow: 0 18px 48px rgba(18, 60, 105, 0.12);
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--page); }
a { color: var(--brand); text-decoration: none; }

.login-body {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(18, 60, 105, 0.92), rgba(31, 138, 112, 0.76)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1200' height='800' viewBox='0 0 1200 800'%3E%3Crect width='1200' height='800' fill='%2312202a'/%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.12'%3E%3Cpath d='M0 120h1200M0 270h1200M0 430h1200M0 610h1200M170 0v800M390 0v800M650 0v800M930 0v800'/%3E%3Ccircle cx='650' cy='430' r='160'/%3E%3Ccircle cx='390' cy='270' r='90'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
}

.login-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) 460px; gap: 48px; align-items: center; padding: 48px; }
.login-layout.single { grid-template-columns: minmax(320px, 520px); justify-content: center; }
.login-brand { color: #fff; max-width: 760px; }
.brand-lockup { display: flex; gap: 24px; align-items: flex-start; }
.brand-mark { width: 42px; height: 42px; border-radius: 8px; background: var(--brand); color: #fff; display: inline-grid; place-items: center; font-weight: 800; letter-spacing: 0; flex: 0 0 auto; }
.brand-mark.large { width: 72px; height: 72px; font-size: 1.35rem; background: #fff; color: var(--brand); }
.login-brand h1 { margin: 8px 0 0; font-size: 3.5rem; line-height: 1.02; max-width: 720px; letter-spacing: 0; }
.eyebrow { margin: 0; color: var(--accent); font-size: .75rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.login-brand .eyebrow { color: #b9f3df; }
.signal-panel { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 54px; max-width: 680px; }
.signal-panel > div { border: 1px solid rgba(255,255,255,.26); background: rgba(255,255,255,.12); padding: 18px; border-radius: 8px; backdrop-filter: blur(14px); }
.signal-label { display: block; color: rgba(255,255,255,.72); font-size: .78rem; margin-bottom: 6px; }

.login-card { background: #fff; border-radius: 8px; box-shadow: var(--shadow); padding: 34px; }
.login-card-header { display: flex; gap: 16px; align-items: center; margin-bottom: 26px; }
.login-card h2 { margin: 0; font-size: 1.65rem; }
.login-card p { margin: 4px 0 0; color: var(--muted); }
.form-stack { display: grid; gap: 18px; }
.form-stack label span { display: block; font-size: .85rem; font-weight: 700; margin-bottom: 8px; }
input { width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 6px; padding: 0 12px; font: inherit; color: var(--ink); }
input:focus { outline: 3px solid rgba(31, 138, 112, .18); border-color: var(--accent); }
select { min-height: 38px; border: 1px solid var(--line); border-radius: 6px; padding: 0 8px; background: #fff; color: var(--ink); }
textarea { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; font: inherit; resize: vertical; }
.inline-form { display: grid; grid-template-columns: minmax(130px, 1fr) auto auto; align-items: center; gap: 8px; min-width: 330px; margin-bottom: 7px; }
.inline-form input[type="checkbox"] { width: 16px; min-height: 16px; }
.inline-form label { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.compact-button { min-height: 38px; border: 0; border-radius: 6px; padding: 0 12px; background: var(--brand); color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.form-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: .9rem; }
.check-row { display: flex; align-items: center; gap: 8px; }
.check-row input { width: 16px; min-height: 16px; }
.primary-button { min-height: 46px; border: 0; border-radius: 6px; background: var(--brand); color: #fff; font: inherit; font-weight: 800; cursor: pointer; }
.link-button { display: grid; place-items: center; margin-top: 18px; }
.primary-button:hover { background: var(--brand-strong); }
.login-note { font-size: .85rem; }
.alert { border-radius: 6px; padding: 12px 14px; margin-bottom: 18px; }
.alert.error { background: #fff1f0; color: var(--danger); border: 1px solid #ffd2cc; }
.alert.success { background: #e9f3ef; color: #11614f; border: 1px solid #b7dfd3; }
.admin-form { display: grid; gap: 8px; min-width: 230px; }
.admin-form.horizontal { grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) 100px auto; align-items: end; }
.admin-form label { color: var(--muted); font-size: .78rem; font-weight: 700; }
.admin-form input, .admin-form select { display: block; width: 100%; min-height: 38px; margin-top: 4px; }
.admin-form .check-row { color: var(--ink); }
.admin-form .check-row input { display: inline-block; width: 16px; min-height: 16px; margin: 0; }
.badge.inactive, .badge.missing { background: #f1f3f5; color: #59636e; }
.badge.present { background: #e9f3ef; color: #11614f; }
.badge.active, .badge.detected, .badge.accounted, .badge.manually_confirmed, .badge.evacuated { background: #e9f3ef; color: #11614f; }
.badge.injured, .badge.requires_assistance, .badge.cancelled { background: #fff1f0; color: var(--danger); }
.badge.unconfirmed, .badge.off_site, .badge.stale { background: #fff3e0; color: var(--warn); }
.danger-button { background: var(--danger); color: #fff; }
.command-band, .muster-banner, .export-bar { display: flex; align-items: center; justify-content: space-between; gap: 20px; border: 1px solid var(--line); background: #fff; padding: 20px; margin-bottom: 18px; }
.export-bar small { display: block; margin-top: 4px; }
.export-unavailable { color: var(--muted); padding: 7px 10px; border: 1px dashed #94a3b8; cursor: not-allowed; }
.command-band h3, .muster-banner h3 { margin: 3px 0 6px; }
.muster-banner.emergency, .active-emergency { border-left: 6px solid var(--danger); }
.muster-command { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.command-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.lifecycle-controls { display: flex; align-items: end; gap: 18px; margin-top: 16px; }
.lifecycle-controls form { display: flex; align-items: end; gap: 8px; }
.report-filters { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; align-items: end; margin-top: 16px; }
.report-filters label { color: var(--muted); font-size: .78rem; font-weight: 700; }
.report-filters input, .report-filters select { display: block; width: 100%; min-height: 38px; margin-top: 4px; }
.report-filters .check-row input { width: 16px; min-height: 16px; margin: 0; }
.reconcile-form { display: grid; grid-template-columns: 150px minmax(160px, 1fr) auto; gap: 7px; min-width: 390px; }
.reconcile-form input, .reconcile-form select { min-height: 38px; }
.pagination { display: flex; justify-content: flex-end; align-items: center; gap: 14px; padding-top: 16px; }
.form-panel { max-width: 760px; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 272px 1fr; }
.sidebar { background: #0f2233; color: #e8eef5; padding: 22px; display: flex; flex-direction: column; gap: 26px; }
.brand { color: #fff; display: flex; align-items: center; gap: 12px; }
.brand small { display: block; color: #9fb1c3; margin-top: 2px; }
.nav-list { display: grid; gap: 6px; }
.nav-item { color: #c9d6e2; padding: 11px 12px; border-radius: 6px; font-weight: 700; }
.nav-item.active, .nav-item:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav-item.muted { color: #7f93a6; cursor: default; }
.sidebar-footer { margin-top: auto; display: flex; align-items: center; gap: 9px; color: #9fb1c3; font-size: .85rem; }
.status-dot { width: 9px; height: 9px; border-radius: 99px; background: var(--accent); display: inline-block; flex: 0 0 auto; }

.main { min-width: 0; padding: 24px; }
.topbar, .page-header, .panel-header, .footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.topbar { margin-bottom: 20px; }
.topbar h1 { margin: 3px 0 0; font-size: 1.55rem; }
.breadcrumbs { display: flex; gap: 8px; color: var(--muted); font-size: .82rem; }
.breadcrumbs span + span::before { content: "/"; margin-right: 8px; color: #9aa6b2; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 8px; background: #fff; position: relative; cursor: pointer; }
.notification-dot { width: 8px; height: 8px; background: var(--danger); border-radius: 50%; position: absolute; top: 10px; right: 10px; }
.profile-menu { position: relative; }
.profile-menu summary { list-style: none; display: flex; align-items: center; gap: 9px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; cursor: pointer; }
.profile-menu summary::-webkit-details-marker { display: none; }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: #e9f3ef; color: var(--accent); display: inline-grid; place-items: center; font-weight: 800; }
.profile-menu form { position: absolute; right: 0; top: 48px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px; box-shadow: var(--shadow); }
.profile-menu button { border: 0; background: transparent; padding: 8px 18px; cursor: pointer; font: inherit; white-space: nowrap; }

.page-header { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 20px; margin-bottom: 20px; }
.page-header h2 { margin: 4px 0 0; font-size: 1.3rem; }
.pill { border-radius: 999px; background: #e9f3ef; color: #11614f; padding: 7px 11px; font-size: .82rem; font-weight: 800; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric-card, .panel, .empty-state { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(18, 60, 105, .05); }
.metric-card { padding: 18px; display: grid; gap: 8px; min-height: 132px; }
.metric-card span { color: var(--muted); font-weight: 800; font-size: .85rem; }
.metric-card strong { font-size: 2rem; letter-spacing: 0; }
.metric-card small { color: var(--muted); line-height: 1.35; }
.metric-card.good { border-top: 4px solid var(--accent); }
.metric-card.warn { border-top: 4px solid var(--warn); }
.metric-card.alert { border-top: 4px solid var(--danger); }
.metric-card.neutral { border-top: 4px solid var(--brand); }
.metric-card.muted { border-top: 4px solid #9aa6b2; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, .55fr); gap: 18px; }
.panel { padding: 18px; min-width: 0; }
.panel.wide { grid-column: 1 / -1; }
.panel h3 { margin: 0; font-size: 1.05rem; }
.zone-map { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 16px; }
.zone-tile { border: 1px solid var(--line); border-radius: 8px; padding: 16px; min-height: 96px; display: grid; gap: 8px; align-content: start; background: #f9fbfd; }
.zone-tile small, table small, .activity-item small { color: var(--muted); display: block; margin-top: 3px; line-height: 1.35; }
.table-wrap { overflow-x: auto; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.badge { display: inline-flex; align-items: center; min-height: 24px; border-radius: 999px; padding: 3px 9px; font-size: .78rem; font-weight: 800; background: #eef3f8; color: var(--muted); text-transform: capitalize; }
.badge.online { background: #e9f3ef; color: #11614f; }
.badge.offline { background: #fff3e0; color: var(--warn); }
.health-list { display: grid; gap: 10px; margin: 14px 0 0; }
.health-list div { display: flex; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.health-list dt { color: var(--muted); }
.health-list dd { margin: 0; font-weight: 800; }
.activity-list { display: grid; gap: 12px; margin-top: 14px; }
.activity-list.horizontal { grid-template-columns: repeat(3, 1fr); }
.activity-item { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fbfcfe; }
.empty-state { padding: 36px; text-align: center; color: var(--muted); }
.empty-state h3 { margin: 0 0 8px; color: var(--ink); }
.empty-state.compact { padding: 24px; margin-top: 12px; }
.footer { color: var(--muted); font-size: .82rem; padding: 24px 2px 4px; }

@media (max-width: 1120px) {
  .login-layout { grid-template-columns: 1fr; }
  .login-brand h1 { font-size: 2.8rem; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
  .zone-map, .activity-list.horizontal { grid-template-columns: repeat(2, 1fr); }
  .report-filters { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
}

@media (max-width: 760px) {
  .login-layout { padding: 22px; }
  .login-brand h1 { font-size: 2.1rem; }
  .signal-panel { grid-template-columns: 1fr; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; padding: 16px; }
  .main { padding: 16px; }
  .topbar, .page-header { align-items: flex-start; flex-direction: column; }
  .metric-grid, .zone-map, .activity-list.horizontal { grid-template-columns: 1fr; }
  .admin-form.horizontal { grid-template-columns: 1fr; }
  .command-band, .muster-banner, .muster-command, .export-bar, .lifecycle-controls { align-items: flex-start; flex-direction: column; }
  .report-filters { grid-template-columns: 1fr; }
}
