:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #607080;
  --line: #d9e0e6;
  --brand: #0f6b68;
  --brand-dark: #0a4e4c;
  --accent: #b7791f;
  --danger: #b42318;
  --ok: #16703c;
  --warn: #9a6700;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button {
  border: 0;
  border-radius: 7px;
  background: var(--brand);
  color: #fff;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
}
button:hover { background: var(--brand-dark); }
button.ghost { background: transparent; color: #d8f4f0; border: 1px solid rgba(255,255,255,.25); }
button.danger { background: var(--danger); }
button.mini {
  padding: 6px 8px;
  font-size: 12px;
  border-radius: 6px;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 10px 11px;
  color: var(--ink);
}
textarea { resize: vertical; }
label { display: grid; gap: 6px; font-size: 13px; color: #31404f; font-weight: 700; }
h1, h2, p { margin-top: 0; }
h1 { font-size: 26px; margin-bottom: 0; letter-spacing: 0; }
h2 { font-size: 17px; margin-bottom: 16px; }

.app-shell { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.sidebar {
  background: #102323;
  color: #f2fbf9;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; }
.sidebar-brand small { display: block; color: #9fc4be; margin-top: 3px; }
.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e4b860;
  color: #102323;
  font-weight: 900;
  letter-spacing: 0;
}
.brand-mark.small { width: 42px; height: 42px; font-size: 13px; }
nav { display: grid; gap: 8px; }
.nav-item {
  text-align: left;
  background: transparent;
  color: #c8dedb;
  border: 1px solid transparent;
  padding: 12px;
}
.nav-item.active, .nav-item:hover { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.12); color: #fff; }
.admin-only { display: none; }
.is-admin .admin-only { display: block; }
.sidebar-footer { margin-top: auto; display: grid; gap: 10px; color: #b8d7d2; }
.workspace { padding: 28px; overflow: auto; }
.view { display: none; }
.view.active { display: block; }
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}
.eyebrow {
  text-transform: uppercase;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  margin-bottom: 6px;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stats-grid div, .panel, .table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(21, 35, 45, .04);
}
.stats-grid div { padding: 18px; }
.stats-grid span { display: block; font-size: 28px; font-weight: 900; }
.stats-grid small { color: var(--muted); font-weight: 700; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
th { color: #4c5b68; font-size: 12px; text-transform: uppercase; background: #f9fbfb; letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.badge.pending, .badge.open, .badge.investigating { background: #fff4d6; color: var(--warn); }
.badge.approved, .badge.closed, .badge.ok { background: #daf5e5; color: var(--ok); }
.badge.rejected, .badge.low { background: #fde1df; color: var(--danger); }
.filter-row { margin-bottom: 14px; max-width: 260px; }
.settings-grid { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(280px, .7fr); gap: 16px; margin-bottom: 16px; }
.panel { padding: 18px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.panel-head h2 { margin: 0; }
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 7px;
  background: var(--brand);
  color: #fff;
  padding: 8px 12px;
  text-decoration: none;
  font-weight: 800;
  white-space: nowrap;
}
.button-link:hover { background: var(--brand-dark); }
.stack { display: grid; gap: 14px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
dialog { border: 0; border-radius: 8px; padding: 0; width: min(760px, calc(100vw - 28px)); box-shadow: 0 24px 60px rgba(0,0,0,.24); }
dialog::backdrop { background: rgba(9, 19, 24, .55); }
.dialog-form { padding: 20px; }
.dialog-form header { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.dialog-form header button { width: 38px; height: 38px; padding: 0; background: #e9eef2; color: #25313d; font-size: 22px; }
.outbox { display: grid; gap: 10px; }
.outbox article { border: 1px solid var(--line); border-radius: 7px; padding: 12px; background: #fbfcfd; }
.outbox code { display: block; white-space: pre-wrap; word-break: break-word; color: #52616f; margin-top: 6px; }
.audit-list, .backup-list { display: grid; gap: 10px; }
.audit-list article, .backup-list article, .user-list article {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfd;
  padding: 12px;
  display: grid;
  gap: 6px;
}
.user-list { display: grid; gap: 10px; }
.user-list article {
  grid-template-columns: 1fr auto;
  align-items: center;
}
.user-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.audit-list small, .backup-list small, .user-list small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}
.audit-list code, .backup-list code {
  display: block;
  color: #52616f;
  word-break: break-word;
}
.approver-preview {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fbfb;
  padding: 12px;
}
.approver-preview strong { display: block; margin-bottom: 8px; }
.approver-preview ol, .category-list ol { margin: 0; padding-left: 20px; color: #40505f; }
.category-list { display: grid; gap: 12px; }
.category-list article {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfd;
  padding: 12px;
}
.category-list header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.category-list header small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}
.category-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 6px 0;
}
.drop-field {
  position: relative;
  border: 1px dashed #8eb4b0;
  border-radius: 8px;
  background: #f7fbfa;
  padding: 14px;
  min-height: 116px;
  justify-content: center;
  color: #31404f;
  transition: border-color .15s ease, background .15s ease;
}
.drop-field input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.drop-field span {
  display: block;
  font-size: 15px;
  color: var(--brand);
}
.drop-field small {
  display: block;
  color: var(--muted);
  font-weight: 600;
  word-break: break-word;
}
.drop-field.dragging {
  border-color: var(--brand);
  background: #edf8f5;
}
#toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #102323;
  color: #fff;
  padding: 12px 16px;
  border-radius: 7px;
  opacity: 0;
  transform: translateY(10px);
  transition: .2s ease;
}
#toast.show { opacity: 1; transform: translateY(0); }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #102323 0%, #243a3a 48%, #f2f5f2 48%);
}
.login-shell, .approval-card {
  width: min(440px, calc(100vw - 28px));
}
.login-panel, .approval-card {
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(255,255,255,.6);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 28px 80px rgba(0,0,0,.18);
}
.login-panel .brand-mark { margin-bottom: 18px; }
.login-panel p, .approval-card p { color: var(--muted); line-height: 1.55; }
.error { color: var(--danger); font-weight: 700; min-height: 20px; }
.info { color: var(--brand); font-weight: 700; min-height: 20px; }
.login-panel hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.approval-card dl { display: grid; gap: 10px; }
.approval-card dl div { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.approval-card dt { color: var(--muted); font-weight: 800; }
.approval-card dd { margin: 0; font-weight: 800; }
.approval-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  nav { grid-template-columns: 1fr 1fr; }
  .workspace { padding: 18px; }
  .page-head, .two-col, .settings-grid { grid-template-columns: 1fr; display: grid; }
  .stats-grid { grid-template-columns: 1fr; }
  .user-list article { grid-template-columns: 1fr; }
  .user-status { justify-content: flex-start; }
}
