:root {
  color-scheme: light;
  --bg: #f5f7f3;
  --surface: #ffffff;
  --surface-soft: #eef3ed;
  --ink: #17201b;
  --muted: #657168;
  --line: #d9e2d8;
  --accent: #0f766e;
  --accent-strong: #075e56;
  --blue: #2563eb;
  --amber: #b7791f;
  --red: #b42318;
  --green: #137a4b;
  --shadow: 0 14px 36px rgba(28, 43, 36, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button, input, select, textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  background: #0e211d;
  color: #e7f4ef;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #d8f3dc;
  color: #063b34;
  font-weight: 800;
}

.brand strong { display: block; font-size: 16px; }
.brand span { color: #a9bbb4; font-size: 12px; }

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  color: #d7e5df;
  background: transparent;
  text-align: left;
  font-size: 14px;
}

.nav button.active {
  background: #d8f3dc;
  color: #063b34;
  font-weight: 700;
}

.main {
  min-width: 0;
  padding: 22px 28px 32px;
}

.topbar {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.page-title h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.16;
}

.page-title p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
}

.search {
  width: min(40vw, 360px);
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--ink);
}

.btn {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  white-space: nowrap;
}

.btn.secondary {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
}

.btn.warning { background: var(--amber); }
.btn.danger { background: var(--red); }

.grid {
  display: grid;
  gap: 14px;
}

.grid.kpi {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-title h2 {
  margin: 0;
  font-size: 17px;
}

.panel-title span, .small {
  color: var(--muted);
  font-size: 12px;
}

.kpi-card b {
  display: block;
  font-size: 26px;
  line-height: 1.1;
  margin: 6px 0;
}

.kpi-card span { color: var(--muted); font-size: 13px; }

.layout-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(300px, 0.7fr);
  gap: 14px;
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th, td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-weight: 700;
  background: var(--surface-soft);
}

tr:hover td { background: #f9fbf8; }

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.tag.green { background: #e6f6ec; color: var(--green); }
.tag.blue { background: #e8f0ff; color: var(--blue); }
.tag.amber { background: #fff3da; color: var(--amber); }
.tag.red { background: #fee7e5; color: var(--red); }

.list {
  display: grid;
  gap: 10px;
}

.row-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.row-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.row-card strong { font-size: 14px; }
.row-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini {
  min-height: 30px;
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.mini.primary { background: var(--accent); color: white; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-card h1 { margin: 0 0 8px; font-size: 28px; }
.login-card p { color: var(--muted); margin: 0 0 18px; line-height: 1.5; }

.form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field input, .field select, .field textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 9px 10px;
}

.field textarea { min-height: 84px; resize: vertical; }

.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
  z-index: 10;
  display: grid;
  justify-items: end;
}

.drawer {
  width: min(560px, 100%);
  height: 100%;
  overflow: auto;
  background: var(--surface);
  padding: 20px;
}

.drawer header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 16px;
}

.drawer h2 { margin: 0; font-size: 22px; }
.drawer p { color: var(--muted); margin: 4px 0 0; }

.split-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.code-block {
  max-height: 62vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
  font-size: 12px;
  line-height: 1.5;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: #10241f;
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 20;
  font-size: 13px;
}

.hidden { display: none !important; }

@media (max-width: 920px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    height: 74px;
    z-index: 8;
    padding: 8px 10px;
  }
  .brand { display: none; }
  .nav {
    grid-auto-flow: column;
    grid-auto-columns: minmax(72px, 1fr);
    overflow-x: auto;
  }
  .nav button {
    justify-content: center;
    min-height: 48px;
    padding: 0 8px;
    font-size: 12px;
  }
  .main { padding: 18px 14px 96px; }
  .topbar { align-items: stretch; flex-direction: column; }
  .toolbar { align-items: stretch; }
  .search { width: 100%; }
  .grid.kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-2 { grid-template-columns: 1fr; }
  .split-form { grid-template-columns: 1fr; }
  .page-title h1 { font-size: 24px; }
}
