:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f232c;
  --border: #2a2f3a;
  --text: #e8eaed;
  --muted: #9aa3b2;
  --accent: #4f8cff;
  --accent-2: #2fd27f;
  --warn: #ffb24f;
  --danger: #ff5c6c;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 0;
}
.sidebar .brand { padding: 0 20px 16px; font-weight: 700; font-size: 18px; letter-spacing: 0.3px; }
.sidebar .brand span { color: var(--accent); }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: var(--muted);
  font-size: 14px; cursor: pointer; border-left: 3px solid transparent;
}
.nav-item:hover { color: var(--text); background: var(--panel-2); }
.nav-item.active { color: var(--text); background: var(--panel-2); border-left-color: var(--accent); }
.sidebar-footer { margin-top: auto; padding: 12px 20px; font-size: 12px; color: var(--muted); }

.main { flex: 1; min-width: 0; padding: 24px 28px; overflow-x: auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.topbar h1 { font-size: 20px; margin: 0; }
.topbar .actions { display: flex; gap: 10px; }

.btn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 14px; font-size: 13px;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: white; font-weight: 600; }
.btn-primary:hover { opacity: 0.9; }
.btn-success { background: var(--accent-2); border-color: var(--accent-2); color: #06281a; font-weight: 600; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.kpi { padding: 18px; }
.kpi .num { font-size: 28px; font-weight: 700; }
.kpi .label { color: var(--muted); font-size: 13px; margin-top: 4px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
tr:hover td { background: var(--panel-2); }
td.wrap, th.wrap { white-space: normal; }

input, select, textarea {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 7px 10px; font-size: 13px; font-family: inherit; width: 100%;
}
label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-ok { background: rgba(47,210,127,0.15); color: var(--accent-2); }
.badge-warn { background: rgba(255,178,79,0.15); color: var(--warn); }
.badge-danger { background: rgba(255,92,108,0.15); color: var(--danger); }
.badge-muted { background: rgba(154,163,178,0.15); color: var(--muted); }

.tree-cat { font-weight: 700; margin-top: 14px; color: var(--accent); font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; }
.tree-model { font-weight: 600; margin-top: 8px; font-size: 14px; }
.tree-unit { padding-left: 20px; display: flex; align-items: center; gap: 10px; padding-top: 4px; padding-bottom: 4px; font-size: 13px; border-bottom: 1px solid var(--border); }
.tree-unit:last-child { border-bottom: none; }
.tree-unit .id { font-family: ui-monospace, monospace; color: var(--muted); width: 110px; }
.tree-unit .loc { width: 90px; color: var(--muted); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; width: 560px; max-width: 92vw; max-height: 86vh; overflow-y: auto; }
.modal h2 { margin-top: 0; font-size: 17px; }

.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 340px; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card p { color: var(--muted); font-size: 13px; margin-top: 0; }
.error-text { color: var(--danger); font-size: 13px; margin-top: 8px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.link-box { background: var(--panel-2); border: 1px dashed var(--border); border-radius: 8px; padding: 10px; font-size: 12px; word-break: break-all; }

.timeline { overflow-x: auto; }
.timeline-row { display: flex; align-items: center; border-bottom: 1px solid var(--border); padding: 6px 0; }
.timeline-row .tname { width: 220px; flex-shrink: 0; font-size: 13px; }
.timeline-row .tbars { position: relative; height: 22px; flex: 1; min-width: 600px; }
.tbar { position: absolute; top: 2px; height: 18px; border-radius: 5px; background: var(--accent); opacity: 0.85; font-size: 10px; color: white; display: flex; align-items: center; padding: 0 6px; overflow: hidden; white-space: nowrap; }
.timeline-head { display: flex; border-bottom: 1px solid var(--border); padding-bottom: 6px; margin-bottom: 4px; }
.timeline-head .tname { width: 220px; flex-shrink: 0; }
.timeline-head .tdays { flex: 1; min-width: 600px; display: flex; }
.timeline-head .tdays span { flex: 1; text-align: center; font-size: 10px; color: var(--muted); }

.delivery-page { max-width: 640px; margin: 0 auto; padding: 24px 16px 60px; }
.delivery-page .card { margin-bottom: 14px; }
.step-done { color: var(--accent-2); font-weight: 600; }

@media print {
  .no-print { display: none !important; }
  body { background: white; color: black; }
  .card { border-color: #ccc; }
}
