:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --ink: #0b0d12;
  --muted: #667085;
  --line: #dfe3ea;
  --red: #ef3340;
  --green: #00a86b;
  --amber: #b77900;
  --blue: #2563eb;
  --dark: #08090d;
  --shadow: 0 20px 55px rgba(15, 23, 42, .10);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}
button, input, select, textarea { font: inherit; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 280px;
  padding: 24px 18px;
  background: #08090d;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.brand {
  color: #fff;
  text-decoration: none;
  font-size: 25px;
  font-weight: 950;
  letter-spacing: .01em;
}
.brand span { color: var(--red); }
.brand small {
  display: block;
  margin-top: 3px;
  color: #98a2b3;
  font-size: 11px;
  letter-spacing: .16em;
}
#sideNav {
  display: grid;
  gap: 8px;
}
#sideNav button {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  color: #d0d5dd;
  background: rgba(255,255,255,.04);
  text-align: left;
  font-weight: 850;
  cursor: pointer;
}
#sideNav button.active,
#sideNav button:hover {
  color: #fff;
  border-color: rgba(239,51,64,.45);
  background: linear-gradient(90deg, rgba(239,51,64,.28), rgba(255,255,255,.04));
}
.sidebar-card {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 10px;
  background: rgba(255,255,255,.06);
}
.sidebar-card strong,
.sidebar-card span { display: block; }
.sidebar-card strong { color: #98a2b3; font-size: 12px; text-transform: uppercase; }
.sidebar-card span { margin-top: 8px; font-size: 26px; font-weight: 950; color: #36d399; }
.app-shell {
  margin-left: 280px;
  padding: 28px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 22px;
}
.eyebrow {
  margin: 0 0 8px;
  color: var(--red);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}
h1 {
  margin: 0;
  font-size: clamp(38px, 5vw, 70px);
  line-height: .92;
  letter-spacing: 0;
}
h2, h3 { margin: 0; }
.muted { color: var(--muted); }
.top-actions, .actions {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}
.btn {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(15,23,42,.05);
}
.btn.primary {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
  box-shadow: 0 12px 26px rgba(239,51,64,.25);
}
.btn.ghost { background: transparent; box-shadow: none; }
.btn.danger {
  color: var(--red);
  border-color: rgba(239,51,64,.35);
  background: rgba(239,51,64,.04);
}
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.kpi {
  min-height: 124px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.kpi strong {
  display: block;
  margin-top: 14px;
  font-size: 32px;
  line-height: 1;
}
.kpi small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
.kpi.dark {
  background: #08090d;
  color: #fff;
}
.kpi.good strong { color: var(--green); }
.kpi.warn strong { color: var(--amber); }
.panel {
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}
.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 180px 180px auto;
  gap: 10px;
  margin-bottom: 12px;
}
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--ink);
}
textarea {
  min-height: 92px;
  padding-top: 11px;
  resize: vertical;
}
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.data-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}
.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}
.data-table th,
.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
.data-table tr:hover td { background: #fcfcfd; }
.name-cell {
  display: grid;
  gap: 3px;
}
.name-cell strong { font-size: 14px; }
.name-cell small { color: var(--muted); font-size: 12px; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
  background: #eef2f7;
  color: #475467;
}
.badge.good { color: #087a46; background: rgba(0,168,107,.10); }
.badge.warn { color: #9a6400; background: rgba(183,121,0,.12); }
.badge.bad { color: var(--red); background: rgba(239,51,64,.10); }
.split {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 16px;
}
.activity-list {
  display: grid;
  gap: 8px;
  max-height: 410px;
  overflow: auto;
  padding-right: 4px;
}
.activity-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.activity-row i {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #08090d;
  color: #fff;
  font-style: normal;
  font-size: 11px;
  font-weight: 950;
}
.activity-row span { font-weight: 900; }
.activity-row small { color: var(--muted); }
dialog {
  width: min(960px, calc(100vw - 28px));
  border: 0;
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 30px 90px rgba(15,23,42,.28);
}
dialog::backdrop { background: rgba(8,9,13,.55); }
.modal-card { padding: 20px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.doc-table .actions .btn {
  min-height: 34px;
  padding: 0 10px;
  font-size: 12px;
}
.document-form {
  max-height: 88vh;
  overflow: auto;
}
.doc-lines-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin: 18px 0 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.doc-lines {
  display: grid;
  gap: 8px;
}
.doc-line {
  display: grid;
  grid-template-columns: minmax(220px,1fr) 90px 140px 130px 48px;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}
.doc-line input {
  background: #fff;
}
.doc-line strong {
  text-align: right;
  font-size: 13px;
}
.doc-line .btn {
  min-width: 0;
  padding: 0;
}
.doc-total-box {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.doc-total-box span {
  min-width: 150px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
.doc-total-box strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 18px;
}
.doc-total-box span:last-child {
  background: #08090d;
  color: #98a2b3;
  border-color: #08090d;
}
.doc-total-box span:last-child strong {
  color: #fff;
}
label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}
.empty {
  padding: 30px;
  text-align: center;
  color: var(--muted);
}
@media (max-width: 1100px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .toolbar { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .sidebar {
    position: static;
    width: auto;
    min-height: auto;
  }
  #sideNav {
    grid-template-columns: repeat(2, minmax(0,1fr));
  }
  .app-shell {
    margin-left: 0;
    padding: 18px;
  }
  .topbar,
  .section-head {
    display: grid;
  }
  .grid,
  .form-grid,
  .toolbar {
    grid-template-columns: 1fr;
  }
  .doc-line {
    grid-template-columns: 1fr;
  }
  .doc-line strong {
    text-align: left;
  }
  .activity-row {
    grid-template-columns: 38px 1fr;
  }
  .activity-row small { grid-column: 2; }
}
