:root {
  /* Palette drawn from the Coldstream Guards Garter Star logo:
     deep navy, dark red (#770C12), gold and silver. */
  --bg: #0c1320;
  --bg-2: #101a2c;
  --panel: #15223a;
  --panel-2: #1a2b47;
  --line: #293a58;
  --olive: #1b3255;
  --olive-2: #24406b;
  --text: #e9ecf2;
  --muted: #97a3ba;
  --navy: #12233f;
  --navy-2: #1e3a63;
  --red: #770c12;
  --red-2: #a01c24;
  --gold: #c9a94a;
  --gold-2: #e6cd76;
  --silver: #c3c7cc;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Barlow', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

/* Layout */
.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--bg-2), #08101c);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--line);
}
.sidebar-logo { width: 46px; height: 46px; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0,0,0,.5)); }
.sidebar-title { display: flex; flex-direction: column; }
.sidebar-title .unit {
  font-family: 'Oswald', sans-serif;
  font-weight: 600;
  letter-spacing: 1px;
  font-size: 15px;
  color: var(--gold);
}
.sidebar-title .placeholder { font-size: 11px; color: var(--muted); letter-spacing: .5px; }

.sidebar-nav { padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  color: var(--text);
  text-decoration: none;
  border-radius: 6px;
  font-weight: 500;
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: background .15s, border-color .15s;
}
.nav-item:hover { background: var(--panel); }
.nav-item.active { background: var(--panel); border-left-color: var(--gold); color: var(--gold-2); }
.nav-ic { color: var(--silver); width: 20px; height: 20px; flex: 0 0 20px; display: inline-flex; align-items: center; justify-content: center; }
.nav-ic svg { width: 19px; height: 19px; display: block; }
.nav-item.active .nav-ic { color: var(--gold-2); }
.nav-item:hover .nav-ic { color: var(--gold); }
.nav-divider { height: 1px; background: var(--line); margin: 10px 8px; }

.sidebar-foot {
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .5px;
}

/* Main */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.crumb { font-family: 'Oswald', sans-serif; letter-spacing: 2px; color: var(--muted); font-size: 14px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-chip {
  font-family: 'Oswald', sans-serif;
  background: var(--navy);
  border: 1px solid var(--navy-2);
  color: var(--silver);
  padding: 6px 12px;
  border-radius: 5px;
  font-size: 13px;
  letter-spacing: .5px;
}

/* Buttons */
.btn {
  font-family: 'Oswald', sans-serif;
  letter-spacing: .5px;
  border: 1px solid transparent;
  padding: 9px 16px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  text-transform: uppercase;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .05s, background .15s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn-lg { padding: 13px 26px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-gold { background: var(--gold); color: #241d05; font-weight: 600; }
.btn-gold:hover { background: var(--gold-2); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: var(--panel); }
.btn-outline { background: transparent; color: var(--gold-2); border-color: var(--gold); }
.btn-outline:hover { background: rgba(201,169,74,.1); }

/* Content */
.content { padding: 32px 26px; max-width: 1080px; width: 100%; margin: 0 auto; }

/* Hero */
.hero { text-align: center; padding: 30px 0 50px; }
.hero-badge img {
  width: 120px; height: 120px; object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,.6));
  margin-bottom: 18px;
}
.hero h1 {
  font-family: 'Oswald', sans-serif;
  font-size: 42px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text);
}
.hero h1::after {
  content: ""; display: block; width: 90px; height: 3px;
  background: var(--red-2); margin: 14px auto 0;
}
.hero-sub { max-width: 620px; margin: 20px auto 28px; color: var(--muted); font-size: 17px; line-height: 1.6; }
.hero-actions { display: flex; gap: 14px; justify-content: center; }
.hero-error {
  max-width: 520px;
  margin: 0 auto 22px;
  background: rgba(152,24,31,.15);
  border: 1px solid var(--red-2);
  color: #f0b7ba;
  padding: 11px 14px;
  border-radius: 6px;
  font-size: 15px;
}

/* Cards */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 34px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--navy-2);
  border-radius: 8px;
  padding: 22px;
}
.card-ic { font-size: 26px; color: var(--gold); margin-bottom: 10px; }
.card h3 { font-family: 'Oswald', sans-serif; letter-spacing: .5px; margin-bottom: 8px; }
.card p { color: var(--muted); font-size: 14px; line-height: 1.5; }

/* Panels */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 20px;
}
.panel h2 {
  font-family: 'Oswald', sans-serif;
  letter-spacing: .5px;
  margin-bottom: 14px;
  color: var(--text);
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

/* Dashboard */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.profile-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 0; border-bottom: 1px solid var(--line);
}
.profile-row:last-child { border-bottom: none; }
.profile-row .lbl { color: var(--muted); font-size: 14px; }
.rank-tag {
  font-family: 'Oswald', sans-serif;
  background: var(--red);
  color: #fff;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 13px;
  letter-spacing: .5px;
}
.linked-badge {
  display: inline-block;
  background: var(--olive);
  color: #eaf0e0;
  font-family: 'Oswald', sans-serif;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 13px;
  margin-bottom: 12px;
}
.btn-row { display: flex; gap: 10px; margin-top: 16px; }
.step label, .auth-form label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 13px; color: var(--muted); margin-bottom: 14px;
  font-family: 'Oswald', sans-serif; letter-spacing: .5px;
}
.step input, .auth-form input {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 12px;
  border-radius: 5px;
  font-family: 'Barlow', sans-serif;
  font-size: 15px;
}
.step input:focus, .auth-form input:focus { outline: none; border-color: var(--gold); }
.code-box {
  font-family: 'Oswald', monospace;
  background: var(--navy);
  border: 1px dashed var(--gold);
  color: var(--gold-2);
  font-size: 24px;
  letter-spacing: 3px;
  text-align: center;
  padding: 16px;
  border-radius: 6px;
  margin: 8px 0 14px;
}
.code-steps { color: var(--muted); font-size: 14px; line-height: 1.7; margin: 0 0 8px 18px; }
.panel-error, .modal-error {
  background: rgba(152,24,31,.15);
  border: 1px solid var(--red-2);
  color: #f0b7ba;
  padding: 10px 12px;
  border-radius: 5px;
  font-size: 14px;
  margin-top: 12px;
}

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.66);
  display: flex; align-items: center; justify-content: center;
  z-index: 150; /* above the mobile drawer (120) so modals are never obscured */
  padding: 20px;
}
.modal {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-top: 4px solid var(--gold);
  border-radius: 10px;
  width: 100%;
  max-width: 400px;
  padding: 28px;
  position: relative;
}
.modal-close {
  position: absolute; top: 14px; right: 14px;
  background: none; border: none; color: var(--muted);
  font-size: 18px; cursor: pointer;
}
.modal-head { text-align: center; margin-bottom: 20px; }
.modal-logo { width: 64px; height: 64px; object-fit: contain; margin-bottom: 8px; }
.modal-head h2 { font-family: 'Oswald', sans-serif; letter-spacing: 1px; }
.auth-form { display: flex; flex-direction: column; }
.link-intro { color: var(--muted); font-size: 14px; line-height: 1.5; margin-bottom: 16px; text-align: center; }
.switch { text-align: center; font-size: 14px; color: var(--muted); margin-top: 14px; }
.switch a { color: var(--gold-2); text-decoration: none; }
.modal-error { margin-bottom: 14px; margin-top: 0; }

/* Page heading */
.page-head { margin-bottom: 22px; }
.page-head h1 { font-family: 'Oswald', sans-serif; font-size: 28px; letter-spacing: .5px; }
.page-head p { color: var(--muted); font-size: 15px; margin-top: 6px; max-width: 680px; line-height: 1.5; }
.section-title { font-family: 'Oswald', sans-serif; letter-spacing: .5px; margin: 26px 0 12px; color: var(--gold-2); font-size: 15px; text-transform: uppercase; }
.section-title:first-child { margin-top: 0; }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 22px; flex-wrap: wrap; }
.tab-btn {
  font-family: 'Oswald', sans-serif; letter-spacing: .5px;
  background: transparent; border: none; border-bottom: 3px solid transparent;
  color: var(--muted); padding: 11px 18px; cursor: pointer; font-size: 14px; text-transform: uppercase;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--gold-2); border-bottom-color: var(--gold); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td.wrap { white-space: normal; min-width: 200px; }
table.data th {
  font-family: 'Oswald', sans-serif; letter-spacing: .5px; color: var(--muted);
  text-transform: uppercase; font-size: 12px; background: var(--bg-2);
}
.filter-bar { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-bar .field { max-width: 260px; margin: 0; }
.filter-bar #rosterCount { padding-bottom: 10px; font-size: 13px; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover { background: var(--panel-2); }
.empty-row td, .empty-note { color: var(--muted); text-align: center; padding: 22px; font-size: 14px; }

/* Badges */
.badge { display: inline-block; font-family: 'Oswald', sans-serif; font-size: 11px; letter-spacing: .5px; padding: 3px 10px; border-radius: 20px; text-transform: uppercase; }
.badge-on { background: rgba(60,140,80,.18); color: #8fdca0; border: 1px solid #3c8c50; }
.badge-off { background: var(--navy); color: var(--muted); border: 1px solid var(--navy-2); }
.badge-pending { background: rgba(201,169,74,.15); color: var(--gold-2); border: 1px solid var(--gold); }
.badge-approved { background: rgba(60,140,80,.18); color: #8fdca0; border: 1px solid #3c8c50; }
.badge-denied, .badge-revoked { background: rgba(152,24,31,.2); color: #f0b7ba; border: 1px solid var(--red-2); }
.badge-ended { background: rgba(120,120,130,.18); color: #c8ccd4; border: 1px solid #6a707c; }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-family: 'Oswald', sans-serif; letter-spacing: .5px; font-size: 13px; color: var(--muted); }
.field.full { grid-column: 1 / -1; }
.field input, .field select, .field textarea {
  background: var(--bg); border: 1px solid var(--line); color: var(--text);
  padding: 11px 12px; border-radius: 5px; font-family: 'Barlow', sans-serif; font-size: 15px;
}
.field textarea { resize: vertical; min-height: 74px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--gold); }
.field input:read-only { color: var(--muted); background: var(--bg-2); cursor: not-allowed; }

/* Notices & detail */
.notice { background: rgba(201,169,74,.07); border: 1px dashed var(--gold); color: var(--gold-2); padding: 16px 18px; border-radius: 6px; font-size: 14px; line-height: 1.5; }
.record-block { margin-bottom: 20px; }
.record-block h4 { font-family: 'Oswald', sans-serif; color: var(--gold-2); margin-bottom: 8px; letter-spacing: .5px; text-transform: uppercase; font-size: 13px; }
.modal.modal-wide { max-width: 680px; max-height: 86vh; overflow-y: auto; text-align: left; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--panel-2); border: 1px solid var(--gold); color: var(--text); padding: 12px 18px; border-radius: 6px; z-index: 200; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.5); }

/* Responsive */
.menu-btn { display: none; }
.sidebar-overlay { display: none; }

/* Tablet: collapse sidebar to icons only */
@media (max-width: 860px) and (min-width: 701px) {
  .sidebar { width: 64px; }
  .sidebar-title, .sidebar-foot span { display: none; }
  .nav-item span:not(.nav-ic) { display: none; }
  .nav-item { justify-content: center; }
}

@media (max-width: 860px) {
  .dash-grid { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
  .hero h1 { font-size: 32px; }
}

/* Phone (portrait): sidebar becomes a slide-out drawer behind a hamburger */
@media (max-width: 700px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 270px;
    max-width: 82vw;
    height: 100dvh;
    z-index: 120;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.6);
  }
  body.menu-open .sidebar { transform: translateX(0); }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 110;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
  }
  body.menu-open .sidebar-overlay { display: block; opacity: 1; pointer-events: auto; }
  .sidebar-overlay { display: block; }
  body.menu-open { overflow: hidden; }

  .menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--navy);
    border: 1px solid var(--navy-2);
    border-radius: 6px;
    color: var(--gold);
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
  }
  .menu-btn svg { width: 22px; height: 22px; }

  .topbar { padding: 0 14px; gap: 10px; }
  .topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
  .crumb { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: 1px; }
  .user-chip { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .content { padding: 16px 14px; }
  .panel { padding: 16px 14px; }
  .hero h1 { font-size: 26px; }

  /* Wide tables scroll sideways instead of squashing the page */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 560px; }
}

.btn-small { padding: 4px 10px; font-size: 12px; margin-left: 6px; }

/* DD/MM/YY date fields: visible text input underneath, invisible native
   date input on top so tapping opens the browser's calendar dropdown. */
.datefield { position: relative; display: block; width: 100%; }
.datefield .datefield-native {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.datefield .datefield-native::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
