* { box-sizing: border-box; }
:root {
  --bg: #0f1115;
  --bg-elev: #171a21;
  --bg-elev2: #1e222b;
  --border: #262b36;
  --text: #e6e8eb;
  --text-dim: #9aa4b2;
  --accent: #4f7cff;
  --accent-strong: #3f63cc;
  --green: #3ecf8e;
  --yellow: #e0b23e;
  --red: #ef5a5a;
  --red-strong: #b34343;
  --gray: #55606f;
  --input-border: #5c6579;
}
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
a { color: inherit; text-decoration: none; }
#root { min-height: 100vh; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }

/* Gate */
.gate { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.gate-card { width: 100%; max-width: 360px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; padding: 28px; }
.gate-card h1 { font-size: 18px; margin: 0 0 4px; }
.gate-card p { color: var(--text-dim); font-size: 13px; margin: 0 0 20px; }
.gate-card input { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--input-border); background: var(--bg); color: var(--text); font-size: 15px; margin-bottom: 12px; }
.gate-card button { width: 100%; padding: 10px 12px; border-radius: 8px; border: none; background: var(--accent-strong); color: white; font-size: 14px; font-weight: 600; }
.gate-error { color: var(--red); font-size: 13px; margin: -6px 0 12px; }
.boot { padding: 40px; color: var(--text-dim); }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.shell-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.nav { width: 220px; flex: none; background: var(--bg-elev); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 16px 0; height: 100vh; position: sticky; top: 0; z-index: 300; }
.nav-brand { font-weight: 700; font-size: 16px; padding: 0 16px 16px; }
.nav-close-btn { display: none; background: transparent; border: none; color: var(--text-dim); font-size: 16px; min-width: 44px; min-height: 44px; align-items: center; justify-content: center; }
.nav-backdrop { display: none; }
.mobile-topbar { display: none; }
.nav-links { flex: 1; overflow-y: auto; }
.nav-link { display: block; padding: 8px 16px; color: var(--text-dim); font-size: 13px; border-left: 2px solid transparent; }
.nav-link:hover { color: var(--text); background: var(--bg-elev2); }
.nav-link.active { color: var(--text); border-left-color: var(--accent); background: var(--bg-elev2); font-weight: 600; }
.nav-group-label { padding: 14px 16px 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--gray); }
.nav-group-label:first-child { padding-top: 0; }
.nav-footer { padding: 12px 16px 0; border-top: 1px solid var(--border); margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.nav-hint-btn { font-size: 12px; color: var(--text-dim); background: var(--bg-elev2); border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; text-align: left; }
.nav-hint-btn:hover { color: var(--text); }
.save-indicator { font-size: 11px; color: var(--text-dim); }
.main { flex: 1; padding: 24px 32px; max-width: 1200px; overflow-x: auto; }

/* Typography / layout helpers */
h1.page-title { font-size: 20px; margin: 0 0 4px; }
.page-sub { color: var(--text-dim); font-size: 13px; margin: 0 0 20px; }
.section-title { font-size: 15px; font-weight: 600; margin: 24px 0 10px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 12px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr 1fr; } }

/* Cards */
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.flash-highlight { animation: flash-highlight 1.6s ease-out; }
@keyframes flash-highlight {
  0% { box-shadow: 0 0 0 2px var(--accent); }
  70% { box-shadow: 0 0 0 2px var(--accent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .flash-highlight { animation: none; box-shadow: 0 0 0 2px var(--accent); }
}
.print-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding-bottom: 12px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  max-width: min(420px, calc(100vw - 32px)); padding: 12px 18px; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: #fff; box-shadow: 0 12px 32px rgba(0,0,0,0.35);
  z-index: 400; text-align: center;
}
.toast-info { background: var(--accent-strong); }
.toast-success { background: #2f9e6e; }
.toast-error { background: var(--red-strong); }
@media (max-width: 768px) { .toast { bottom: 76px; } }
.stat-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.stat-card .label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card .value { font-size: 20px; font-weight: 700; margin-top: 4px; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-green { background: rgba(62,207,142,0.15); color: var(--green); }
.badge-yellow { background: rgba(224,178,62,0.15); color: var(--yellow); }
.badge-red { background: rgba(239,90,90,0.15); color: var(--red); }
.badge-gray { background: rgba(85,96,111,0.25); color: var(--text-dim); }
.badge-blue { background: rgba(79,124,255,0.15); color: var(--accent); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot-green { background: var(--green); }
.dot-yellow { background: var(--yellow); }
.dot-red { background: var(--red); }
.dot-gray { background: var(--gray); }

/* Table */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--text-dim); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: var(--bg-elev2); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.table-wrap table { border: none; }
.table-wrap .table-wrap { border: none; }

/* Forms */
input[type=text], input[type=number], input[type=date], input[type=password], input[type=email], select, textarea {
  background: var(--bg); border: 1px solid var(--input-border); border-radius: 6px; padding: 6px 9px; color: var(--text); width: 100%;
}
textarea { resize: vertical; min-height: 60px; }
.date-field-btn {
  background: var(--bg); border: 1px solid var(--input-border); border-radius: 6px; padding: 6px 9px; color: var(--text);
  width: 100%; text-align: left; display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 13px;
}
.date-field-btn .placeholder { color: var(--text-dim); }
label.field { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.field-wrap { margin-bottom: 10px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }

/* Buttons */
.btn { background: var(--accent-strong); color: white; border: none; border-radius: 6px; padding: 7px 12px; font-weight: 600; font-size: 13px; }
.btn-secondary { background: var(--bg-elev2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 7px 12px; font-size: 13px; }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; font-size: 12px; }
.btn-danger { background: var(--red-strong); color: white; border: none; border-radius: 6px; padding: 7px 12px; font-size: 13px; }
.btn-sm { padding: 4px 8px; font-size: 12px; }
.icon-btn {
  background: transparent; border: none; color: var(--text-dim); border-radius: 6px;
  min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--text); background: var(--bg-elev2); }

.swatch {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; padding: 0; cursor: pointer;
}
.swatch.selected { border-color: var(--text); }
.swatch-none {
  background: var(--bg-elev2); border: 1px solid var(--border);
  background-image: linear-gradient(to top left, transparent calc(50% - 1px), var(--red), transparent calc(50% + 1px));
}
.swatch-none.selected { border-color: var(--text); }

/* Lists */
.list-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }
/* One activity within a Schedule Day card — a divider, not a nested card. */
.schedule-activity-row { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 10px; padding-left: 10px; }
.schedule-activity-row:first-child { border-top: none; padding-top: 0; margin-top: 0; }
/* Edit controls (Hold/Confirmed select, Duplicate, delete) stay invisible
   until the row is hovered, focused, or explicitly opened — pure CSS, no
   extra JS hover state needed on top of this app's full-rebuild-on-refresh
   render model. .is-open is added inline so keyboard/touch users (no hover)
   still reach these once they've opened the row. */
.row-actions { opacity: 0; transition: opacity .1s; }
.schedule-activity-row:hover .row-actions,
.schedule-activity-row:focus-within .row-actions,
.row-actions.is-open { opacity: 1; }
.empty-state { color: var(--text-dim); font-size: 13px; padding: 24px; text-align: center; border: 1px dashed var(--border); border-radius: 10px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab { padding: 8px 14px; color: var(--text-dim); font-size: 13px; border-bottom: 2px solid transparent; cursor: pointer; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

/* Command palette */
.palette-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; z-index: 100; }
.palette { width: 100%; max-width: 560px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.palette input { border: none; border-radius: 0; padding: 14px 16px; font-size: 15px; border-bottom: 1px solid var(--border); }
.palette-results { max-height: 360px; overflow-y: auto; }
.palette-item { padding: 10px 16px; border-bottom: 1px solid var(--border); }
.palette-item:hover { background: var(--bg-elev2); }
.palette-hint { padding: 8px 16px; color: var(--text-dim); font-size: 11px; }

/* Mini calendar popover */
.mini-cal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 260; }
.mini-cal { position: fixed; left: 236px; bottom: 90px; width: 260px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; padding: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.mini-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.mini-cal-dow { text-align: center; font-size: 10px; color: var(--text-dim); padding: 2px 0; }
.mini-cal-day {
  background: transparent; border: none; color: var(--text); border-radius: 6px; font-size: 12px;
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center; position: relative;
}
.mini-cal-day:hover { background: var(--bg-elev2); }
.mini-cal-day.today { font-weight: 700; border: 1px solid var(--accent); }
.mini-cal-day.selected { background: var(--accent); color: #fff; }
.mini-cal-day.has-event::after { content: ''; position: absolute; bottom: 3px; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-top: 12px; }
.cal-header { background: transparent; border: none; margin-top: 16px; }
.cal-header > div { text-align: center; font-size: 11px; color: var(--text-dim); padding: 4px; }
.cal-cell { background: var(--bg-elev); min-height: 84px; padding: 6px; font-size: 11px; }
.cal-cell.empty { background: var(--bg); }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-cell.today .cal-daynum { color: var(--accent); font-weight: 700; }
.cal-daynum { color: var(--text-dim); margin-bottom: 4px; }
.cal-event { padding: 1px 5px; border-radius: 4px; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px; }
.modal-card { width: 100%; max-width: 420px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); max-height: 85vh; overflow-y: auto; }
.modal-title { margin: 0 0 14px; font-size: 16px; }
.modal-message { color: var(--text-dim); font-size: 13px; margin: -6px 0 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

.debug { padding: 24px; white-space: pre-wrap; font-family: monospace; font-size: 12px; }
.text-dim { color: var(--text-dim); }
.mt-0 { margin-top: 0; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.checklist-item { display: flex; align-items: center; gap: 8px; padding: 4px 0; }

@media (max-width: 480px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .shell { display: block; }
  .nav {
    position: fixed; top: 0; left: 0; bottom: 0; width: 260px; max-width: 82vw;
    transform: translateX(-100%); transition: transform 0.22s ease; box-shadow: 0 0 0 rgba(0,0,0,0);
  }
  .nav.open { transform: translateX(0); box-shadow: 20px 0 40px rgba(0,0,0,0.4); }
  .nav-close-btn { display: flex; }
  .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 250; }
  .shell-content { min-height: 100vh; }
  .mobile-topbar {
    display: flex; align-items: center; gap: 12px; padding: 12px 16px;
    border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); z-index: 50;
  }
  .mobile-topbar-title { font-weight: 700; font-size: 15px; flex: 1; }
  .hamburger-btn {
    background: transparent; border: 1px solid var(--border); border-radius: 6px;
    min-width: 44px; min-height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  }
  .hamburger-bar { display: block; width: 16px; height: 2px; background: var(--text); border-radius: 1px; }
  .search-btn {
    background: transparent; border: 1px solid var(--border); border-radius: 6px;
    min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; font-size: 16px; line-height: 1;
  }
  .main { padding: 16px; max-width: 100%; }
  .row { gap: 8px; }
  .tabs { overflow-x: auto; flex-wrap: nowrap; }
  .tab { white-space: nowrap; }
  .cal-cell { min-height: 56px; font-size: 10px; }
  .modal-card { max-width: 100%; }
  .palette-backdrop { padding: 12px; padding-top: 12px; }
  .palette { max-width: 100%; }
  .mini-cal { left: 12px; right: 12px; width: auto; bottom: 12px; }
}

@media print {
  .nav, .btn, .btn-secondary, .btn-danger, .icon-btn { display: none !important; }
  .main { padding: 0; max-width: none; }
  body { background: white; color: black; }
}
