:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d9dee7;
  --text: #17202a;
  --muted: #657083;
  --accent: #116466;
  --accent-2: #c84b31;
  --ok: #1d7f4f;
  --bad: #b42318;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button, input, select, textarea { font: inherit; }
button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 7px;
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
}
button.primary { background: var(--accent); color: white; border-color: var(--accent); }
button.danger { color: var(--bad); }
button.icon { width: 36px; padding: 0; }
button:disabled { opacity: .55; cursor: wait; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--text);
  min-height: 38px;
  padding: 8px 10px;
}
textarea { resize: vertical; min-height: 86px; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login form {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  display: grid;
  gap: 14px;
}
.brand { font-size: 30px; font-weight: 750; letter-spacing: 0; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 232px 1fr; }
.sidebar {
  background: #1f2933;
  color: white;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.sidebar .brand { font-size: 24px; }
.nav { display: grid; gap: 6px; }
.nav a {
  color: #e6edf3;
  text-decoration: none;
  border-radius: 7px;
  padding: 10px 12px;
}
.nav a.active, .nav a:hover { background: rgba(255,255,255,.12); }
.userbox { margin-top: auto; color: #cbd5df; display: grid; gap: 8px; }

.main { padding: 22px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 18px; }
h1 { font-size: 24px; margin: 0; letter-spacing: 0; }
h2 { font-size: 18px; margin: 0 0 12px; letter-spacing: 0; }
.grid { display: grid; gap: 14px; }
.metrics { grid-template-columns: repeat(4, minmax(160px, 1fr)); }
.metric, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.metric .value { font-size: 26px; font-weight: 760; margin-top: 6px; }
.metric .label { color: var(--muted); font-size: 13px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.toolbar > * { width: auto; min-width: 180px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: white; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; color: var(--muted); background: #fbfcfd; }
td.money, th.money { text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.error { color: var(--bad); }
.ok { color: var(--ok); }
.forms { display: grid; grid-template-columns: minmax(260px, 360px) 1fr; gap: 14px; align-items: start; }
form.stack, .stack { display: grid; gap: 10px; }
.row { display: flex; gap: 8px; align-items: center; }
.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(560px, 100%);
  background: white;
  border-left: 1px solid var(--line);
  box-shadow: -16px 0 32px rgba(0,0,0,.14);
  padding: 18px;
  overflow: auto;
  z-index: 10;
}
.drawer-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.28); z-index: 9; }
.comment { border-top: 1px solid var(--line); padding: 10px 0; }
.toast { margin-bottom: 12px; color: var(--bad); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .metrics, .forms { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
}
