:root {
  --bg: #090d14;
  --surface: #111827;
  --card: #151e2e;
  --line: #223047;
  --text: #e7ecf5;
  --muted: #8494aa;
  --accent: #f2b544;
  --danger: #e5484d;
  --ok: #5bd6a2;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(circle at 20% 0%, #162034 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, "DejaVu Sans", sans-serif;
  font-size: 14px;
}
.hidden { display: none !important; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea {
  font: inherit;
  color: var(--text);
}
button {
  border: 1px solid var(--line);
  background: #1a2436;
  border-radius: 9px;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 600;
}
button:hover { background: #243149; border-color: #3a4f71; }
button.primary {
  background: linear-gradient(90deg, #f2b544, #e8912e);
  border: 0;
  color: #10151e;
  font-weight: 800;
}
button.primary:hover { background: #ffc65c; }
button.danger { background: #2a1518; border-color: #5a2228; color: #ff8a8e; }
button.danger:hover { background: #3a1a1f; }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { background: #101827; color: #fff; }
input, select, textarea {
  width: 100%;
  background: #0e1522;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }
.error { color: #ff7a7f; min-height: 18px; font-size: 12px; }
.logo {
  width: 46px; height: 46px; border-radius: 13px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #f7c85e, #d9772a);
  color: #10151e; font-weight: 900; font-size: 26px;
  box-shadow: 0 8px 30px rgba(242, 181, 68, 0.18);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1, .brand h2 { font-size: 23px; letter-spacing: 1px; }
.brand p { color: var(--muted); font-size: 11px; }
.brand.small h2 { font-size: 17px; }

.login-view {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.login-card {
  width: min(430px, 100%);
  background: rgba(21, 30, 46, 0.92);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 34px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}
.login-card .brand { margin-bottom: 24px; }
#login-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
#login-form button { margin-top: 8px; padding: 12px; }
.login-card .ghost { padding-left: 0; }

.app { min-height: 100vh; display: grid; grid-template-columns: 240px 1fr; }
.sidebar {
  background: #0c121c; border-inline-end: 1px solid #1b2536;
  padding: 22px 16px; display: flex; flex-direction: column; gap: 20px;
  position: sticky; top: 0; height: 100vh;
}
nav { display: flex; flex-direction: column; gap: 4px; }
nav button { text-align: start; background: transparent; border-color: transparent; color: var(--muted); }
nav button:hover { background: #141d2c; color: #fff; }
nav button.active { background: #1d293d; border-color: #2f4260; color: var(--accent); font-weight: 800; }
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
main { padding: 26px 30px 40px; overflow-x: hidden; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 16px; }
.topbar h1 { font-size: 27px; }
.badge { padding: 6px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.ok { background: rgba(91, 214, 162, 0.12); color: var(--ok); border: 1px solid rgba(91, 214, 162, 0.3); }
.badge.warn { background: rgba(242, 181, 68, 0.12); color: var(--accent); border: 1px solid rgba(242, 181, 68, 0.3); }
.badge.bad { background: rgba(229, 72, 77, 0.12); color: #ff7a7f; border: 1px solid rgba(229, 72, 77, 0.3); }
.page { display: none; animation: fade 0.18s ease; }
.page.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px;
}
.stat .value { font-size: 30px; font-weight: 800; letter-spacing: 0.5px; }
.stat .label { color: var(--muted); font-size: 12px; margin-top: 4px; }
.stat.accent .value { color: var(--accent); }
.stat.bad .value { color: #ff7a7f; }
.panels { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h3 { font-size: 15px; }
.tools { display: flex; gap: 8px; align-items: center; }
.tools input, .tools select { width: auto; min-width: 120px; padding: 8px 10px; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: start; color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.5px; padding: 9px 8px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 11px 8px; border-bottom: 1px solid #1a2434; vertical-align: middle; }
tr:hover td { background: #121a28; }
td .actions { display: flex; gap: 6px; flex-wrap: wrap; }
td button { padding: 6px 10px; font-size: 12px; }
.risk { display: inline-flex; align-items: center; gap: 8px; }
.risk-bar { width: 72px; height: 7px; border-radius: 4px; background: #0e1522; overflow: hidden; }
.risk-bar span { display: block; height: 100%; background: linear-gradient(90deg, #5bd6a2, #f2b544, #e5484d); }
.pill { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: #1a2436; color: var(--muted); border: 1px solid var(--line); }
.pill.open { color: #ff9f43; border-color: #5a4522; background: #2a2113; }
.pill.confirmed { color: #ff7a7f; border-color: #5a2228; background: #2a1518; }
.pill.cleared { color: var(--ok); border-color: #23503e; background: #10251d; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-form .wide { grid-column: 1 / -1; }
.grid-form .check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.grid-form .check input { width: auto; }
.empty { color: var(--muted); padding: 18px 4px; }
.toast {
  position: fixed; inset-block-end: 24px; inset-inline-end: 24px; max-width: 420px;
  background: #131c2b; border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45); z-index: 20;
}
.toast.error { border-color: #5a2228; color: #ff9a9d; }
.event-card {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  margin-bottom: 9px; background: #101827;
}
.event-card header { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.event-card p { color: var(--muted); font-size: 12px; }
.risk-high { color: #ff7a7f; font-weight: 800; }
.risk-mid { color: var(--accent); font-weight: 700; }
.risk-low { color: var(--ok); font-weight: 700; }

@media (max-width: 980px) {
  .panels { grid-template-columns: 1fr; }
  .app { grid-template-columns: 76px 1fr; }
  .sidebar { padding: 18px 8px; }
  .brand div:not(.logo), nav button span, .sidebar-footer .muted { display: none; }
  nav button { text-align: center; font-size: 12px; padding: 10px 4px; }
  .grid-form { grid-template-columns: 1fr; }
}
