:root {
  --navy: #080c18;
  --navy-2: #0f1730;
  --gold: #c9a84c;
  --cream: #f0e6c8;
  --bg: #0b1020;
  --panel: #121a30;
  --panel-2: #1a2340;
  --line: #283457;
  --text: #e8edf7;
  --muted: #8e9ab8;
  --ok: #3ecf8e;
  --warn: #e0a93b;
  --bad: #e5615e;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, #16224a 0%, var(--bg) 55%);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.view { min-height: 100vh; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
code { background: var(--panel-2); padding: 1px 6px; border-radius: 5px; color: var(--cream); }
a { color: var(--gold); }

/* ---- Login ---- */
#login-view { display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px; padding: 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center;
  font-weight: 800; color: var(--navy);
  background: linear-gradient(135deg, var(--gold), #e7cf86);
}
.login-card h1 { font-size: 19px; margin: 0; }
.login-card p { margin: 2px 0 0; }
form { display: flex; flex-direction: column; gap: 13px; margin-top: 20px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
input, textarea {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 9px; padding: 9px 11px; font-size: 14px; font-family: inherit;
}
input:focus, textarea:focus { outline: 2px solid var(--gold); border-color: transparent; }

button {
  cursor: pointer; border-radius: 9px; border: 1px solid var(--line);
  padding: 9px 14px; font-size: 13.5px; font-weight: 600; background: var(--panel-2); color: var(--text);
}
button.primary { background: linear-gradient(135deg, var(--gold), #e7cf86); color: var(--navy); border: none; }
button.ghost { background: transparent; }
button.small { padding: 5px 9px; font-size: 12px; }
button.danger { color: var(--bad); border-color: rgba(229,97,94,.4); }
button:hover { filter: brightness(1.08); }

.error { color: var(--bad); font-size: 13px; }

/* ---- Dashboard ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: rgba(10,15,30,.6); position: sticky; top: 0; backdrop-filter: blur(6px);
}
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fleet-target { flex-direction: row; align-items: center; gap: 7px; font-size: 12px; }
.fleet-target input { width: 130px; padding: 6px 9px; }

main { padding: 22px; max-width: 1200px; margin: 0 auto; }

.summary { display: flex; gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 13px;
  padding: 14px 20px; min-width: 120px;
}
.stat .num { font-size: 26px; font-weight: 800; display: block; }
.stat .lbl { color: var(--muted); font-size: 12px; }
.stat.alert .num { color: var(--bad); }
.stat.clickable { cursor: pointer; }
.stat.clickable:hover { border-color: var(--gold); }
.stat.clickable.active { border-color: var(--gold); background: var(--panel-2); }
.stat.clickable:focus-visible { outline: 2px solid var(--gold); }

.filter-indicator {
  margin: -6px 0 12px; font-size: 13px; color: var(--muted);
}
.filter-indicator a { color: var(--gold); }

.settings-lifecycle h3, .settings-checklist h3 { margin: 16px 0 8px; font-size: 14px; color: var(--gold); }
.lifecycle-row { display: flex; align-items: center; gap: 10px; }
.checklist { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 720px) { .checklist { grid-template-columns: 1fr; } }

table.fleet { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 13px; overflow: hidden; border: 1px solid var(--line); }
table.fleet th, table.fleet td { text-align: left; padding: 11px 13px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.fleet th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
table.fleet tr:last-child td { border-bottom: none; }
td.actions { display: flex; gap: 6px; justify-content: flex-end; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge.ok { background: rgba(62,207,142,.15); color: var(--ok); }
.badge.bad { background: rgba(229,97,94,.15); color: var(--bad); }
.badge.warn { background: rgba(224,169,59,.15); color: var(--warn); }

/* ---- Modals ---- */
/* The `hidden` attribute must win over the explicit `display` rules below
   (e.g. `.modal { display: flex }`), otherwise hidden modals stay visible. */
[hidden] { display: none !important; }
.modal { position: fixed; inset: 0; background: rgba(4,7,16,.7); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 24px; width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; }
.modal-card.wide { max-width: 640px; }
.modal-card h2 { margin: 0 0 8px; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.row { display: flex; gap: 12px; }
.row > label { flex: 1; }
.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }

.settings-body h3 { margin: 16px 0 8px; font-size: 14px; color: var(--gold); }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.features { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }

.settings-history h3 { margin: 16px 0 8px; font-size: 14px; color: var(--gold); }
.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; }
.history-list li { border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; font-size: 13px; }
.history-list .badge { margin-right: 6px; }

.activity { margin-top: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: 13px; padding: 14px 16px; }
.activity-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.activity-head-actions { display: flex; gap: 8px; }
.activity-head h2 { margin: 0; font-size: 15px; }
.activity-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 12px; }
.activity-filters label { display: flex; flex-direction: column; gap: 3px; margin: 0; }
.activity-filters select, .activity-filters input { padding: 6px 8px; }
.activity-filters button { align-self: flex-end; }
.activity-body .history-list { max-height: 320px; }
.activity-link { color: var(--gold); text-decoration: none; }
.activity-link:hover { text-decoration: underline; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line); padding: 11px 18px; border-radius: 11px; z-index: 80; }
.toast.error { border-color: var(--bad); color: var(--bad); }

@media (max-width: 720px) {
  .settings-grid, .features { grid-template-columns: 1fr; }
  table.fleet { font-size: 13px; }
}
