:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273449;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #6366f1;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --p1: #ef4444;
  --p2: #f97316;
  --p3: #eab308;
  --p4: #22c55e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; font-size: 15px; }
.nav { display: flex; gap: 8px; }
.nav-btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.nav-btn:hover { border-color: var(--accent); }
.nav-btn.active { background: var(--accent-2); border-color: var(--accent-2); color: white; }
.nav-btn.primary { background: var(--accent); border-color: var(--accent); color: #082f49; font-weight: 600; }

main { max-width: 1100px; margin: 0 auto; padding: 20px 20px 96px; }

h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; }
.muted { color: var(--muted); }

.grid { display: grid; gap: 16px; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.grow { flex: 1; min-width: 220px; }

label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 60px; }

.btn {
  background: var(--accent);
  color: #082f49;
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); color: #450a0a; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--panel-2); }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.tag.p1 { background: var(--p1); color: white; border: none; }
.tag.p2 { background: var(--p2); color: white; border: none; }
.tag.p3 { background: var(--p3); color: #1c1917; border: none; }
.tag.p4 { background: var(--p4); color: #052e16; border: none; }
.tag.open { background: #1d4ed8; color: white; border: none; }
.tag.ok { background: #14532d; color: #bbf7d0; }
.tag.warn { background: #422006; color: #fde68a; }

.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--panel-2); border: 1px solid var(--border); border-radius: 20px; padding: 2px 10px; font-size: 12px; }

.live-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.live-item { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.live-item .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.live-item .v { font-size: 15px; font-weight: 600; margin-top: 4px; word-break: break-word; }
.live-item .v.count-open { color: var(--accent); }
.live-item .v.count-critica { color: var(--p1); }
.live-item .v.count-alerta { color: var(--warn); }
.deadline-over { color: var(--danger); }
.deadline-soon { color: var(--warn); }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 10px 0 10px 18px; border-left: 2px solid var(--border); margin-left: 6px; position: relative; }
.timeline li::before {
  content: '';
  position: absolute; left: -6px; top: 16px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
}
.timeline .t-meta { font-size: 11px; color: var(--muted); }
.timeline .t-body { white-space: pre-wrap; }

.field-group { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }

.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { width: auto; }

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--panel);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,.4);
  z-index: 100;
}
.toast.err { border-color: var(--danger); }
.hidden { display: none; }

.steps { display: flex; gap: 8px; margin-bottom: 16px; }
.step {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.step.active { background: var(--accent-2); color: white; border-color: var(--accent-2); }
.step.done { background: #14532d; color: #bbf7d0; border-color: #14532d; }

.empty { color: var(--muted); padding: 24px; text-align: center; border: 1px dashed var(--border); border-radius: 10px; }

.back { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 13px; padding: 0; margin-bottom: 12px; }

.user-bar {
  position: fixed;
  bottom: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  z-index: 50;
}
.user-bar label { margin: 0; font-size: 12px; color: var(--muted); }
.user-bar select { width: auto; min-width: 200px; }
