:root {
  --bg:      #1A1A1A;
  --bg2:     #242424;
  --bg3:     #2E2E2E;
  --border:  #3A3A3A;
  --accent:  #FF6B35;
  --accent2: #E55A25;
  --text:    #F0F0F0;
  --text2:   #888;
  --danger:  #E53935;
  --success: #43A047;
  --radius:  10px;
  --tap:     44px;
  --nav-w:   200px;
  --nav-h:   54px;
}

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

html { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  min-height: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* ── App shell ─────────────────────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Navigation — mobile bottom bar ─────────────────────────────────────── */
nav {
  background: var(--bg2);
  display: flex;
  flex-direction: row;
  border-top: 1px solid var(--border);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-brand { display: none; }

nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 2px;
  color: var(--text2);
  text-decoration: none;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.3px;
  min-height: var(--nav-h);
  position: relative;
  transition: color 0.15s;
  text-transform: uppercase;
  gap: 3px;
}

nav a.active { color: var(--accent); }
nav a:not(.active):active { color: var(--text); }

.nav-icon {
  width: 20px;
  height: 20px;
  display: block;
  flex-shrink: 0;
}

.nav-label { line-height: 1; }

/* logout link in nav — same style, danger color on active */
.nav-logout-link:active { color: var(--danger) !important; }

.badge {
  position: absolute;
  top: 5px;
  right: calc(50% - 20px);
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  min-width: 16px;
  text-align: center;
  line-height: 14px;
}

/* ── Main content ────────────────────────────────────────────────────────── */
main {
  flex: 1;
  padding: 12px 12px calc(var(--nav-h) + env(safe-area-inset-bottom) + 72px);
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

/* ── Page header ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
  flex-wrap: wrap;
}

.page-header-left { min-width: 0; flex: 1; }

.page-title {
  font-size: 18px;
  font-weight: 800;
}

.page-subtitle {
  font-size: 12px;
  color: var(--text2);
  margin-top: 1px;
}

.page-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

@media (max-width: 380px) {
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header-right { justify-content: flex-start; }
}

/* ── Cards grid ──────────────────────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-row { display: flex; gap: 8px; }
.form-row .form-group { flex: 1; }
.form-group { margin-bottom: 12px; }

label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input, textarea, select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 15px;
  min-height: var(--tap);
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
}

textarea { min-height: 80px; resize: vertical; }

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255,107,53,0.2);
}

input::placeholder, textarea::placeholder { color: var(--text2); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: var(--tap);
  padding: 0 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: opacity 0.15s, transform 0.1s;
  user-select: none;
  white-space: nowrap;
}

.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn:active { opacity: 0.7; transform: scale(0.96); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-ghost   { background: var(--bg3); color: var(--text2); border: 1px solid var(--border); }
.btn-full    { width: 100%; }
.btn-sm      { min-height: 36px; padding: 0 12px; font-size: 12px; border-radius: 6px; }
.btn-sm svg  { width: 13px; height: 13px; }
.btn-icon    { min-height: 36px; width: 36px; padding: 0; border-radius: 8px; flex-shrink: 0; }

/* ── Time chips ──────────────────────────────────────────────────────────── */
.time-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.time-chip {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  min-height: 34px;
}

.time-chip:active { opacity: 0.7; }
.time-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Date chip ───────────────────────────────────────────────────────────── */
.date-chip {
  background: var(--bg3);
  border-radius: 16px;
  padding: 0 12px;
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  border: 1px solid var(--border);
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}

input.date-input-chip {
  background: var(--bg3);
  border-radius: 16px;
  padding: 0 12px;
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  border: 1px solid var(--border);
  min-height: 36px;
  width: auto;
  font-family: inherit;
  color-scheme: dark;
}
input.date-input-chip:focus { border-color: var(--accent); box-shadow: none; outline: none; }

/* ── Reservation cards ───────────────────────────────────────────────────── */
.res-card {
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 12px;
  border-left: 3px solid var(--accent);
}

.res-card.unread { border-left-color: #FFD700; }

.res-name  { font-size: 16px; font-weight: 700; }
.res-meta  { font-size: 12px; color: var(--text2); margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.res-meta svg { width: 13px; height: 13px; }
.res-notes { font-size: 13px; color: var(--text2); margin-top: 8px; font-style: italic;
             padding-top: 8px; border-top: 1px solid var(--border); }
.res-actions { display: flex; gap: 6px; margin-top: 10px; }

/* ── Note cards ──────────────────────────────────────────────────────────── */
.note-card {
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 12px;
}

.note-header { display: flex; align-items: center; justify-content: space-between;
               margin-bottom: 6px; gap: 8px; flex-wrap: wrap; }
.note-author { font-size: 12px; color: var(--accent); font-weight: 700; display: flex; align-items: center; gap: 4px; }
.note-author svg { width: 12px; height: 12px; }
.note-time   { font-size: 11px; color: var(--text2); }
.note-content { font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.note-footer { margin-top: 10px; }

/* ── Weekly work plan ────────────────────────────────────────────────────── */
.week-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.day-card {
  background: var(--bg2);
  border-radius: var(--radius);
  overflow: hidden;
  border-left: 3px solid var(--border);
}

.day-card.today { border-left-color: var(--accent); }

.day-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

.day-name  { font-size: 14px; font-weight: 800; }
.day-date  { font-size: 11px; color: var(--text2); margin-top: 1px; }

.day-card-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }

.day-role { display: flex; align-items: flex-start; gap: 6px; flex-wrap: wrap; font-size: 13px; }

.role-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  min-width: 48px;
  flex-shrink: 0;
  padding-top: 3px;
}

.staff-tag {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}

.day-card.today .staff-tag { border-color: rgba(255,107,53,0.3); }

.staff-empty { color: var(--text2); font-size: 12px; }

.day-note {
  font-size: 12px;
  color: var(--text2);
  font-style: italic;
  padding-top: 5px;
  border-top: 1px solid var(--border);
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg2);
  border-radius: 18px 18px 0 0;
  padding: 6px 16px calc(24px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-handle {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 10px auto 16px;
}

.modal h3 { font-size: 16px; font-weight: 800; margin-bottom: 16px; }

.modal-actions { display: flex; gap: 8px; margin-top: 4px; }
.modal-actions .btn { flex: 1; }

/* ── FAB ─────────────────────────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px);
  right: 16px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(255,107,53,0.5);
  cursor: pointer; border: none; z-index: 150;
  transition: transform 0.15s, box-shadow 0.15s;
}
.fab svg { width: 24px; height: 24px; }
.fab:active { transform: scale(0.9); box-shadow: 0 2px 8px rgba(255,107,53,0.3); }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 40px 16px; color: var(--text2); }
.empty-icon { font-size: 40px; margin-bottom: 10px; display: flex; justify-content: center; }
.empty p { font-size: 14px; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: #3a3a3a; color: #fff;
  padding: 10px 20px; border-radius: 20px;
  font-size: 13px; font-weight: 500;
  z-index: 400; opacity: 0; pointer-events: none;
  transition: opacity 0.25s; white-space: nowrap; max-width: 88vw;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
#toast.show { opacity: 1; }

/* ── Day navigator ───────────────────────────────────────────────────────── */
.day-nav {
  display: flex;
  align-items: center;
  gap: 3px;
}

.day-nav-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font-family: inherit;
  transition: background 0.15s;
}
.day-nav-btn svg { width: 16px; height: 16px; }
.day-nav-btn:active { opacity: 0.6; }

/* ── View toggle ─────────────────────────────────────────────────────────── */
.view-toggle {
  display: flex;
  background: var(--bg3);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
  margin-bottom: 12px;
}
.view-toggle button {
  flex: 1;
  min-height: 34px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.view-toggle button.active {
  background: var(--bg2);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* ── Pagination ──────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}
.pagination-info { font-size: 12px; color: var(--text2); }

/* ── Date group heading ──────────────────────────────────────────────────── */
.date-group { margin-bottom: 16px; }
.date-group-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 6px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}

/* ── Misc ────────────────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.loader  { text-align: center; padding: 28px; color: var(--text2); font-size: 14px; }

/* ── Login screen ────────────────────────────────────────────────────────── */
.login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.login-screen.hidden { display: none; }

.login-card {
  background: var(--bg2);
  border-radius: 18px;
  padding: 28px 22px 24px;
  width: 100%;
  max-width: 320px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

.login-logo  { font-size: 44px; margin-bottom: 8px; }
.login-title { font-size: 20px; font-weight: 800; margin-bottom: 3px; }
.login-sub   { font-size: 13px; color: var(--text2); margin-bottom: 22px; }

.login-card input[type="password"] {
  font-size: 16px;
  text-align: center;
  letter-spacing: 4px;
  margin-bottom: 12px;
}

.login-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 8px;
  min-height: 16px;
}

/* ════════════════════════════════════════════════════════════════════════════
   TABLET  ≥ 600px  — top nav
   ════════════════════════════════════════════════════════════════════════════ */
@media (min-width: 600px) {
  nav {
    position: sticky;
    top: 0;
    bottom: auto;
    border-top: none;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
  }

  nav a {
    font-size: 11px;
    min-height: 58px;
    padding: 10px 6px;
    gap: 4px;
  }

  .nav-icon { width: 22px; height: 22px; }

  main { padding: 20px 20px 80px; }

  .page-title { font-size: 22px; }

  .modal-overlay { align-items: center; padding: 16px; }
  .modal {
    border-radius: 14px;
    max-height: 88vh;
    padding: 22px 22px 24px;
  }
  .modal-handle { display: none; }

  .fab { bottom: 24px; right: 20px; }
  #toast { bottom: 20px; }
}

/* ════════════════════════════════════════════════════════════════════════════
   DESKTOP  ≥ 1024px  — sidebar nav
   ════════════════════════════════════════════════════════════════════════════ */
@media (min-width: 1024px) {
  .app {
    flex-direction: row;
    min-height: 100vh;
    align-items: flex-start;
  }

  nav {
    flex-direction: column;
    width: var(--nav-w);
    height: 100vh;
    border-bottom: none;
    border-right: 1px solid var(--border);
    position: sticky;
    top: 0;
    overflow-y: auto;
    padding-top: 8px;
    flex-shrink: 0;
  }

  .nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px 10px;
    font-size: 14px;
    font-weight: 800;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
  }
  .nav-brand-icon { font-size: 20px; }

  nav a {
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    padding: 11px 16px;
    font-size: 13px;
    min-height: 44px;
    text-transform: none;
    letter-spacing: 0;
    border-radius: 8px;
    margin: 1px 6px;
    width: calc(100% - 12px);
    flex: none;
  }

  nav a.active { background: rgba(255,107,53,0.12); }

  .nav-icon { width: 18px; height: 18px; margin-bottom: 0; }

  .badge {
    position: static;
    margin-left: auto;
    flex-shrink: 0;
  }

  .nav-logout-link { margin-top: auto; color: var(--text2); }
  .nav-logout-link:hover { color: var(--danger); }

  main {
    flex: 1;
    min-height: 100vh;
    padding: 24px 28px 48px;
    max-width: none;
  }

  .page-title { font-size: 24px; }

  .cards-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }

  .modal { max-width: 560px; }
  .fab { display: none; }
  #toast { bottom: 24px; }

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

@media (min-width: 1280px) {
  .week-grid { grid-template-columns: repeat(3, 1fr); }
}
