:root {
  color-scheme: dark;
  --bg: #0b0b0c;
  --panel: #141415;
  --panel-2: #1a1a1c;
  --line: #2a2a2e;
  --line-2: #3a3a3f;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --accent: #e8e4dc;
  --on-accent: #0a0a0a;
  --ok: #7aab93;
  --warn: #d4b483;
  --danger: #d97777;
  --blue: #8ba6d8;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.small-btn { padding: 6px 10px; font-size: 13px; }

.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  display: flex; flex-direction: column; gap: 18px;
  padding: 18px 16px; border-right: 1px solid var(--line);
  background: #0f0f11; position: sticky; top: 0; height: 100vh;
}
.side-head { display: flex; flex-direction: column; gap: 2px; }
.logo { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.org-pick { display: grid; gap: 6px; }
select, input, textarea {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 11px; width: 100%; outline: none;
}
select:focus, input:focus, textarea:focus { border-color: var(--line-2); box-shadow: 0 0 0 2px rgba(232,228,220,.12); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  padding: 9px 11px; border-radius: 10px; color: var(--muted); font-size: 14px;
}
.nav a:hover { background: var(--panel); color: var(--text); }
.nav a.active { background: var(--panel-2); color: var(--text); font-weight: 600; }
.side-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ghost { background: transparent; border: 1px solid var(--line); border-radius: 10px; }
.ghost:hover { border-color: var(--line-2); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 24px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5; background: rgba(11,11,12,.92); backdrop-filter: blur(10px);
}
.topbar h1 { margin: 0; font-size: 20px; letter-spacing: -0.02em; }
.top-actions { margin-left: auto; display: flex; gap: 8px; }
.icon-btn { display: none; background: transparent; border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; }
main { padding: 24px; display: grid; gap: 16px; align-content: start; max-width: 1180px; width: 100%; }

.primary { background: var(--accent); color: var(--on-accent); border: 1px solid var(--accent); border-radius: 10px; padding: 9px 14px; font-weight: 600; }
.primary:hover { opacity: .92; }
.btn-danger { border-color: var(--danger); color: var(--danger); background: transparent; border-radius: 10px; padding: 8px 12px; }

.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px;
}
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi b { font-size: 26px; letter-spacing: -0.03em; }
.kpi span { color: var(--muted); font-size: 13px; }
.kpi small { color: var(--muted); font-size: 12px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.section-head h2 { margin: 0; font-size: 16px; }
.link { color: var(--muted); font-size: 13px; }
.link:hover { color: var(--text); }

.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px;
}
.row:first-child { border-top: 0; }
.row .meta { color: var(--muted); font-size: 12px; }
.money { font-variant-numeric: tabular-nums; font-weight: 600; }

.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); color: var(--muted); }
.chip.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 60%, var(--line)); }
.chip.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 60%, var(--line)); }
.chip.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 60%, var(--line)); }
.chip.blue { color: var(--blue); border-color: color-mix(in srgb, var(--blue) 60%, var(--line)); }

.progress { height: 7px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); }
.project-card { display: grid; gap: 10px; }
.project-card .top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.project-card b { font-size: 15px; }
.project-card .meta { color: var(--muted); font-size: 12px; }
.cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 500; font-size: 12px; }
.table tr:last-child td { border-bottom: 0; }
.table .right { text-align: right; }
.table tbody tr:hover { background: var(--panel-2); }

.empty { padding: 22px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; }
.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--panel-2), var(--line), var(--panel-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; margin-bottom: 8px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.overlay {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(0,0,0,.62);
}
.modal {
  width: min(680px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 20px;
}
.modal h2 { margin: 0 0 6px; font-size: 20px; }
.modal .modal-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.modal-close { background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; }
.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field span { color: var(--muted); font-size: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.thread { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.msg { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.msg .meta { color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.msg p { margin: 0; white-space: pre-wrap; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: 13px; box-shadow: 0 12px 40px rgba(0,0,0,.4); }
.toast.err { border-color: var(--danger); }
.toast.ok { border-color: var(--ok); }

.auth { display: grid; place-items: center; padding: 24px; }
.gate { width: min(100%, 380px); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 28px; }
.gate .logo { margin-bottom: 6px; }
.gate h1 { margin: 0 0 18px; font-size: 22px; }
.gate form { display: grid; gap: 12px; }
.gate label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.gate .error { color: var(--danger); min-height: 20px; margin: 12px 0 0; }
.gate .link { margin-top: 14px; width: 100%; text-align: center; background: transparent; border: 0; text-decoration: underline; }

@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 30;
    transform: translateX(-100%); transition: transform .2s ease; height: 100dvh;
  }
  .sidebar.open { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.6); }
  .icon-btn { display: inline-block; }
  .topbar { padding: 12px 14px; }
  main { padding: 14px; }
  .cards { grid-template-columns: 1fr; }
  .table th:nth-child(2), .table td:nth-child(2) { display: none; }
}
