:root {
  --navy: #0b3d66;
  --navy-700: #0a3357;
  --accent: #2f80ed;
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #e3e8ef;
  --text: #1c2733;
  --muted: #6b7785;
  --good: #1f9d6b;
  --warn: #d98b00;
  --bad: #d64545;
  --shadow: 0 1px 3px rgba(16,30,54,.08), 0 4px 16px rgba(16,30,54,.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

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

.sidebar {
  width: 232px;
  background: var(--navy);
  color: #dbe7f2;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}
.sidebar .brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .brand .app { font-weight: 700; font-size: 16px; color: #fff; letter-spacing: .2px; }
.sidebar .brand .client { font-size: 12px; color: #9fc0dd; margin-top: 2px; }
.sidebar nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; margin: 2px 0;
  border-radius: 8px;
  color: #cfe0f0; text-decoration: none; font-size: 13.5px;
}
.sidebar nav a .ic { width: 18px; text-align: center; opacity: .9; }
.sidebar nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar nav a.active { background: var(--accent); color: #fff; }
.sidebar nav .group-label {
  padding: 14px 12px 4px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .6px; color: #7ea6cc;
}
.sidebar .foot { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; }
.sidebar .foot .who { color: #fff; font-weight: 600; }
.sidebar .foot a { color: #9fc0dd; text-decoration: none; }
.sidebar .foot a:hover { text-decoration: underline; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 650; }
.content { padding: 24px; flex: 1; }

/* ---------- Cards / stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: 16px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 18px;
}
.stat .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.stat .value { font-size: 30px; font-weight: 700; margin-top: 6px; }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.placeholder {
  border: 1px dashed var(--line); border-radius: 12px; background: #fbfcfe;
  padding: 40px; text-align: center; color: var(--muted); margin-top: 20px;
}
.placeholder h3 { color: var(--text); margin: 0 0 6px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
tbody tr:hover { background: #f8fafc; }

/* ---------- Buttons / forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 8px 14px; border-radius: 8px; font-size: 13.5px; cursor: pointer;
}
.btn:hover { background: #f4f7fb; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #2570d6; }
.btn.danger { color: var(--bad); border-color: #f0c9c9; }

input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 14px; font-family: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,128,237,.12); }
label { display: block; font-size: 12.5px; color: var(--muted); margin: 12px 0 4px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; }
.badge.good { background: #e3f6ed; color: var(--good); }
.badge.warn { background: #fdf2dd; color: var(--warn); }
.badge.bad  { background: #fce5e5; color: var(--bad); }
.badge.mute { background: #eef1f5; color: var(--muted); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#0b3d66,#0a2a47); }
.login-card { width: 360px; background: #fff; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.25); padding: 32px; }
.login-card .app { font-size: 20px; font-weight: 700; color: var(--navy); }
.login-card .client { font-size: 13px; color: var(--muted); margin-bottom: 22px; }
.login-card .err { color: var(--bad); font-size: 13px; margin-top: 12px; min-height: 18px; }
.login-card .btn.primary { width: 100%; justify-content: center; margin-top: 18px; padding: 11px; }

.modal-bg { position: fixed; inset: 0; background: rgba(16,30,54,.5); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: 14px; padding: 24px; width: 420px; max-width: 92vw; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal h2 { margin: 0 0 14px; font-size: 18px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.hidden { display: none !important; }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .grow { flex: 1; }
.toolbar select, .toolbar input { width: auto; min-width: 130px; }
.toolbar input.search { min-width: 220px; }

/* ---------- Side drawer ---------- */
.drawer-bg { position: fixed; inset: 0; background: rgba(16,30,54,.45); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 560px; max-width: 94vw;
  background: var(--bg); z-index: 41; box-shadow: -8px 0 30px rgba(16,30,54,.18);
  display: flex; flex-direction: column;
}
.drawer .dhead { background: #fff; border-bottom: 1px solid var(--line); padding: 18px 22px; }
.drawer .dhead .ref { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .4px; }
.drawer .dhead h2 { margin: 4px 0 0; font-size: 19px; }
.drawer .dhead .close { position: absolute; top: 16px; right: 18px; cursor: pointer; font-size: 22px; color: var(--muted); background: none; border: none; }
.drawer .tabs { display: flex; gap: 4px; background: #fff; padding: 0 16px; border-bottom: 1px solid var(--line); }
.drawer .tabs button { background: none; border: none; padding: 12px 14px; cursor: pointer; font-size: 13.5px; color: var(--muted); border-bottom: 2px solid transparent; }
.drawer .tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.drawer .dbody { padding: 20px 22px; overflow-y: auto; flex: 1; }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; font-size: 13.5px; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 500; }

.ball {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 18px;
}
.ball .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.ball .who { font-size: 17px; font-weight: 700; margin: 4px 0 2px; }
.ball.them { border-left: 4px solid var(--warn); }
.ball.us { border-left: 4px solid var(--accent); }
.ball.none { border-left: 4px solid var(--line); }

.timeline-item { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.timeline-item .meta { color: var(--muted); font-size: 11.5px; }
.list-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
td .age-warn { color: var(--warn); font-weight: 600; }
td .age-bad { color: var(--bad); font-weight: 700; }
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; background: #eef2f7; border-radius: 99px; padding: 4px 10px; font-size: 12.5px; }
.pill .x { cursor: pointer; color: var(--muted); font-weight: 700; }
.muted { color: var(--muted); }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 18px 0 8px; }
