:root {
  /* Same design tokens as WeekOps -- warm off-white, near-black accent,
     DM Mono/DM Sans -- so the two feel like one product. */
  --bg-page: #f5f3ef;
  --surface: #ffffff;
  --surface2: #f0ede8;
  --border: #ddd9d2;
  --border-strong: #b8b2a8;
  --text: #1a1816;
  --heading: #1a1816;
  --muted: #5a5650;
  --text-muted: #9a948e;

  --accent: #1a1816;
  --accent-hover: #34302c;
  --accent-soft: rgba(26, 24, 22, 0.06);

  --success: #2d6a4f;
  --success-bg: #d8f3dc;
  --success-border: #95d5a8;
  --error: #9b1c1c;
  --error-bg: #fde8e8;
  --error-border: #f8a8a8;
  --pending: #b5580a;
  --pending-bg: #fef3e2;
  --pending-border: #f4c07a;
  --cancelled: #5b21b6;
  --cancelled-bg: #ede9fe;
  --cancelled-border: #c4b5fd;

  --sidebar-bg: var(--surface);
  --sidebar-border: var(--border);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10), 0 2px 4px rgba(0,0,0,0.06);

  --radius: 6px;
  --radius-sm: 4px;

  --mono: 'DM Mono', monospace;
  --sans: 'DM Sans', sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg-page);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
  font-size: 14px;
}

a { color: var(--text); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); text-decoration-color: currentColor; }

h1 {
  font-size: 1.3em;
  font-weight: 600;
  color: var(--heading);
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

.muted { color: var(--muted); }
.muted.small { font-size: 0.85em; margin-top: 16px; }

/* ---------- app shell (authenticated pages) ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  color: var(--text);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 6px 20px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.68em;
  font-family: var(--mono);
  letter-spacing: 0.01em;
  flex-shrink: 0;
}

.brand-word {
  font-weight: 600;
  font-size: 1.02em;
  color: var(--heading);
  letter-spacing: -0.01em;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
  flex: 1;
}

.side-nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.9em;
  font-weight: 500;
  text-decoration: none;
}

.side-nav a:hover { background: var(--surface2); color: var(--text); }

.side-nav a.active {
  background: none;
  color: var(--text);
  font-weight: 600;
}

/* A straight indicator line, drawn as its own flat rectangle rather than an
   inset box-shadow -- a box-shadow follows the link's border-radius and
   comes out curved at the top/bottom, which reads as a bracket, not a line. */
.side-nav a.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}

.nav-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.nav-icon svg { width: 17px; height: 17px; }
.side-nav a:hover .nav-icon { color: var(--text); }
.side-nav a.active .nav-icon { color: var(--accent); }

.side-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 6px 8px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.72em;
  font-family: var(--mono);
  flex-shrink: 0;
}

.side-user-info { overflow: hidden; }

.side-user-name {
  font-size: 0.85em;
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-user-role {
  font-size: 0.72em;
  color: var(--text-muted);
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

.logout-link {
  display: block;
  text-align: center;
  margin-top: 6px;
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 0.82em;
  color: var(--text-muted);
  text-decoration: none;
  font-family: var(--mono);
}
.logout-link:hover { background: var(--surface2); color: var(--text); }

.side-version {
  text-align: center;
  margin-top: 2px;
  font-size: 0.68em;
  color: var(--text-muted);
  font-family: var(--mono);
  letter-spacing: 0.02em;
  opacity: 0.7;
}

.main-col { flex: 1; min-width: 0; }

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 30px 32px 64px;
}

/* ---------- auth shell (login / activate / verify) ---------- */

.auth-body { background: var(--bg-page); }

.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px;
}

.brand-auth { display: flex; align-items: center; gap: 9px; text-decoration: none; }
.brand-auth .brand-word { color: var(--heading); }

.auth-container { width: 100%; max-width: 420px; }

/* ---------- cards / forms ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin: 16px 0;
  box-shadow: var(--shadow-sm);
}

.card.narrow { max-width: 420px; }

form label {
  display: block;
  font-size: 0.78em;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  font-family: var(--mono);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

input[type="email"],
input[type="text"],
input[type="date"],
input[type="file"],
select {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95em;
  margin-bottom: 14px;
  font-family: var(--sans);
  transition: border-color 0.12s;
}
input[type="file"] { height: auto; padding: 8px 11px; }

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

button, .link-button, .button-link {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  padding: 0 16px;
  height: 36px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  cursor: pointer;
  font-size: 0.9em;
  font-family: var(--sans);
  transition: opacity 0.12s, background 0.12s, border-color 0.12s;
}

button:hover, .button-link:hover { opacity: 0.85; color: #fff; }

.link-button {
  background: none;
  color: var(--error);
  border: none;
  padding: 0;
  height: auto;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--error-border);
}
.link-button:hover { opacity: 1; color: #7a1616; background: none; text-decoration-color: currentColor; }

.button-link { display: inline-flex; align-items: center; text-decoration: none; }

.upload-form { display: flex; gap: 10px; align-items: center; }
.upload-form input[type="file"] { margin-bottom: 0; flex: 1; }

.flashes { margin-bottom: 18px; }
.flash {
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 0.88em;
  border: 1px solid;
}
.flash-error { background: var(--error-bg); color: var(--error); border-color: var(--error-border); }
.flash-success { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }

.qr {
  display: block;
  margin: 16px auto;
  width: 220px;
  height: 220px;
  background: #fff;
  padding: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.secret {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  word-break: break-all;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.92em;
}

/* ---------- tables ---------- */

.files-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.files-table th, .files-table td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9em;
}

.files-table th {
  color: var(--text-muted);
  font-weight: 500;
  background: var(--surface2);
  font-size: 0.72em;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.files-table tbody tr:last-child td { border-bottom: none; }
.files-table tbody tr:hover { background: #fdfcfa; }

.actions { display: flex; gap: 14px; align-items: center; }
.actions form { margin: 0; }

.tag {
  font-size: 0.65em;
  background: var(--accent);
  color: #fff;
  padding: 2px 7px;
  border-radius: 3px;
  font-weight: 600;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: var(--mono);
}

details { margin: 8px 0 16px; color: var(--muted); font-size: 0.9em; }
details summary { cursor: pointer; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72em;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-family: var(--mono);
  border: 1px solid;
}
.pill-approved  { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.pill-rejected  { background: var(--error-bg); color: var(--error); border-color: var(--error-border); }
.pill-pending   { background: var(--pending-bg); color: var(--pending); border-color: var(--pending-border); }
.pill-cancelled { background: var(--surface2); color: var(--text-muted); border-color: var(--border-strong); }

.tag-type {
  background: var(--surface2);
  color: var(--heading);
  border: 1px solid var(--border);
  font-weight: 600;
}

.approved-by { font-size: 0.85em; }
.approved-by div { margin-bottom: 2px; }

.files-table select {
  width: auto;
  height: 30px;
  margin-bottom: 0;
  padding: 0 8px;
  font-size: 0.85em;
}

.inline-form {
  display: inline-block;
  margin: 0 6px 0 0 !important;
}

/* ---------- summary dashboard (KPI tiles / mini-stats / upcoming) ---------- */

.section-heading {
  font-size: 0.72em;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 22px 0 10px;
  font-family: var(--mono);
}
.section-heading:first-child { margin-top: 4px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 4px;
}

.kpi-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 15px;
  box-shadow: var(--shadow-sm);
}

/* Tone accents follow WeekOps's own card language: a tinted border plus a
   colored value, the same treatment as its stat-chips and task cards --
   not a left accent bar. */
.kpi-tile.tone-pending   { border-color: var(--pending-border); }
.kpi-tile.tone-approved  { border-color: var(--success-border); }
.kpi-tile.tone-rejected  { border-color: var(--error-border); }
.kpi-tile.tone-cancelled { border-color: var(--cancelled-border); }

.kpi-tile.tone-pending   .kpi-value { color: var(--pending); }
.kpi-tile.tone-approved  .kpi-value { color: var(--success); }
.kpi-tile.tone-rejected  .kpi-value { color: var(--error); }
.kpi-tile.tone-cancelled .kpi-value { color: var(--cancelled); }

.kpi-value {
  font-size: 1.6em;
  font-weight: 500;
  color: var(--heading);
  line-height: 1.15;
  font-variant-numeric: proportional-nums;
  font-family: var(--mono);
}

.kpi-label {
  font-size: 0.74em;
  color: var(--text-muted);
  margin-top: 3px;
  font-weight: 500;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

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

.mini-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 13px;
  font-size: 0.84em;
  color: var(--muted);
  font-family: var(--mono);
  box-shadow: var(--shadow-sm);
}
.mini-stat b { color: var(--heading); font-weight: 600; }

.upcoming-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upcoming-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.88em;
  box-shadow: var(--shadow-sm);
}
.upcoming-item .upcoming-date { font-weight: 600; color: var(--heading); min-width: 108px; font-family: var(--mono); }
.upcoming-item .upcoming-duration { color: var(--text-muted); font-size: 0.9em; font-family: var(--mono); }

/* ---------- mobile top bar / drawer sidebar ---------- */

.mobile-topbar {
  display: none;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  /* Stays above the drawer + backdrop so the hamburger is always reachable
     to close the drawer again, even while it's open. */
  z-index: 60;
}
.mobile-topbar .brand-word { color: var(--heading); }

.hamburger {
  background: none;
  border: none;
  padding: 6px;
  width: 40px;
  height: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  flex-shrink: 0;
}
.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26, 24, 22, 0.35);
  z-index: 45;
}
.sidebar-backdrop.open { display: block; }

/* ---------- scrollbar (match WeekOps) ---------- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; }

/* ---------- responsive breakpoint ---------- */

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }

  .mobile-topbar { display: flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 260px;
    max-width: 82vw;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 50;
    box-shadow: var(--shadow-md);
    /* Room for the fixed topbar (z-index above the drawer) so the first
       nav link isn't hidden underneath it. */
    padding-top: 76px;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar > .brand { display: none; } /* the mobile topbar already shows the brand */

  .container { padding: 20px 16px 56px; }

  h1 { font-size: 1.2em; }

  .card, .card.narrow { padding: 18px; max-width: 100%; }

  .page-head { align-items: flex-start; }
  .page-head .button-link { width: 100%; text-align: center; justify-content: center; }

  button, .link-button, .button-link, input, select {
    font-size: 1em;
  }
  button, .button-link { min-height: 44px; }

  .upload-form { flex-direction: column; align-items: stretch; }

  /* stacked "card" tables instead of a wide grid */
  .files-table thead { display: none; }
  .files-table, .files-table tbody, .files-table tr, .files-table td {
    display: block;
    width: 100%;
  }
  .files-table { border: none; box-shadow: none; background: none; }
  .files-table tbody tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 6px 0;
    margin-bottom: 12px;
  }
  .files-table tbody tr:last-child { margin-bottom: 0; }
  .files-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    text-align: right;
  }
  .files-table td:last-child { border-bottom: none; }
  .files-table td::before {
    content: attr(data-label);
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.72em;
    font-family: var(--mono);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: left;
    flex-shrink: 0;
  }
  .files-table td.actions, .files-table td.stacked-value {
    justify-content: flex-end;
    text-align: right;
  }
  .files-table .actions { justify-content: flex-end; }

  .files-table td.approved-by {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
  }
  .files-table td.approved-by::before { margin-bottom: 4px; }

  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 1.4em; }
}
