:root {
  --ink: #12302e;
  --ink-2: #1b4542;
  --ink-text: #cfe0dc;
  --accent: #e8a23a;
  --accent-ink: #3a2606;
  --bg: #f4f2ec;
  --card: #ffffff;
  --line: #e3dfd4;
  --text: #1f2a29;
  --muted: #6b7774;
  --red: #c4432f;
  --orange: #dd7a26;
  --yellow: #d4a72a;
  --lime: #8bab3c;
  --green: #3d8c5a;
  --teal: #2f7f86;
  --radius: 10px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--teal); }
button, input, select, textarea { font: inherit; }

.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
aside {
  background: var(--ink); color: var(--ink-text); padding: 20px 14px;
  display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 16px; color: #fff; }
.brand svg { width: 34px; height: 34px; }
.brand b { font-size: 20px; letter-spacing: .3px; }
.brand small { display: block; font-size: 11px; color: var(--ink-text); opacity: .8; }
.actions { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.btn {
  border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 8px;
  padding: 8px 14px; cursor: pointer; font-weight: 600;
}
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: #3f6763; color: #fff; }
.btn.danger { color: var(--red); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
nav .group { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; opacity: .6; margin: 14px 8px 4px; }
nav a {
  display: flex; justify-content: space-between; align-items: center;
  color: var(--ink-text); text-decoration: none; padding: 7px 10px; border-radius: 7px; font-size: 14px;
}
nav a:hover { background: var(--ink-2); color: #fff; }
nav a.active { background: var(--ink-2); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
nav .badge { background: var(--red); color: #fff; border-radius: 9px; font-size: 11px; padding: 1px 7px; }
.userbox { margin-top: auto; border-top: 1px solid #2a5450; padding: 12px 8px 0; font-size: 13px; }
.userbox b { color: #fff; display: block; } .userbox small { display: block; opacity: .7; margin-bottom: 6px; }
.userbox a { color: var(--accent); text-decoration: none; }
aside footer { font-size: 11px; opacity: .55; padding: 12px 8px 0; }

main { padding: 24px 28px 40px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.topbar h1 { font-size: 22px; margin: 0; }
.topbar .sub { color: var(--muted); font-size: 13px; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.tile { background: var(--card); border-radius: var(--radius); padding: 16px 18px; border: 1px solid var(--line); border-top: 4px solid var(--teal); }
.tile.alert { border-top-color: var(--red); }
.tile.ok { border-top-color: var(--green); }
.tile h3 { margin: 0 0 12px; font-size: 14px; display: flex; gap: 8px; align-items: center; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.tile .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.stat b { display: block; font-size: 30px; line-height: 1.1; }
.stat span { font-size: 13px; color: var(--muted); }
.stat.red b { color: var(--red); } .stat.orange b { color: var(--orange); } .stat.green b { color: var(--green); }

.grid2 { display: grid; grid-template-columns: minmax(280px, 1fr) 2fr; gap: 16px; }
.card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); padding: 16px 18px; min-width: 0; }
.card h2 { font-size: 15px; margin: 0 0 12px; display: flex; justify-content: space-between; align-items: center; }
.counters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 16px; }
.counter { display: flex; align-items: center; gap: 14px; }
.counter .ico { width: 42px; height: 42px; border-radius: 10px; background: #e7f0ee; color: var(--teal); display: grid; place-items: center; }
.counter b { font-size: 26px; display: block; }
.counter span { color: var(--muted); font-size: 13px; }

.discoveries { list-style: none; margin: 0; padding: 0; }
.discoveries li { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.discoveries li:last-child { border-bottom: 0; }
.discoveries .cn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.pill { font-size: 12px; font-weight: 600; border-radius: 20px; padding: 2px 9px; white-space: nowrap; background: #eef1ef; color: var(--muted); }
.pill.red { background: #f8e1dc; color: var(--red); } .pill.orange { background: #fbe9d9; color: #a65612; }
.pill.yellow { background: #f8efd2; color: #876914; } .pill.green { background: #dff0e5; color: var(--green); }
.pill.teal { background: #dcedee; color: var(--teal); }

.chart { display: flex; align-items: flex-end; gap: 10px; height: 220px; padding: 10px 4px 0; border-bottom: 1px solid var(--line); }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.chart .bar { width: 60%; max-width: 54px; border-radius: 6px 6px 0 0; min-height: 2px; transition: height .4s; }
.chart .val { font-weight: 700; font-size: 14px; }
.chart-labels { display: flex; gap: 10px; padding: 8px 4px 0; }
.chart-labels div { flex: 1; text-align: center; font-size: 12px; color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 8px; border-bottom: 2px solid var(--line); }
td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.click { cursor: pointer; } tr.click:hover td { background: #faf8f3; }
.table-wrap { overflow-x: auto; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.mono { font-family: Consolas, monospace; font-size: 12px; word-break: break-all; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input[type=search] { flex: 1; min-width: 200px; }

input, select, textarea { border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; background: #fff; color: var(--text); width: 100%; }
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
label.inline { display: flex; align-items: center; gap: 8px; color: var(--text); }
label.inline input { width: auto; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

dialog { border: 0; border-radius: 14px; padding: 0; width: min(640px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(14, 30, 29, .55); }
dialog header { background: var(--ink); color: #fff; padding: 14px 20px; display: flex; justify-content: space-between; align-items: center; }
dialog header h3 { margin: 0; font-size: 16px; }
dialog header button { background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; }
dialog .body { padding: 6px 20px 18px; max-height: 70vh; overflow-y: auto; }
dialog footer { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.wide { width: min(900px, 96vw); }

.progress { height: 8px; background: #e9e6dd; border-radius: 5px; overflow: hidden; margin: 8px 0; }
.progress div { height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.notice { background: #fdf5e6; border: 1px solid #f1d9a8; border-radius: 8px; padding: 10px 12px; font-size: 13px; margin: 10px 0; }
.notice.err { background: #fbe7e3; border-color: #efc0b6; color: #7c2416; }
.notice.ok { background: #e3f2e8; border-color: #b9dcc5; color: #1f5a36; }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 8px; z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 420px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
details summary { cursor: pointer; font-weight: 600; margin: 8px 0; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }

@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  aside { position: static; height: auto; }
  .tiles, .grid2, .counters { grid-template-columns: 1fr; }
  main { padding: 16px; }
  .row, .row3 { grid-template-columns: 1fr; }
}
