:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --text: #25313c;
  --muted: #6c7b88;
  --border: #dfe6ec;
  --accent: #517da4;
  --accent-strong: #315d84;
  --accent-soft: #dfeaf4;
  --danger: #b74d59;
  --success: #4e8b68;
  --warning: #b88739;
  --radius: 18px;
  --shadow: 0 10px 28px rgba(36, 52, 66, .08);
  --decor-a: rgba(81,125,164,.11);
  --decor-b: rgba(81,125,164,.05);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font);
  background:
    radial-gradient(circle at 8% 10%, var(--decor-a) 0 90px, transparent 91px),
    radial-gradient(circle at 92% 20%, var(--decor-b) 0 130px, transparent 131px),
    var(--bg);
}

body::before, body::after {
  position: fixed;
  z-index: -1;
  pointer-events: none;
  user-select: none;
  opacity: .2;
  font-family: Georgia, serif;
}
body[data-theme="pink-bow"]::before { content: "♡"; top: 14%; right: 5%; font-size: 82px; color: var(--accent); transform: rotate(12deg); }
body[data-theme="pink-bow"]::after { content: "♡"; bottom: 8%; left: 4%; font-size: 58px; color: var(--accent); transform: rotate(-16deg); }
body[data-theme="island-blue"]::before { content: "✿"; top: 15%; right: 5%; font-size: 74px; color: var(--accent); transform: rotate(10deg); }
body[data-theme="island-blue"]::after { content: "≈"; bottom: 7%; left: 3%; font-size: 92px; color: var(--accent); letter-spacing: -18px; }
body[data-theme="sage-cream"]::before { content: "❧"; top: 16%; right: 5%; font-size: 76px; color: var(--accent); }
body[data-theme="lavender"]::before { content: "✦"; top: 15%; right: 6%; font-size: 62px; color: var(--accent); }
body[data-theme="midnight"]::before { content: "☾"; top: 13%; right: 5%; font-size: 72px; color: var(--accent); opacity: .14; }

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: not-allowed; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px clamp(16px, 4vw, 38px);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 800;
}
.brand h1 { margin: 0; font-size: 18px; }
.brand small { display: block; margin-top: 2px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.live-pill, .user-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 11px;
  font-size: 13px;
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #9aa5ad; }
.live-dot.on { background: #45a66f; box-shadow: 0 0 0 4px rgba(69,166,111,.12); }

.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 24px;
  padding: 24px clamp(16px, 4vw, 38px) 48px;
}
.sidebar { position: sticky; top: 91px; align-self: start; display: grid; gap: 8px; }
.nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border: 0;
  border-radius: 14px;
  color: var(--muted);
  background: transparent;
  text-align: left;
}
.nav-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-btn.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; }
.main { min-width: 0; }
.view { display: none; }
.view.active { display: block; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head h2 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
}
.btn:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 7px 10px; font-size: 13px; }

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card + .card { margin-top: 16px; }
.card h3 { margin: 0 0 12px; font-size: 17px; }
.card-sub { margin: -5px 0 14px; color: var(--muted); font-size: 14px; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 16px; }
.metric { padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { display: block; margin-top: 5px; font-size: 25px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-bottom: 16px; }
.field { display: grid; gap: 6px; min-width: 160px; }
.field.grow { flex: 1; min-width: 220px; }
.field label, .field-label { font-size: 13px; color: var(--muted); font-weight: 700; }
.input, .select, .textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 11px;
  outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { min-height: 88px; resize: vertical; }

.attendance-list { display: grid; gap: 10px; }
.attendance-row {
  display: grid;
  grid-template-columns: var(--attendance-columns, minmax(170px,1.35fr) minmax(100px,.65fr) minmax(130px,.9fr) minmax(130px,.9fr) minmax(180px,1.2fr));
  gap: 12px;
  align-items: center;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}
.attendance-row:hover { border-color: color-mix(in srgb, var(--accent) 28%, var(--border)); }
.person-name { font-weight: 800; }
.person-sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.status-select { font-weight: 800; }
.detail-cell { min-width: 0; }
.inline-detail { display: grid; gap: 5px; }
.inline-detail small { color: var(--muted); font-weight: 700; }
.minutes-chip { display: inline-flex; align-items: center; gap: 5px; padding: 7px 10px; border-radius: 999px; background: var(--surface-2); font-size: 13px; font-weight: 800; }
.update-meta { color: var(--muted); font-size: 12px; line-height: 1.35; }
.empty { padding: 32px 18px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); }

.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 12px 13px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 26%, var(--surface)); }

.badge { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; background: var(--surface-2); }
.status-badge { color: #263039; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: 0; }
.check-row { display: flex; align-items: center; gap: 9px; }
.check-row input { width: 17px; height: 17px; accent-color: var(--accent); }
.color-input { width: 38px; height: 34px; border: 0; padding: 0; background: transparent; }

.theme-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.theme-card { border: 2px solid var(--border); border-radius: 16px; background: var(--surface); padding: 12px; text-align: left; }
.theme-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.theme-swatch { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 8px 0; }
.theme-swatch i { height: 22px; border-radius: 6px; display: block; }
.theme-card small { color: var(--muted); }
.custom-theme-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }

.status-editor-row, .shift-editor-row { display: grid; grid-template-columns: 1fr 1.25fr auto auto; gap: 9px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); }
.shift-editor-row { grid-template-columns: 1.2fr .8fr .8fr auto; }

.modal {
  width: min(760px, calc(100vw - 28px));
  max-height: 86vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  color: var(--text);
  padding: 0;
  box-shadow: 0 24px 70px rgba(0,0,0,.22);
}
.modal::backdrop { background: rgba(20, 26, 32, .5); backdrop-filter: blur(2px); }
.modal-head { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--border); background: var(--surface); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 18px; }
.modal-foot { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border); background: var(--surface); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }

.login-wrap, .setup-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card, .setup-card { width: min(470px,100%); }
.login-card h1, .setup-card h1 { margin: 0 0 8px; }
.login-card p, .setup-card p { color: var(--muted); }
.stack { display: grid; gap: 12px; }
.notice { border: 1px solid color-mix(in srgb, var(--warning) 42%, var(--border)); background: color-mix(in srgb, #f3dca8 28%, var(--surface)); border-radius: 14px; padding: 12px 14px; }
.error { color: var(--danger); font-size: 13px; }
.success { color: var(--success); font-size: 13px; }

.import-preview { display: grid; gap: 12px; }
.mapping-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.file-drop { border: 2px dashed var(--border); border-radius: var(--radius); padding: 26px; text-align: center; background: var(--surface-2); }
.file-drop input { width: 100%; margin-top: 12px; }

.audit-list { display: grid; gap: 8px; }
.audit-item { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); }
.audit-item small { color: var(--muted); }

.mobile-nav { display: none; }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 50; max-width: 360px; padding: 11px 14px; border-radius: 13px; background: var(--text); color: var(--surface); box-shadow: var(--shadow); }

/* Theme decorative identities. No copyrighted character artwork is included. */
body[data-theme="pink-bow"] {
  --bg:#fff3f8; --surface:#fffafd; --surface-2:#fde3ef; --text:#573747; --muted:#8d6578;
  --border:#f0c8d9; --accent:#e06d9f; --accent-strong:#ad3f70; --accent-soft:#f9d7e6;
  --decor-a:rgba(236,142,182,.18); --decor-b:rgba(246,184,209,.18);
}
body[data-theme="island-blue"] {
  --bg:#edf9fb; --surface:#fbffff; --surface-2:#dff3f5; --text:#244653; --muted:#63808a;
  --border:#c5e2e6; --accent:#3f9fbd; --accent-strong:#25738e; --accent-soft:#d3eff5;
  --decor-a:rgba(79,184,210,.16); --decor-b:rgba(140,112,197,.10);
}
body[data-theme="sage-cream"] {
  --bg:#f4f3eb; --surface:#fffdf7; --surface-2:#e7ece0; --text:#39443a; --muted:#707d70;
  --border:#d6ddce; --accent:#769574; --accent-strong:#526f52; --accent-soft:#dfe9dc;
  --decor-a:rgba(118,149,116,.14); --decor-b:rgba(205,185,141,.10);
}
body[data-theme="lavender"] {
  --bg:#f7f2fc; --surface:#fefcff; --surface-2:#eee3f7; --text:#473c56; --muted:#786b87;
  --border:#ded1e9; --accent:#9b78bd; --accent-strong:#76569a; --accent-soft:#e8d9f3;
  --decor-a:rgba(155,120,189,.15); --decor-b:rgba(216,176,227,.13);
}
body[data-theme="midnight"] {
  --bg:#17202a; --surface:#202b36; --surface-2:#293743; --text:#eef4f7; --muted:#a9bac5;
  --border:#344552; --accent:#73a7d0; --accent-strong:#b8d9f2; --accent-soft:#2c465c;
  --danger:#ef929b; --success:#82c99d; --warning:#e2bd72; --shadow:none;
  --decor-a:rgba(115,167,208,.08); --decor-b:rgba(115,167,208,.04);
}
body[data-theme="classic"] {
  --bg:#f6f8fb; --surface:#ffffff; --surface-2:#eef3f8; --text:#25313c; --muted:#6c7b88;
  --border:#dfe6ec; --accent:#517da4; --accent-strong:#315d84; --accent-soft:#dfeaf4;
  --decor-a:rgba(81,125,164,.11); --decor-b:rgba(81,125,164,.05);
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; padding-bottom: 88px; }
  .sidebar { display: none; }
  .mobile-nav { position: fixed; left: 12px; right: 12px; bottom: 10px; z-index: 30; display: grid; grid-template-columns: repeat(5,1fr); gap: 5px; padding: 7px; border: 1px solid var(--border); border-radius: 18px; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); box-shadow: var(--shadow); }
  .mobile-nav .nav-btn { justify-content: center; padding: 10px 6px; font-size: 12px; }
  .attendance-row { grid-template-columns: 1.2fr .8fr 1fr !important; }
  .attendance-row .update-meta { display: none; }
  .metrics { grid-template-columns: repeat(2,1fr); }
}

@media (max-width: 700px) {
  .topbar { padding: 12px 14px; }
  .brand small, .user-pill { display: none; }
  .layout { padding: 16px 12px 88px; }
  .page-head { align-items: stretch; flex-direction: column; }
  .settings-grid, .theme-grid, .custom-theme-grid, .mapping-grid, .form-grid { grid-template-columns: 1fr; }
  .attendance-row { grid-template-columns: 1fr 1fr !important; }
  .attendance-row .person { grid-column: 1 / -1; }
  .attendance-row .detail-cell { grid-column: 1 / -1; }
  .shift-editor-row { grid-template-columns: 1fr 1fr; }
  .shift-editor-row > :first-child { grid-column: 1 / -1; }
  .status-editor-row { grid-template-columns: 1fr auto; }
  .status-editor-row .status-behavior { grid-column: 1 / -1; }
}

/* Roster grouping inspired by the uploaded team roster */
.roster-groups { display: grid; gap: 18px; }
.roster-group { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.roster-group-head { padding: 11px 14px; background: var(--accent); color: #fff; font-weight: 800; text-align: center; letter-spacing: .01em; }
.roster-inner { border: 0; border-radius: 0; }
.roster-inner table { min-width: 980px; }

/* Monthly attendance matrix */
.month-table-wrap { max-width: 100%; }
.month-grid { min-width: 1900px; font-size: 12px; }
.month-grid th, .month-grid td { padding: 6px 7px; text-align: center; }
.month-grid th:first-child, .month-grid td:first-child { text-align: left; }
.month-day-head { min-width: 64px; padding: 6px 3px !important; }
.month-day-head span { display: block; font-size: 10px; color: var(--muted); text-transform: none; letter-spacing: 0; }
.month-day-head strong { display: block; margin-top: 2px; font-size: 13px; color: var(--text); }
.month-att-cell { padding: 3px !important; }
.month-status { width: 58px; min-height: 30px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text); font-size: 11px; font-weight: 800; padding: 2px 3px; text-align: center; }
.month-total-head { min-width: 54px; }
.month-total-cell, .month-total-wd { background: color-mix(in srgb, var(--surface-2) 70%, var(--surface)); }
.month-total-wd { min-width: 62px; }
.month-group-row td { background: color-mix(in srgb, var(--accent) 88%, #000 12%); color: #fff; font-weight: 800; text-align: center !important; padding: 8px 10px; }
.month-grid .sticky-person { position: sticky; left: 0; z-index: 3; min-width: 180px; background: var(--surface); }
.month-grid thead .sticky-person { z-index: 5; background: var(--surface-2); }
.month-grid tbody tr:hover .sticky-person { background: color-mix(in srgb, var(--accent-soft) 26%, var(--surface)); }

/* Expanded status editor */
.status-editor-row.expanded { grid-template-columns: .7fr 1.3fr 1.15fr 1fr auto auto; align-items: end; gap: 9px; }
.status-editor-row.expanded .field { min-width: 0; }
.status-editor-row.expanded .worked-day-check { align-self: center; padding-bottom: 10px; }
.status-description { grid-column: 1 / -1; color: var(--muted); font-size: 12px; padding: 0 2px 8px; }
.shift-editor-row.simple { grid-template-columns: 1fr auto; }

@media (max-width: 900px) {
  .status-editor-row.expanded { grid-template-columns: 1fr 1fr; }
  .status-editor-row.expanded .worked-day-check,
  .status-editor-row.expanded .color-field,
  .status-editor-row.expanded .remove-status { align-self: end; }
  .status-description { grid-column: 1 / -1; }
}

/* Team Spades-style attendance grid + note markers */
.month-grid { min-width: 2450px; }
.month-grid th, .month-grid td { border-right: 1px solid var(--border); }
.month-grid th:nth-child(2), .month-grid td:nth-child(2) { min-width: 92px; }
.month-grid th:nth-child(3), .month-grid td:nth-child(3) { min-width: 110px; }
.month-grid th:nth-child(4), .month-grid td:nth-child(4) { min-width: 185px; text-align: left; }
.month-grid th:nth-child(5), .month-grid td:nth-child(5) { min-width: 130px; text-align: left; }
.month-day-head { min-width: 82px; }
.month-att-cell { min-width: 82px; }
.month-cell-wrap { position: relative; min-width: 76px; }
.month-status { width: 76px; min-height: 31px; padding: 2px 14px 2px 4px; font-size: 10px; }
.month-note-button {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  opacity: .55;
}
.month-cell-wrap:hover .month-note-button,
.month-note-button:focus-visible { opacity: 1; }
.month-note-button.has-note {
  opacity: 1;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 2px var(--surface);
}
.month-schedule-cell { white-space: normal; line-height: 1.25; }
.attendance-note-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-bottom: 7px; }
.note-chip { display: inline-flex; align-items: center; padding: 4px 7px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 900; letter-spacing: .04em; }
.attendance-note-open.has-note { border-color: var(--accent); color: var(--accent-strong); }
.optional-label { color: var(--muted); font-size: 11px; font-weight: 600; }
.note-modal { width: min(680px, calc(100vw - 28px)); }
.import-table-wrap { max-height: 250px; }
.import-table { min-width: max-content; font-size: 12px; }
.import-table th, .import-table td { white-space: nowrap; padding: 8px 10px; }
.status-editor-row.expanded.spades-status-editor { grid-template-columns: 1.05fr 1.8fr 1.1fr auto auto; }
.status-editor-row.expanded.spades-status-editor .status-meaning-field { min-width: 220px; }

@media (max-width: 980px) {
  .mobile-nav { grid-template-columns: repeat(6,1fr); }
}
@media (max-width: 900px) {
  .status-editor-row.expanded.spades-status-editor { grid-template-columns: 1fr 1fr; }
  .status-editor-row.expanded.spades-status-editor .status-meaning-field { min-width: 0; }
}
.status-legend { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 10px; }
.status-legend-item { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 11px; font-weight: 750; }
.status-legend-item i { width: 12px; height: 12px; border-radius: 4px; border: 1px solid color-mix(in srgb, #000 12%, transparent); }
.month-note-help { color: var(--muted); font-size: 12px; margin: 0 0 10px; }
.note-key { display: inline-grid; place-items: center; width: 18px; height: 18px; margin-right: 4px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 900; }

/* Day navigation and future planning */
.date-picker-row { display: flex; align-items: center; gap: 6px; }
.date-picker-row .input { min-width: 150px; }
.compact-head { align-items: center; margin-bottom: 12px; }
.compact-head h3 { margin-bottom: 0; }
.plan-chip {
  display: inline-flex;
  align-items: center;
  margin: 0 0 5px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .05em;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 850;
}
#attendancePlansList table { min-width: 900px; }

@media (max-width: 700px) {
  .date-picker-row { flex-wrap: wrap; }
  .date-picker-row .input { flex: 1 1 170px; }
}
