/* ============================================================
   Monterey Bay Recovery — Timer System Stylesheet
   Mobile-first design: phones → tablets → desktop
   ============================================================ */

:root {
  --green-dark:   #1a3d2b;
  --green-mid:    #2d5a3d;
  --green-light:  #4a8c5c;
  --green-pale:   #c8d8c0;
  --cream:        #f5f0e8;
  --cream-dark:   #e8e0d0;
  --stone:        #4a5a4a;
  --stone-light:  #6a7a6a;
  --gold:         #c8a84b;
  --gold-light:   #e0c870;
  --white:        #ffffff;
  --text-dark:    #0f1a0d;
  --text-mid:     #1e3828;
  --shadow:       rgba(10, 30, 15, 0.35);
  --glass:        rgba(245, 240, 232, 0.12);
  --glass-border: rgba(180, 160, 120, 0.25);
  --cream-glass:  rgba(245, 240, 232, 0.30);
  --cream-glass-strong: rgba(245, 240, 232, 0.50);

  --status-idle:    #5a7a5a;
  --status-running: #2d7a3d;
  --status-paused:  #c8a84b;
  --status-expired: #c0392b;
  --status-warning: #e67e22;

  /* Touch-friendly minimum tap size */
  --tap-min: 48px;
}

/* ---- Reset ------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Lato', sans-serif;
  color: var(--text-dark);
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--green-dark);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ---- Background -------------------------------------------- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: url('../images/bixby-bridge.jpg') center center / cover no-repeat;
  z-index: -2;
}
.bg-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg,
    rgba(245,240,232,0.18) 0%,
    rgba(245,240,232,0.10) 40%,
    rgba(245,240,232,0.18) 100%);
  z-index: -1;
}

/* ---- Flash Overlay ----------------------------------------- */
.flash-overlay {
  position: fixed; inset: 0; z-index: 9999;
  pointer-events: none; opacity: 0;
  background: rgba(255,255,255,0.92);
  transition: opacity 0.1s;
}
.flash-overlay.flashing { animation: flash-anim 0.6s ease-in-out 3; }
@keyframes flash-anim {
  0%   { opacity: 0; }
  30%  { opacity: 0.85; }
  60%  { opacity: 0; }
  100% { opacity: 0; }
}

/* ============================================================
   HEADER — compact on mobile, full on desktop
   ============================================================ */
.site-header {
  background: var(--cream-glass-strong);
  border-bottom: 2px solid rgba(180,160,120,0.45);
  box-shadow: 0 4px 24px rgba(10,30,15,0.18);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 10px 0 8px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 200;
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 12px;
}

.site-logo {
  display: block;
  margin: 0 auto 4px;
  max-height: 60px;
  max-width: 200px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.45));
}
.site-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text-dark);
  text-transform: uppercase;
  text-shadow: 0 1px 4px rgba(255,255,255,0.6);
  line-height: 1.2;
}
.site-subtitle {
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  color: var(--text-dark);
  font-weight: 700;
  text-transform: uppercase;
  margin: 2px 0 8px;
}

/* Navigation — scrollable row on small screens */
.header-nav {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.header-nav::-webkit-scrollbar { display: none; }
.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: 30px;
  border: 1.5px solid var(--green-light);
  background: rgba(245,240,232,0.30);
  color: var(--text-dark);
  font-weight: 700;
  font-family: 'Lato', sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.22s;
  min-height: var(--tap-min);
}
.nav-btn:hover, .nav-btn.active {
  background: var(--green-mid);
  color: var(--cream);
  border-color: var(--gold);
  box-shadow: 0 2px 12px rgba(200,168,75,0.25);
}

/* ============================================================
   SCANNER SECTION
   ============================================================ */
.scanner-section {
  background: var(--cream-glass);
  border-bottom: 1px solid rgba(180,160,120,0.3);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 10px 12px;
  text-align: center;
}
.scanner-inner { max-width: 900px; margin: 0 auto; }
.scanner-toggle-group {
  display: flex;
  justify-content: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.scan-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  height: var(--tap-min);
  border-radius: 8px;
  border: 1.5px solid var(--green-light);
  background: rgba(245,240,232,0.55);
  color: var(--text-dark);
  font-size: 0.82rem;
  font-weight: 700;
  font-family: 'Lato', sans-serif;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.22s;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  white-space: nowrap;
}
.scan-btn:hover, .scan-btn.active {
  background: var(--green-mid);
  border-color: var(--gold);
  color: var(--gold-light);
}
.manual-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 8px;
}
.manual-input-area input {
  flex: 1;
  min-width: 200px;
  max-width: 380px;
  padding: 0 14px;
  height: var(--tap-min);
  border-radius: 8px;
  border: 1.5px solid var(--green-light);
  background: rgba(245,240,232,0.50);
  color: var(--text-dark);
  font-size: 1rem;
  font-family: 'Lato', sans-serif;
  outline: none;
}
.manual-input-area input:focus { border-color: var(--gold); }
.manual-input-area input::placeholder { color: #5a6a5a; font-weight: 500; }
.submit-scan-btn {
  height: var(--tap-min);
  padding: 0 20px;
  background: var(--green-mid);
  border: 1.5px solid var(--gold);
  border-radius: 8px;
  color: var(--gold-light);
  font-size: 0.88rem;
  font-family: 'Lato', sans-serif;
  cursor: pointer;
  transition: all 0.22s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}
.submit-scan-btn:hover { background: var(--green-dark); color: var(--cream); }
.hidden { display: none !important; }

/* ============================================================
   TIMER GRID — 1 col mobile → 2 col tablet → auto desktop
   ============================================================ */
.timers-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 10px 80px;
}
.timer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

/* ============================================================
   TIMER CARD — touch-optimized
   ============================================================ */
.timer-card {
  background: var(--cream-glass);
  border: 1.5px solid rgba(180,160,120,0.4);
  border-radius: 16px;
  padding: 16px 14px 14px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 6px 28px rgba(10,30,15,0.22);
  /* visibility defaults — card-hidden/card-revealed manage actual display */
  opacity: 0;
  transform: translateY(18px) scale(0.96);
  pointer-events: none;
  transition: box-shadow 0.2s, border-color 0.3s,
              opacity 0.4s cubic-bezier(0.22,1,0.36,1),
              transform 0.4s cubic-bezier(0.22,1,0.36,1);
  position: relative;
  overflow: visible;
}
.timer-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 5px;
  border-radius: 16px 16px 0 0;
  background: var(--card-accent, var(--green-light));
  transition: background 0.3s;
  z-index: 0;
}

/* Status variations */
.timer-card.status-idle    { --card-accent: var(--status-idle); }
.timer-card.status-running { --card-accent: var(--status-running); border-color: rgba(45,122,61,0.5); }
.timer-card.status-paused  { --card-accent: var(--status-paused); border-color: rgba(200,168,75,0.4); }
.timer-card.status-expired { --card-accent: var(--status-expired); border-color: rgba(192,57,43,0.5); animation: expired-pulse 1.2s ease-in-out infinite; }
.timer-card.status-warning { --card-accent: var(--status-warning); border-color: rgba(230,126,34,0.5); }

@keyframes expired-pulse {
  0%, 100% { box-shadow: 0 6px 28px rgba(0,0,0,0.4); }
  50%       { box-shadow: 0 6px 40px rgba(192,57,43,0.5); }
}

/* ---- Close button ---- */
.timer-card > .card-close-btn {
  position: absolute;
  top: 10px; right: 10px;
  z-index: 100;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid #c0392b;
  background: #ffcdc8;
  color: #700010;
  font-size: 1.1rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  display: flex !important;
  align-items: center;
  justify-content: center;
  transition: background 0.18s;
  padding: 0;
  box-shadow: 0 2px 8px rgba(192,57,43,0.4);
  isolation: isolate;
  touch-action: manipulation;
}
.timer-card > .card-close-btn:hover,
.timer-card > .card-close-btn:active {
  background: #c0392b;
  color: #fff;
  transform: scale(1.1);
}

/* ---- Card header ---- */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
  padding-right: 42px;
}
.card-slot-num {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  color: var(--text-mid);
  font-weight: 700;
  text-transform: uppercase;
}
.card-status-badge {
  font-size: 0.68rem;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}
.status-idle    .card-status-badge { background: rgba(255,255,255,0.55); color: var(--text-dark); border: 1px solid rgba(74,90,74,0.4); }
.status-running .card-status-badge { background: rgba(200,240,210,0.85); color: #0d4020; border: 1px solid rgba(45,122,61,0.5); }
.status-paused  .card-status-badge { background: rgba(255,240,180,0.85); color: #5a3a00; border: 1px solid rgba(200,168,75,0.5); }
.status-expired .card-status-badge { background: rgba(255,210,200,0.85); color: #700010; border: 1px solid rgba(192,57,43,0.5); }
.status-warning .card-status-badge { background: rgba(255,225,180,0.85); color: #6a2800; border: 1px solid rgba(230,126,34,0.5); }

/* ---- Patient name & device ---- */
.card-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-device {
  font-size: 0.76rem;
  color: var(--text-mid);
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.card-device i { color: var(--green-light); }

/* ---- Big timer display ---- */
.timer-display {
  font-family: 'Cormorant Garamond', serif;
  font-size: 3.8rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.04em;
  color: var(--text-dark);
  text-shadow: 0 1px 8px rgba(255,255,255,0.5);
  margin: 4px 0 6px;
  transition: color 0.3s;
  line-height: 1;
}
.status-running .timer-display { color: #0d4020; }
.status-paused  .timer-display { color: #5a3a00; }
.status-expired .timer-display { color: #700010; }
.status-warning .timer-display { color: #6a2800; }

/* ---- Progress bar ---- */
.timer-progress-wrap {
  background: rgba(0,0,0,0.12);
  border-radius: 8px;
  height: 8px;
  margin: 0 0 12px;
  overflow: hidden;
}
.timer-progress-bar {
  height: 100%;
  border-radius: 8px;
  background: var(--green-light);
  transition: width 1s linear, background 0.5s;
}
.status-paused  .timer-progress-bar { background: var(--gold); }
.status-expired .timer-progress-bar { background: var(--status-expired); width: 100% !important; }
.status-warning .timer-progress-bar { background: var(--status-warning); }

/* ---- Duration row ---- */
.card-duration-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.8rem;
  color: var(--text-mid);
  font-weight: 600;
}
.card-duration-row select,
.duration-select {
  padding: 0 10px;
  height: 40px;
  background: rgba(245,240,232,0.88);
  border: 1.5px solid var(--green-mid);
  border-radius: 8px;
  color: var(--text-dark);
  font-size: 0.88rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%231e3828'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.card-duration-row select:focus { border-color: var(--gold); }

/* ---- Custom duration row ---- */
.card-custom-duration {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 12px;
}
.custom-duration-label {
  font-size: 0.74rem;
  color: var(--text-mid);
  font-weight: 700;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.custom-min-input,
.custom-sec-input {
  width: 58px;
  height: 40px;
  padding: 0 4px;
  background: rgba(245,240,232,0.92);
  border: 1.5px solid var(--green-mid);
  border-radius: 8px;
  color: var(--text-dark);
  font-size: 1rem;
  font-weight: 700;
  font-family: 'Lato', sans-serif;
  text-align: center;
  outline: none;
  /* On mobile, number inputs need explicit sizing */
  -moz-appearance: textfield;
  appearance: textfield;
}
.custom-min-input::-webkit-inner-spin-button,
.custom-min-input::-webkit-outer-spin-button,
.custom-sec-input::-webkit-inner-spin-button,
.custom-sec-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.custom-min-input:focus,
.custom-sec-input:focus { border-color: var(--gold); background: rgba(245,240,232,0.98); }
.custom-min-input:disabled,
.custom-sec-input:disabled { opacity: 0.4; cursor: not-allowed; }
.custom-min-input::placeholder,
.custom-sec-input::placeholder { color: #8a9a8a; font-weight: 400; font-size: 0.85rem; }
.custom-duration-sep {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-mid);
  line-height: 1;
}
.custom-duration-hint {
  font-size: 0.65rem;
  color: var(--text-mid);
  font-weight: 600;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

/* ---- Card controls — large touch targets ---- */
.card-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.ctrl-btn {
  height: var(--tap-min);
  border-radius: 10px;
  border: 1.5px solid rgba(30,56,40,0.4);
  background: rgba(245,240,232,0.60);
  color: var(--text-dark);
  font-size: 0.82rem;
  font-weight: 700;
  font-family: 'Lato', sans-serif;
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  backdrop-filter: blur(4px);
  touch-action: manipulation;
  /* prevent text selection on double-tap */
  -webkit-user-select: none;
  user-select: none;
}
.ctrl-btn span { font-size: 0.82rem; }
.ctrl-btn:active { transform: scale(0.96); }
.ctrl-btn:hover  { background: var(--green-mid); border-color: var(--gold); color: var(--gold-light); }
.ctrl-btn.btn-start  { border-color: rgba(45,122,61,0.5); grid-column: 1 / -1; background: rgba(45,122,61,0.15); }
.ctrl-btn.btn-start:hover  { background: rgba(45,122,61,0.4); color: #7dde8d; border-color: #4a9c5c; }
.ctrl-btn.btn-pause  { border-color: rgba(200,168,75,0.4); }
.ctrl-btn.btn-pause:hover  { background: rgba(200,168,75,0.25); color: var(--gold-light); border-color: var(--gold); }
.ctrl-btn.btn-reset  { border-color: rgba(192,57,43,0.35); }
.ctrl-btn.btn-reset:hover  { background: rgba(192,57,43,0.25); color: #ff9988; border-color: #c0392b; }
.ctrl-btn:disabled { opacity: 0.32; cursor: not-allowed; pointer-events: none; transform: none; }

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(5,20,10,0.82);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 16px;
}
.modal-box {
  background: rgba(245,240,232,0.96);
  border: 1.5px solid rgba(180,160,120,0.4);
  border-radius: 18px;
  padding: 24px 20px 20px;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(10,30,15,0.35);
  position: relative;
}
.modal-box h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.4rem;
  color: var(--green-dark);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.modal-box h2 i { color: var(--gold); }
.modal-close-btn, .modal-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 20px;
  height: var(--tap-min);
  border-radius: 8px;
  border: 1.5px solid;
  font-family: 'Lato', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.22s;
  margin-top: 12px;
  touch-action: manipulation;
}
.modal-close-btn {
  background: rgba(245,240,232,0.55);
  border-color: var(--text-mid);
  color: var(--text-dark);
  margin-left: 8px;
}
.modal-close-btn:hover { background: rgba(138,154,138,0.25); }
.modal-action-btn {
  background: var(--green-mid);
  border-color: var(--gold);
  color: var(--gold-light);
}
.modal-action-btn:hover { background: var(--green-dark); color: var(--cream); }

.camera-modal-box { max-width: 520px; }
.scan-status-text {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-mid);
  font-weight: 600;
  margin-top: 10px;
  min-height: 20px;
}
#reader { border-radius: 8px; overflow: hidden; border: 1.5px solid var(--green-light); }

.qr-modal-box { max-width: 820px; }
.qr-hint {
  font-size: 0.84rem;
  color: var(--text-dark);
  font-weight: 600;
  margin-bottom: 14px;
  line-height: 1.6;
}
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 12px; }
.qr-item { background: var(--white); border-radius: 8px; padding: 12px 8px 8px; text-align: center; color: var(--text-dark); }
.qr-item canvas { display: block; margin: 0 auto; }
.qr-item .qr-label {
  font-size: 0.72rem; font-weight: 700; color: var(--text-dark);
  margin-top: 6px; font-family: 'Lato', sans-serif;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.qr-item .qr-code-val { font-size: 0.62rem; color: var(--text-mid); font-weight: 600; font-family: monospace; }
.qr-actions { display: flex; align-items: center; justify-content: flex-end; }

/* Alert modal */
.alert-modal .modal-box { text-align: center; max-width: 420px; }
.alert-icon { font-size: 3rem; color: var(--gold); margin-bottom: 12px; }
.alert-icon i { color: var(--gold); }
.alert-modal h2 { font-size: 1.6rem; justify-content: center; color: var(--green-dark); }
.alert-modal #alert-message { color: var(--text-dark); font-weight: 600; margin: 8px 0 0; font-size: 1rem; line-height: 1.6; }
@keyframes pulse-ring {
  0%   { transform: scale(1); opacity: 1; }
  80%  { transform: scale(1.3); opacity: 0.2; }
  100% { transform: scale(1); opacity: 0; }
}
.pulse-icon { display: inline-block; animation: pulse-ring 1.4s ease-in-out infinite; }

/* ============================================================
   CARD HIDDEN / REVEALED
   Use opacity + transform transitions (NOT CSS animations).
   CSS animations restart whenever className is reassigned
   (e.g. from renderCard's status-class updates), which would
   reset opacity to 0 every 500 ms and make cards invisible.
   Transitions only fire when the property VALUE changes, so
   they are stable across repeated classList.add/remove calls.
   ============================================================ */
.timer-card.card-hidden {
  display: none;
  opacity: 0;
  transform: translateY(18px) scale(0.96);
  pointer-events: none;
}
.timer-card.card-revealed {
  display: block;
  opacity: 1 !important;
  transform: translateY(0) scale(1) !important;
  pointer-events: auto;
}

/* ============================================================
   SCAN PROMPT
   ============================================================ */
.scan-prompt {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 20px 56px;
  background: var(--cream-glass);
  border: 1.5px dashed rgba(200,168,75,0.5);
  border-radius: 18px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: opacity 0.5s, transform 0.5s;
}
.scan-prompt.prompt-faded {
  opacity: 0; transform: scale(0.97);
  pointer-events: none; height: 0; padding: 0; margin: 0; border: none; overflow: hidden;
}
.scan-prompt-icon {
  font-size: 4rem; color: var(--gold); margin-bottom: 18px;
  animation: prompt-pulse 2.4s ease-in-out infinite;
  filter: drop-shadow(0 4px 18px rgba(200,168,75,0.4));
}
@keyframes prompt-pulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50%       { transform: scale(1.08); opacity: 1; }
}
.scan-prompt h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.7rem; font-weight: 700;
  color: var(--text-dark); letter-spacing: 0.08em;
  margin-bottom: 12px;
  text-shadow: 0 1px 6px rgba(255,255,255,0.5);
}
.scan-prompt p {
  color: var(--text-dark); font-size: 0.9rem; font-weight: 600;
  max-width: 420px; line-height: 1.7; margin-bottom: 6px;
}
.scan-prompt p strong { color: var(--green-dark); font-weight: 800; }
.scan-prompt-sub { font-size: 0.76rem !important; color: var(--text-mid) !important; font-weight: 600 !important; margin-top: 4px; }

/* ============================================================
   ADMIN PAGE
   ============================================================ */
.page-content { max-width: 1100px; margin: 0 auto; padding: 20px 12px 60px; }
.page-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.6rem; color: var(--text-dark); font-weight: 700;
  text-shadow: 0 1px 6px rgba(255,255,255,0.5);
  letter-spacing: 0.08em; margin-bottom: 4px;
  display: flex; align-items: center; gap: 10px;
}
.page-title i { color: var(--gold); }
.page-subtitle { color: var(--text-dark); font-size: 0.85rem; font-weight: 600; letter-spacing: 0.06em; margin-bottom: 20px; }

.admin-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.admin-card {
  background: var(--cream-glass);
  border: 1.5px solid rgba(180,160,120,0.4);
  border-radius: 14px; padding: 18px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 4px 20px rgba(10,30,15,0.15);
}
.admin-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; padding-bottom: 10px;
  border-bottom: 2px solid rgba(74,140,92,0.4);
}
.admin-card-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.05rem; font-weight: 700;
  color: var(--text-dark);
  text-shadow: 0 1px 3px rgba(255,255,255,0.7);
}
.admin-slot-badge {
  background: rgba(245,240,232,0.90);
  border: 1.5px solid var(--green-mid);
  color: var(--text-dark);
  font-size: 0.72rem; font-weight: 700;
  padding: 2px 9px; border-radius: 20px; letter-spacing: 0.1em;
}
.form-group { margin-bottom: 12px; }
.form-group label {
  display: block; font-size: 0.72rem; letter-spacing: 0.12em;
  color: var(--text-dark); font-weight: 700; text-transform: uppercase; margin-bottom: 5px;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 0 12px;
  height: var(--tap-min);
  background: rgba(245,240,232,0.92);
  border: 1.5px solid var(--green-mid);
  border-radius: 8px;
  color: var(--text-dark);
  font-size: 0.92rem; font-weight: 600;
  font-family: 'Lato', sans-serif;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus { border-color: var(--gold); background: rgba(245,240,232,0.98); }
.form-group input::placeholder { color: #5a6a5a; font-weight: 500; }
.save-btn {
  width: 100%; height: var(--tap-min);
  border-radius: 8px; border: 1.5px solid var(--gold);
  background: var(--green-mid); color: var(--gold-light);
  font-family: 'Lato', sans-serif; font-size: 0.88rem;
  cursor: pointer; transition: all 0.22s;
  display: flex; align-items: center; justify-content: center;
  gap: 7px; margin-top: 6px; font-weight: 700;
}
.save-btn:hover { background: var(--green-dark); color: var(--cream); }
.save-success { font-size: 0.75rem; color: #0a5a20; font-weight: 700; text-align: center; margin-top: 6px; min-height: 18px; }

/* ============================================================
   LOG PAGE
   ============================================================ */
.log-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.log-filters input,
.log-filters select {
  padding: 0 12px; height: var(--tap-min);
  background: rgba(245,240,232,0.80);
  border: 1.5px solid var(--green-mid); border-radius: 8px;
  color: var(--text-dark); font-size: 0.88rem; font-weight: 600;
  font-family: 'Lato', sans-serif; outline: none;
}
.log-filters input:focus, .log-filters select:focus { border-color: var(--gold); }
.log-table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid rgba(180,160,120,0.35); box-shadow: 0 4px 20px rgba(10,30,15,0.15); }
table.log-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.log-table thead tr { background: rgba(245,240,232,0.85); }
.log-table th {
  padding: 10px 12px; text-align: left;
  color: var(--text-dark); font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  font-size: 0.7rem; border-bottom: 1px solid rgba(180,160,120,0.3);
  white-space: nowrap;
}
.log-table tbody tr { background: rgba(245,240,232,0.55); border-bottom: 1px solid rgba(180,160,120,0.2); }
.log-table tbody tr:hover { background: rgba(245,240,232,0.80); }
.log-table td { padding: 9px 12px; color: var(--text-dark); font-weight: 600; vertical-align: middle; }
.log-table td .status-pill {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
}
.pill-completed { background: rgba(200,240,210,0.85); color: #0d4020; border: 1px solid rgba(45,122,61,0.4); }
.pill-running   { background: rgba(180,230,200,0.85); color: #0a3818; border: 1px solid rgba(45,122,61,0.4); }
.pill-paused    { background: rgba(255,240,180,0.85); color: #5a3a00; border: 1px solid rgba(200,168,75,0.5); }
.pill-cancelled { background: rgba(220,220,215,0.85); color: #2a2a2a; border: 1px solid rgba(100,100,100,0.3); }
.pill-expired   { background: rgba(255,210,200,0.85); color: #700010; border: 1px solid rgba(192,57,43,0.4); }
.log-empty { text-align: center; padding: 36px; color: var(--text-dark); font-weight: 600; font-size: 0.9rem; }
.log-pagination {
  display: flex; justify-content: center; align-items: center;
  gap: 10px; margin-top: 16px;
  font-size: 0.82rem; font-weight: 600; color: var(--text-dark);
}
.log-pagination button {
  height: var(--tap-min); padding: 0 18px;
  border-radius: 8px; border: 1.5px solid var(--green-mid);
  background: rgba(245,240,232,0.70); color: var(--text-dark);
  font-weight: 700; cursor: pointer; font-size: 0.82rem; transition: all 0.2s;
}
.log-pagination button:hover { background: var(--green-mid); color: var(--cream); border-color: var(--gold); }
.log-pagination button:disabled { opacity: 0.35; cursor: not-allowed; }

/* Stats row */
.stats-row { display: grid; grid-template-columns: repeat(auto-fill,minmax(140px,1fr)); gap: 10px; margin-bottom: 18px; }
.stat-card {
  background: var(--cream-glass); border: 1px solid rgba(180,160,120,0.35);
  border-radius: 10px; padding: 12px 14px; text-align: center;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.stat-val { font-family: 'Cormorant Garamond', serif; font-size: 1.9rem; font-weight: 700; color: var(--text-dark); text-shadow: 0 1px 4px rgba(255,255,255,0.4); }
.stat-label { font-size: 0.68rem; color: var(--text-mid); font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; margin-top: 2px; }

/* ============================================================
   LOG PAGE — Active rows & View Timer button
   ============================================================ */

/* Highlight rows for running / paused timers */
.log-table tbody tr.log-row-active {
  background: rgba(200, 240, 210, 0.45) !important;
  border-left: 3px solid var(--green-light);
}
.log-table tbody tr.log-row-active:hover {
  background: rgba(200, 240, 210, 0.70) !important;
}

/* Live countdown shown above the View Timer button */
.log-live-time {
  display: block;
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--green-dark);
  letter-spacing: 0.06em;
  margin-bottom: 5px;
  text-shadow: 0 1px 3px rgba(255,255,255,0.5);
}
.log-paused-time {
  color: #7a5500;
}

/* Actions column cell */
.log-action-cell {
  white-space: nowrap;
  text-align: center;
  min-width: 110px;
}

/* "View Timer" button */
.btn-view-timer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1.5px solid var(--green-mid);
  background: rgba(45, 90, 61, 0.12);
  color: var(--green-dark);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.15s;
  white-space: nowrap;
}
.btn-view-timer:hover {
  background: var(--green-mid);
  color: var(--cream);
  border-color: var(--gold);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(10,30,15,0.25);
}
.btn-view-timer i {
  font-size: 0.7rem;
}

/* ============================================================
   TIMER CARD — Highlight ring (after navigating from Log page)
   ============================================================ */
@keyframes highlight-ring-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(200, 168, 75, 0.9),  0 6px 28px rgba(10,30,15,0.22); }
  40%  { box-shadow: 0 0 0 10px rgba(200, 168, 75, 0.35), 0 6px 28px rgba(10,30,15,0.22); }
  70%  { box-shadow: 0 0 0 18px rgba(200, 168, 75, 0.08), 0 6px 28px rgba(10,30,15,0.22); }
  100% { box-shadow: 0 0 0 0   rgba(200, 168, 75, 0),    0 6px 28px rgba(10,30,15,0.22); }
}
.timer-card.card-highlight-ring {
  animation: highlight-ring-pulse 0.9s ease-out 3;
  border-color: var(--gold) !important;
  outline: none;
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  body { background: white; }
  body::before, .bg-overlay { display: none; }
  .site-header, .scanner-section, .modal-overlay,
  .qr-actions button.modal-close-btn { display: none !important; }
  .modal-overlay { display: flex !important; position: static !important; background: none !important; }
  .modal-box { box-shadow: none !important; border: none !important; background: white !important; color: black !important; max-width: 100% !important; }
  .modal-box h2, .qr-hint { color: black !important; }
  .qr-item { border: 1px solid #ccc; }
  .qr-item .qr-label { color: black !important; }
}

/* ============================================================
   RESPONSIVE BREAKPOINTS
   ============================================================ */

/* Small phone (≥ 400px) — 2-column grid */
@media (min-width: 400px) {
  .timer-grid { grid-template-columns: 1fr 1fr; }
  .timer-display { font-size: 2.8rem; }
  .ctrl-btn.btn-start { grid-column: 1 / -1; }
}

/* Tablet (≥ 640px) */
@media (min-width: 640px) {
  .site-header { padding: 12px 0 10px; }
  .site-logo { max-height: 80px; max-width: 260px; margin-bottom: 6px; }
  .site-title { font-size: 1.65rem; }
  .site-subtitle { font-size: 0.7rem; }
  .nav-btn { font-size: 0.8rem; padding: 7px 18px; }
  .timers-main { padding: 18px 14px 80px; }
  .timer-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
  .timer-display { font-size: 3.4rem; }
  .admin-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
}

/* Desktop (≥ 1024px) */
@media (min-width: 1024px) {
  .site-logo { max-height: 110px; max-width: 340px; }
  .site-title { font-size: 2rem; }
  .site-subtitle { font-size: 0.82rem; margin: 4px 0 12px; }
  .nav-btn { font-size: 0.82rem; padding: 7px 20px; }
  .timers-main { padding: 28px 16px 60px; }
  .timer-display { font-size: 3.8rem; }
  .timer-card:hover { transform: translateY(-2px); box-shadow: 0 10px 36px rgba(0,0,0,0.55); }
}
