:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-alt: #eef2f6;
  --text: #17202a;
  --muted: #657282;
  --line: #d9e0e8;
  --primary: #1769aa;
  --primary-dark: #0f4d7d;
  --success: #16845f;
  --warning: #b7791f;
  --danger: #c2413b;
  --violet: #6b5dd3;
  --shadow: 0 16px 40px rgba(19, 34, 56, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select {
  font: inherit;
}
button {
  border: 0;
  cursor: pointer;
}
.hidden { display: none !important; }
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(23, 105, 170, 0.10), transparent 38%),
    linear-gradient(315deg, rgba(22, 132, 95, 0.10), transparent 42%),
    var(--bg);
}
.login-panel {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: var(--text);
  color: #fff;
  border-radius: 8px;
  font-weight: 800;
}
h1, h2, h3, p { margin: 0; }
.login-panel h1 {
  margin-top: 18px;
  font-size: 28px;
}
.login-panel p {
  margin: 6px 0 22px;
  color: var(--muted);
}
label {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}
input, select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 9px 11px;
  outline: none;
}
input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.12);
}
.primary-action, .secondary-action, .ghost-action {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 750;
}
.primary-action {
  width: 100%;
  background: var(--primary);
  color: #fff;
}
.primary-action:hover { background: var(--primary-dark); }
.secondary-action {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
}
.ghost-action {
  background: transparent;
  color: var(--muted);
}
svg { width: 17px; height: 17px; }
.error-text {
  color: var(--danger) !important;
  min-height: 20px;
  margin-top: 12px !important;
}
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  background: #111a24;
  color: #fff;
  display: flex;
  flex-direction: column;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 20px;
}
.sidebar-brand span {
  display: block;
  color: #a9b7c6;
  font-size: 12px;
  margin-top: 2px;
}
.sidebar nav {
  display: grid;
  gap: 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border-radius: 6px;
  padding: 0 10px;
  background: transparent;
  color: #c5d1dc;
  text-align: left;
}
.nav-item.active, .nav-item:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}
#logoutButton { margin-top: auto; justify-content: flex-start; color: #c5d1dc; }
.main {
  min-width: 0;
  padding: 24px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.topbar h2 { font-size: 26px; }
.topbar p { color: var(--muted); margin-top: 4px; }
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(19, 34, 56, 0.04);
}
.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}
.metric strong {
  display: block;
  font-size: 26px;
  margin-top: 8px;
}
.metric small {
  color: var(--muted);
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.panel h3 { font-size: 17px; margin-bottom: 12px; }
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}
.toolbar input { max-width: 360px; }
.table-wrap {
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}
th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}
th {
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}
tr:last-child td { border-bottom: 0; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}
.badge.pending { background: #fff3cd; color: var(--warning); }
.badge.approved { background: #dceeff; color: var(--primary); }
.badge.completed, .badge.success { background: #dff4ea; color: var(--success); }
.badge.rejected, .badge.failed, .badge.blocked { background: #fde2e1; color: var(--danger); }
.badge.user { background: #e9edf2; color: var(--muted); }
.badge.admin, .badge.ops { background: #e6e2ff; color: var(--violet); }
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.mini-btn {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 5px;
  padding: 0 9px;
  background: var(--surface-alt);
  color: var(--text);
  font-weight: 700;
}
.mini-btn.danger { color: var(--danger); }
.mini-btn.success { color: var(--success); }
.split {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 360px;
  gap: 16px;
}
.form-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.check-row {
  grid-template-columns: 20px 1fr;
  align-items: center;
  color: var(--text);
}
.check-row input {
  min-height: auto;
  width: 16px;
}
.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 30px;
  color: var(--muted);
  background: rgba(255,255,255,0.55);
}
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #111a24;
  color: #fff;
  border-radius: 7px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  max-width: 360px;
}
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 12px; }

@media (max-width: 920px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
  }
  .sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .main { padding: 16px; }
  .topbar, .toolbar { align-items: stretch; flex-direction: column; }
  .metric-grid { grid-template-columns: 1fr; }
}
