:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #657282;
  --line: #d9e1ea;
  --primary: #1f7a8c;
  --primary-dark: #135c6b;
  --danger: #b42318;
  --success: #047857;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 14px;
}
a { color: var(--primary); text-decoration: none; }
code { background: #eef3f7; padding: 2px 5px; border-radius: 4px; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 230px;
  background: #18222f;
  color: white;
  padding: 22px 16px;
}
.brand { font-weight: 800; font-size: 18px; margin-bottom: 22px; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar a {
  color: #dbe7ef;
  padding: 10px 12px;
  border-radius: 7px;
}
.sidebar a:hover { background: #263547; color: white; }

.main {
  margin-left: 230px;
  padding: 24px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.topbar h1 { margin: 0; font-size: 28px; }
.topbar form { display: flex; align-items: center; gap: 10px; color: var(--muted); }

.panel, .stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.wide { overflow-x: auto; }
.panel h2 { margin: 0 0 14px; font-size: 18px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat span { color: var(--muted); display: block; margin-bottom: 8px; }
.stat strong { font-size: 26px; }
.grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}
.actions form { display: flex; gap: 8px; flex-wrap: wrap; }

table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}
th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}
.actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 360px;
}
.actions-cell form { display: flex; gap: 5px; align-items: center; }
.actions-cell input[type="number"] { width: 74px; }
.actions-cell.compact { min-width: 220px; }
.muted { color: var(--muted); }

label { display: grid; gap: 6px; color: var(--muted); font-weight: 600; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  color: var(--ink);
  background: white;
  font: inherit;
}
textarea { min-height: 110px; resize: vertical; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.full { grid-column: 1 / -1; }
.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}
.checkbox input { width: auto; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 12px;
  background: white;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}
.button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.button.primary:hover { background: var(--primary-dark); }
.button.ghost { background: transparent; color: var(--muted); }
.button.danger { background: var(--danger); border-color: var(--danger); color: white; }
.button.danger:hover { filter: brightness(0.95); }
.button.small { padding: 6px 9px; font-size: 12px; }
.badge {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e7f2f4;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
}
.flash {
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  background: #eef3f7;
}
.flash.success { color: var(--success); background: #ecfdf3; }
.flash.error { color: var(--danger); background: #fff1f0; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #eef3f7;
}
.login-card {
  width: min(420px, calc(100vw - 32px));
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  display: grid;
  gap: 14px;
}
.login-card h1 { margin: 0 0 6px; }

@media (max-width: 900px) {
  .sidebar {
    position: static;
    width: auto;
  }
  .sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main { margin-left: 0; padding: 16px; }
  .stats-grid, .grid-two, .form-grid { grid-template-columns: 1fr; }
  .actions { align-items: stretch; flex-direction: column; }
  .topbar { align-items: flex-start; flex-direction: column; }
}

