:root {
  --bg: #0b1220;
  --card: #121a2b;
  --text: #e8eefc;
  --muted: #93a0b8;
  --accent: #3b82f6;
  --accent2: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --border: #243049;
  --radius: 14px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 10% -10%, #1e293b, var(--bg));
  color: var(--text);
  min-height: 100vh;
  line-height: 1.4;
}
a { color: #93c5fd; text-decoration: none; }
.container { max-width: 860px; margin: 0 auto; padding: 1rem 1rem 5rem; }
.topbar {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .75rem 1rem; background: rgba(15,23,42,.9); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(8px);
}
.brand { font-weight: 800; letter-spacing: .04em; color: #fff; font-size: 1.1rem; }
.nav { display: flex; gap: .65rem; flex-wrap: wrap; flex: 1; }
.nav a { color: var(--text); opacity: .85; font-size: .92rem; }
.nav a:hover { opacity: 1; }
.badge-link { position: relative; }
.badge {
  display: inline-block; min-width: 1.2rem; padding: 0 .35rem; margin-left: .25rem;
  border-radius: 999px; background: var(--danger); color: #fff; font-size: .75rem; text-align: center;
}
.logout { margin-left: auto; }
.linkish { background: none; border: 0; color: var(--muted); cursor: pointer; }
h1 { font-size: 1.5rem; margin: .5rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.25rem 0 .5rem; }
.muted { color: var(--muted); }
.card, .login-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem;
}
.login-card { max-width: 380px; margin: 15vh auto; }
.stack { display: flex; flex-direction: column; gap: .85rem; }
.row { display: flex; align-items: end; }
.gap { gap: .75rem; }
label { display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; }
input, select, textarea, button {
  font: inherit; border-radius: 10px; border: 1px solid var(--border);
  background: #0b1324; color: var(--text); padding: .7rem .8rem;
}
textarea { resize: vertical; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .75rem 1rem; border-radius: 12px; border: 1px solid var(--border);
  background: #1e293b; color: var(--text); cursor: pointer; font-weight: 600;
}
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.danger { background: #7f1d1d; border-color: transparent; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1rem 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .6rem; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem;
}
.stat.warn { border-color: #92400e; }
.stat-n { font-size: 1.4rem; font-weight: 800; }
.stat-l { color: var(--muted); font-size: .8rem; }
.list, .check-list { list-style: none; padding: 0; margin: 0; }
.list li, .check-list li {
  padding: .7rem .2rem; border-bottom: 1px solid var(--border);
}
.pill {
  display: inline-block; padding: .1rem .45rem; border-radius: 999px;
  background: #1e3a5f; color: #bfdbfe; font-size: .75rem; margin-left: .25rem;
}
.check { flex-direction: row; align-items: center; gap: .55rem; }
.check input { width: auto; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; min-height: 2rem; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem; flex-wrap: wrap;
  background: #1e3a5f; border-radius: 999px; padding: .35rem .65rem; font-weight: 600;
}
.chip.risk-watch { box-shadow: inset 0 0 0 1px #f59e0b; }
.chip.risk-frequent { box-shadow: inset 0 0 0 1px #fb923c; background: #3b2a12; }
.chip.risk-chronic { box-shadow: inset 0 0 0 1px #ef4444; background: #3f1212; }
.risk {
  display: inline-block; font-size: .72rem; font-weight: 700; padding: .15rem .45rem;
  border-radius: 999px; margin-left: .25rem; vertical-align: middle;
}
.risk-watch { background: #78350f; color: #fde68a; }
.risk-frequent { background: #7c2d12; color: #fdba74; }
.risk-chronic { background: #7f1d1d; color: #fecaca; }
.risk-hint { color: var(--muted); font-size: .8rem; margin: .15rem 0 .4rem 1.7rem; }
.flash-warning { border-color: #92400e; background: #451a03; }
.chip button { border: 0; background: transparent; color: #93c5fd; cursor: pointer; padding: 0; }
.suggest {
  background: #0b1324; border: 1px solid var(--border); border-radius: 10px; max-height: 220px; overflow: auto;
}
.suggest button {
  display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--border);
  background: transparent; border-radius: 0;
}
.suggest button:hover { background: #1e293b; }
.hidden { display: none !important; }
.ok { color: var(--accent2); }
.bad { color: var(--warn); }
.flash { list-style: none; padding: 0; }
.flash li, .flash-info {
  padding: .7rem .9rem; border-radius: 10px; margin-bottom: .5rem;
  background: #1e293b; border: 1px solid var(--border);
}
.flash-error, .flash-error { border-color: #7f1d1d; background: #450a0a; }
.flash-success { border-color: #166534; background: #052e16; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { border-bottom: 1px solid var(--border); padding: .55rem .35rem; text-align: left; }
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 1rem;
}
.modal-card { background: var(--card); border-radius: var(--radius); padding: 1.2rem; max-width: 360px; width: 100%; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem; }
@media (max-width: 640px) {
  .nav { width: 100%; }
  .logout { margin-left: 0; }
}
