:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1f2733;
  --muted: #6b7685;
  --line: #e3e8ef;
  --primary: #2563eb;
  --primary-d: #1d4ed8;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
h2 { margin: 0 0 16px; }
h3 { margin: 24px 0 8px; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
hr { border: none; border-top: 1px solid var(--line); margin: 18px 0; }

/* ---- Auth ---- */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  background: var(--card);
  width: 100%;
  max-width: 380px;
  padding: 32px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.auth-logo { display: block; width: 120px; height: auto; margin: 0 auto 16px; }
.brand { margin: 0 0 4px; font-size: 22px; text-align: center; }
.auth-card > .muted { text-align: center; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }

/* ---- Forms ---- */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
input, select, textarea {
  font: inherit;
  color: var(--ink);
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfd3ff; border-color: var(--primary); }
textarea { resize: vertical; }

.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  background: #eef1f5;
  color: var(--ink);
  text-decoration: none;
  display: inline-block;
}
.btn:hover { filter: brightness(0.97); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-d); }
.btn.ghost { background: #fff; border-color: var(--line); }
.btn.link { background: none; border: none; color: var(--primary); padding: 0; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.approve { background: #e7f6ec; color: var(--green); }
.btn.deny { background: #fbe9e9; color: var(--red); }

.form-error { color: var(--red); font-size: 13px; min-height: 0; margin: 0; }
.form-error.ok { color: var(--green); }

/* ---- App layout ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 6px 22px;
  min-height: 60px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar-brand { display: flex; flex-direction: column; align-items: center; gap: 2px; font-weight: 700; line-height: 1.1; }
.topbar-logo { height: 34px; width: auto; }
.hamburger { display: none; background: none; border: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink); padding: 4px 8px; }
.tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.tab {
  border: none;
  background: none;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.tab:hover { background: #f0f3f7; }
.tab.active { color: var(--primary); background: #eaf1ff; }
.topbar-user { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }

main { max-width: 980px; margin: 26px auto; padding: 0 22px; }
.view { display: none; }
.view.active { display: block; }
.view-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 620px) { .form-grid { grid-template-columns: 1fr; } }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
th { background: #f8fafc; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tr:last-child td { border-bottom: none; }
.empty { padding: 18px; color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; }

.badge { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; text-transform: capitalize; }
.badge.pending { background: #fef3c7; color: var(--amber); }
.badge.approved { background: #dcfce7; color: var(--green); }
.badge.denied { background: #fee2e2; color: var(--red); }

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

.icon-btn { background: none; border: 1px solid var(--line); border-radius: 8px; color: var(--red); padding: 5px 9px; cursor: pointer; display: inline-flex; align-items: center; }
.icon-btn:hover { background: #fbe9e9; }

/* Kebab (⋮) actions menu */
.actions-cell { text-align: right; }
.kebab { position: relative; display: inline-block; }
.kebab-btn { background: #fff; border: 1px solid var(--line); border-radius: 8px; font-size: 18px; line-height: 1; padding: 3px 11px; cursor: pointer; color: var(--ink); }
.kebab-btn:hover { background: #f0f3f7; }
.kebab-menu { display: none; position: absolute; right: 0; top: 100%; margin-top: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); min-width: 170px; z-index: 30; overflow: hidden; }
.kebab-menu.open { display: block; }
.kebab-menu button { display: block; width: 100%; text-align: left; background: none; border: none; padding: 10px 14px; font: inherit; cursor: pointer; color: var(--ink); }
.kebab-menu button:hover { background: #f0f3f7; }
.kebab-menu button.danger { color: var(--red); }
/* let the menu escape the table container instead of being clipped */
#user-list { overflow: visible; }
.cell-note { color: var(--muted); font-size: 13px; }

select.role-select { padding: 5px 8px; font-size: 13px; width: auto; }

input[type="checkbox"] { width: auto; }
.approves-group { display: flex; gap: 14px; flex-wrap: wrap; }
.chk { display: flex; align-items: center; gap: 5px; font-weight: 500; color: var(--ink); text-transform: capitalize; cursor: pointer; }
.approves-label { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 11px 18px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 50;
  font-weight: 600;
}
.toast.err { background: var(--red); }

/* ---- Mobile: hamburger nav ---- */
@media (max-width: 760px) {
  .topbar { gap: 10px; padding: 6px 14px; }
  .hamburger { display: block; }
  #user-label { display: none; }
  .topbar-brand { flex: 1; align-items: flex-start; }
  .tabs {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 2px;
    background: var(--card);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
    padding: 8px;
  }
  .tabs.open { display: flex; }
  .tab { width: 100%; text-align: left; padding: 12px 14px; border-radius: 6px; }
  main { padding: 0 14px; margin: 18px auto; }
  .view-head { gap: 8px; }
  .form-grid { grid-template-columns: 1fr; }

  /* Stack tables into cards so nothing scrolls sideways on phones */
  .table-wrap { overflow-x: visible; }
  table, thead, tbody, tr, th, td { display: block; }
  thead { display: none; }
  table { border: none; background: transparent; }
  tbody tr {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    padding: 2px 12px;
  }
  tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    text-align: right;
    border: none;
    border-bottom: 1px solid var(--line);
    padding: 10px 0;
  }
  tbody tr td:last-child { border-bottom: none; }
  td[data-label]::before {
    content: attr(data-label);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--muted);
    text-align: left;
  }
  td.row-actions, td.actions-cell { justify-content: flex-end; flex-wrap: wrap; }
  select.role-select { width: auto; max-width: 60%; }
}
