:root {
  color-scheme: dark;
  --bg: #07080a;
  --side: #050609;
  --panel: #101316;
  --panel2: #15191d;
  --line: #24292f;
  --line2: #303741;
  --text: #f4f7fb;
  --muted: #8993a3;
  --orange: #ff8a00;
  --orange2: #ffb000;
  --green: #16c172;
  --red: #ff4d5f;
  --yellow: #ffc145;
  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(--text);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.login-mode {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #101216, #08090c);
  border-radius: 8px;
  padding: 30px;
  box-shadow: 0 24px 70px rgba(0,0,0,.45);
}
.login-card h1 { margin: 16px 0 8px; font-size: 40px; }
.login-card p { color: var(--muted); line-height: 1.6; }

.app-shell:not(.login-mode) {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
}
.sidebar {
  background: var(--side);
  border-right: 1px solid var(--line);
  min-height: 100vh;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.brand strong {
  display: block;
  font-size: 15px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.brand small, .profile small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-top: 5px;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border: 10px solid var(--orange);
  background: transparent;
  display: inline-block;
}
.mini-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-top: 6px;
}
.sidebar-select {
  width: 100%;
  border: 1px solid var(--line);
  background: #090b0e;
  color: var(--text);
  border-radius: 6px;
  padding: 10px;
}
.nav {
  display: grid;
  gap: 7px;
  margin-top: 8px;
}
.nav button {
  display: flex;
  align-items: center;
  gap: 11px;
  color: #aab3c1;
  background: transparent;
  border: 0;
  border-radius: 6px;
  padding: 12px 10px;
  text-align: left;
}
.nav button span {
  width: 19px;
  color: var(--muted);
}
.nav button.active {
  background: #202124;
  color: var(--orange);
}
.nav button.active::after {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--orange);
  border-radius: 50%;
  margin-left: auto;
}
.profile {
  margin-top: auto;
  display: flex;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  background: #111419;
  border-radius: 6px;
  padding: 12px;
}
.profile img, .member-row img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #20242a;
}

.content {
  min-width: 0;
  padding: 0 32px 42px;
}
.topbar {
  height: 64px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 -32px 32px;
  padding: 0 32px;
}
.topbar span {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .12em;
}
.topbar strong { margin-left: 10px; }
.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn {
  border: 1px solid var(--line);
  background: #0b0d10;
  color: var(--text);
  border-radius: 2px;
  padding: 10px 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-size: 12px;
}
.btn.primary {
  background: var(--orange);
  color: #120b00;
  border-color: var(--orange);
}
.btn.ghost:hover, .btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 7px 9px; font-size: 11px; }
.link {
  border: 0;
  background: transparent;
  color: var(--orange);
  text-transform: uppercase;
  font-weight: 800;
  font-size: 11px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}
.stat-card {
  border: 1px solid var(--line);
  background: var(--panel);
  min-height: 118px;
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
}
.stat-card.accent { border-left: 3px solid var(--orange); }
.stat-card.warn { border-left: 3px solid var(--yellow); }
.stat-card span {
  display: block;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  font-size: 12px;
  margin-bottom: 9px;
}
.stat-card strong {
  font-size: 31px;
  letter-spacing: .03em;
}
.stat-card small {
  display: block;
  color: var(--muted);
  margin-top: 10px;
  text-transform: uppercase;
  font-size: 11px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 512px;
  gap: 24px;
  margin-bottom: 24px;
}
.panel {
  border: 1px solid var(--line);
  background: #0e1012;
  min-height: 160px;
}
.panel.wide { min-width: 0; }
.panel-head {
  min-height: 40px;
  border-bottom: 1px solid var(--line);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.panel-head h2 {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .12em;
}
.empty, .error {
  color: var(--muted);
  padding: 18px 20px;
  margin: 0;
}
.error { color: var(--red); font-weight: 800; }

.table-list {
  display: grid;
}
.table-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 116px 140px;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 12px 20px;
  border-bottom: 1px solid #1d2228;
}
.table-list.compact .table-row { grid-template-columns: 98px minmax(0, 1fr) 130px; }
.table-row:last-child { border-bottom: 0; }
.table-row b {
  color: var(--orange);
  font-size: 12px;
}
.table-row span strong {
  display: block;
  color: var(--text);
  font-weight: 800;
}
.table-row small {
  color: var(--muted);
  display: block;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.table-row > strong {
  justify-self: end;
  font-size: 15px;
}
.badge {
  justify-self: end;
  font-style: normal;
  font-size: 10px;
  font-weight: 900;
  padding: 4px 9px;
  border-radius: 3px;
  border: 1px solid var(--line2);
  color: var(--muted);
}
.badge.ok {
  color: var(--green);
  border-color: rgba(22,193,114,.35);
  background: rgba(22,193,114,.11);
}
.badge.new {
  color: var(--orange);
  border-color: rgba(255,138,0,.35);
  background: rgba(255,138,0,.12);
}
.green { color: var(--green); }
.red { color: var(--red); }

.field {
  display: grid;
  gap: 7px;
  margin: 0 0 13px;
}
.field span, .check {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 800;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #07090b;
  color: var(--text);
  border-radius: 3px;
  padding: 11px 12px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--orange); }
textarea { resize: vertical; }
form.panel { padding: 18px; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
}
.check {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 10px 0 14px;
}
.check input { width: auto; }

.template-grid, .member-list {
  display: grid;
  gap: 10px;
  padding: 16px;
}
.template-card {
  border: 1px solid var(--line);
  background: var(--panel2);
  padding: 14px;
}
.template-card b, .template-card span, .template-card small { display: block; }
.template-card span { color: var(--orange); margin-top: 4px; font-size: 12px; }
.template-card small { color: var(--muted); margin-top: 9px; }
.member-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  background: var(--panel2);
  padding: 12px;
}
.member-row small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.empty-state {
  min-height: 420px;
  display: grid;
  place-content: center;
  text-align: center;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 32px;
}
.empty-state h2 {
  margin: 0 0 10px;
  font-size: 30px;
}
.empty-state p {
  color: var(--muted);
  max-width: 560px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.72);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 20;
}
.modal {
  width: min(680px, 100%);
  max-height: min(780px, calc(100vh - 40px));
  overflow: auto;
  background: #0c0e11;
  border: 1px solid var(--line2);
  box-shadow: 0 30px 90px rgba(0,0,0,.55);
  padding: 22px;
  position: relative;
}
.modal h2 { margin: 0 0 18px; }
.modal-close {
  position: absolute;
  right: 14px;
  top: 12px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  background: #090b0d;
  color: var(--text);
}
.quote-preview {
  display: grid;
  gap: 8px;
  margin: 10px 0 16px;
}
.quote-preview div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel2);
  border: 1px solid var(--line);
  padding: 10px 12px;
}
.quote-preview span { color: var(--muted); }

#toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #11151a;
  border: 1px solid var(--line2);
  color: var(--text);
  padding: 12px 15px;
  transform: translateY(120%);
  opacity: 0;
  transition: .18s ease;
  z-index: 50;
}
#toast.show {
  transform: translateY(0);
  opacity: 1;
}
#toast.error { border-color: rgba(255,77,95,.5); color: var(--red); }

@media (max-width: 1040px) {
  .app-shell:not(.login-mode) { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; }
  .content { padding: 0 16px 34px; }
  .topbar { margin: 0 -16px 22px; padding: 12px 16px; height: auto; align-items: flex-start; flex-direction: column; }
  .cards, .dashboard-grid { grid-template-columns: 1fr; }
  .table-row, .table-list.compact .table-row { grid-template-columns: 1fr; align-items: start; }
  .table-row > strong, .badge { justify-self: start; }
  .form-grid { grid-template-columns: 1fr; }
}

