/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --water:       #2196F3;
  --other-drink: #9C27B0;
  --large-meal:  #F44336;
  --small-meal:  #FF9800;
  --snack:       #4CAF50;

  --bg:          #F0F2F5;
  --surface:     #FFFFFF;
  --text:        #1A1A2E;
  --text-muted:  #666;
  --border:      #E0E0E0;
  --radius:      18px;
  --radius-sm:   10px;
  --shadow:      0 4px 16px rgba(0,0,0,0.12);
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.08);
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Header ────────────────────────────────────────────────────────────────── */
.app-header {
  background: var(--surface);
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 1rem;
}

.app-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.header-spacer { flex: 0 0 80px; }

.nav-link {
  flex: 0 0 80px;
  color: var(--water);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  white-space: nowrap;
}

.nav-link:hover, .nav-link:focus-visible {
  background: rgba(33,150,243,0.1);
  outline: none;
}

.nav-admin {
  font-size: 1.1rem;
  opacity: 0.45;
  transition: opacity 0.15s;
}
.nav-admin:hover { opacity: 1; background: transparent; }

/* ── Main page button grid ─────────────────────────────────────────────────── */
.page-main {
  /* fill viewport height minus header */
}

.button-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1.25rem;
  padding: 1.5rem;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  align-content: center;
}

@media (max-width: 960px) {
  .button-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 600px) {
  .button-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    padding: 1rem;
  }
  /* Last button centred when it's the only one on its row */
  .item-btn:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    max-width: calc(50% - 0.5rem);
    justify-self: center;
  }
}

/* ── Item buttons ──────────────────────────────────────────────────────────── */
.item-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem 1rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.14s ease, box-shadow 0.14s ease;
  min-height: 165px;
  color: white;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

.item-btn:hover   { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.18); }
.item-btn:active  { transform: scale(0.95);       box-shadow: 0 2px 8px rgba(0,0,0,0.15); }

.item-btn[data-type="water"]       { background: var(--water); }
.item-btn[data-type="other_drink"] { background: var(--other-drink); }
.item-btn[data-type="large_meal"]  { background: var(--large-meal); }
.item-btn[data-type="small_meal"]  { background: var(--small-meal); }
.item-btn[data-type="snack"]       { background: var(--snack); }

.btn-icon {
  width: 84px;
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.btn-icon svg { width: 100%; height: 100%; }

.btn-label {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

@media (max-height: 580px) {
  .item-btn  { min-height: 120px; }
  .btn-icon  { width: 60px; height: 60px; }
  .btn-label { font-size: 0.9rem; }
}

/* ── Confirmation modal ────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--surface);
  border-radius: 24px;
  padding: 2.25rem 2rem 2rem;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 24px 64px rgba(0,0,0,0.3);
  transform: scale(0.88) translateY(16px);
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-align: center;
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-question {
  font-size: 1.35rem;
  line-height: 1.45;
  color: var(--text);
  margin-bottom: 1.75rem;
}

.modal-actions {
  display: flex;
  gap: 0.875rem;
  justify-content: center;
}

.modal-btn {
  flex: 1;
  max-width: 145px;
  padding: 0.9rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s, opacity 0.12s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.modal-btn:active { transform: scale(0.95); opacity: 0.85; }

.modal-yes { background: #4CAF50; color: white; }
.modal-no  { background: #9E9E9E; color: white; }

/* ── Toast ─────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1A1A2E;
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 30px;
  font-size: 0.95rem;
  font-weight: 500;
  z-index: 200;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

.toast.show { transform: translateX(-50%) translateY(0); }

/* ── History page ──────────────────────────────────────────────────────────── */
.history-main {
  flex: 1;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Date controls */
.date-controls {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.date-shortcut {
  padding: 0.45rem 1rem;
  border: 2px solid var(--border);
  border-radius: 30px;
  background: transparent;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  white-space: nowrap;
}

.date-shortcut:hover        { border-color: var(--water); color: var(--water); }
.date-shortcut.active       { background: var(--water); border-color: var(--water); color: white; }

.date-inputs {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-left: auto;
}

.date-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}

.date-label input[type="date"] {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.6rem;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s;
  cursor: pointer;
}

.date-label input[type="date"]:focus {
  outline: none;
  border-color: var(--water);
}

@media (max-width: 520px) {
  .date-inputs { margin-left: 0; width: 100%; }
  .date-label input[type="date"] { flex: 1; }
}

/* Summary */
.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.summary-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.9rem;
  border-radius: 30px;
  color: white;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.summary-badge .count {
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1;
}

/* Day groups */
.day-group {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.day-heading {
  padding: 0.75rem 1.25rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.day-records {
  list-style: none;
}

.record-item {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.record-item:last-child { border-bottom: none; }
.record-item:hover { background: #FAFAFA; }

/* Top row: time + type + actions */
.record-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.record-time {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 72px;
  flex-shrink: 0;
}

.record-type-display { flex: 1; min-width: 0; }

.type-badge {
  display: inline-block;
  padding: 0.28rem 0.75rem;
  border-radius: 20px;
  color: white;
  font-size: 0.85rem;
  font-weight: 600;
}

.type-badge.water       { background: var(--water); }
.type-badge.other_drink { background: var(--other-drink); }
.type-badge.large_meal  { background: var(--large-meal); }
.type-badge.small_meal  { background: var(--small-meal); }
.type-badge.snack       { background: var(--snack); }

.record-type-select {
  flex: 1;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.5rem;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  display: none;
}

.record-type-select:focus { outline: none; border-color: var(--water); }

.record-item.editing .record-type-display { display: none; }
.record-item.editing .record-type-select  { display: block; }

.record-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.action-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.14s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  background: transparent;
  color: var(--text-muted);
}

.action-btn:hover  { background: var(--bg); }
.action-btn:active { transform: scale(0.92); }

.action-btn.save-btn   { color: #4CAF50; display: none; }
.action-btn.cancel-btn { color: #9E9E9E; display: none; }
.action-btn.delete-btn { color: #E53935; }

.record-item.editing .edit-btn   { display: none; }
.record-item.editing .delete-btn { display: none; }
.record-item.editing .save-btn   { display: flex; }
.record-item.editing .cancel-btn { display: flex; }

/* Notes row (below the main row) */
.record-notes-row {
  /* indent to align with the type column (time min-width + gap) */
  padding-left: calc(72px + 0.75rem);
}

.record-notes-display {
  margin-top: 0.35rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.record-notes-display:empty { display: none; }

.record-notes-edit {
  display: none;
  margin-top: 0.5rem;
  width: 100%;
  min-height: 64px;
  padding: 0.5rem 0.65rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  resize: vertical;
  line-height: 1.5;
  transition: border-color 0.15s;
}

.record-notes-edit:focus {
  outline: none;
  border-color: var(--water);
}

.record-item.editing .record-notes-edit { display: block; }

/* Empty / loading states */
.state-msg {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem;
  font-size: 1rem;
}

/* ── Shared nav-btn (for buttons styled as nav-links) ──────────────────────── */
.nav-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-family: inherit;
}

/* ── Admin login page ──────────────────────────────────────────────────────── */
.page-admin-login {
  background: linear-gradient(135deg, #1A1A2E 0%, #16213E 60%, #0F3460 100%);
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-login-wrap {
  width: 100%;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-login-card {
  background: white;
  border-radius: 24px;
  padding: 2.5rem 2rem 2rem;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 24px 64px rgba(0,0,0,0.4);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.admin-login-app {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.admin-login-title {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.admin-login-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.admin-login-error {
  min-height: 1.2rem;
  font-size: 0.88rem;
  color: #E53935;
  font-weight: 500;
}

.admin-back-link {
  margin-top: 0.5rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  text-decoration: none;
}

.admin-back-link:hover { color: var(--water); }

/* ── PIN boxes ─────────────────────────────────────────────────────────────── */
.pin-boxes {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin: 0.5rem 0;
}

.pin-box {
  width: 62px;
  height: 72px;
  border: 2.5px solid var(--border);
  border-radius: 14px;
  font-size: 1.8rem;
  text-align: center;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
  caret-color: transparent;
}

.pin-box:focus {
  outline: none;
  border-color: var(--water);
  box-shadow: 0 0 0 3px rgba(33,150,243,0.18);
}

.pin-box-error,
.pin-box-error:focus { border-color: #E53935; box-shadow: 0 0 0 3px rgba(229,57,53,0.15); }

/* Smaller variant used on the admin page change-PIN form */
.pin-boxes-sm .pin-box {
  width: 50px;
  height: 58px;
  font-size: 1.4rem;
  border-radius: 10px;
}

/* ── Admin primary button ───────────────────────────────────────────────────── */
.admin-primary-btn {
  width: 100%;
  max-width: 280px;
  padding: 0.9rem;
  margin-top: 0.4rem;
  background: var(--water);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.admin-primary-btn:hover   { opacity: 0.88; }
.admin-primary-btn:active  { transform: scale(0.97); }
.admin-primary-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Admin page cards ──────────────────────────────────────────────────────── */
.admin-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.admin-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.log-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.log-autoscroll-label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.admin-sm-btn {
  padding: 0.3rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: transparent;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.admin-sm-btn:hover { border-color: var(--water); color: var(--water); }

/* ── Log viewer ─────────────────────────────────────────────────────────────── */
.log-viewer {
  background: #12121E;
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  height: 380px;
  overflow-y: auto;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, 'Courier New', monospace;
  font-size: 0.78rem;
  line-height: 1.55;
  scroll-behavior: smooth;
}

.log-entry {
  display: grid;
  grid-template-columns: 68px 60px 42px 1fr;
  gap: 0.4rem;
  padding: 0.18rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  align-items: baseline;
}

.log-entry-new { background: rgba(33,150,243,0.07); border-radius: 3px; }

.log-date { color: #555; white-space: nowrap; }
.log-time { color: #666; white-space: nowrap; }

.log-level     { font-weight: 700; white-space: nowrap; }
.log-info      { color: #4CAF50; }
.log-error     { color: #F44336; }
.log-warn      { color: #FF9800; }

.log-msg  { color: #C8C8D4; word-break: break-word; }

.log-empty {
  color: #555;
  text-align: center;
  padding: 2rem 0;
  font-size: 0.85rem;
}

.log-updated {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: -0.25rem;
}

/* ── Change PIN form ────────────────────────────────────────────────────────── */
.pin-field-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.pin-field-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 90px;
}

.pin-status {
  min-height: 1.2rem;
  font-size: 0.88rem;
  font-weight: 500;
}

.pin-status-ok  { color: #4CAF50; }
.pin-status-err { color: #E53935; }

@media (max-width: 480px) {
  .pin-field-group { flex-direction: column; align-items: flex-start; gap: 0.4rem; }
  .log-entry { grid-template-columns: 60px 50px 38px 1fr; font-size: 0.72rem; }
}

/* ── SMS toggle ─────────────────────────────────────────────────────────────── */
.sms-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.sms-toggle-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 56px;
  text-align: right;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #CCC;
  border-radius: 28px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

.toggle-switch input:checked + .toggle-slider              { background: #4CAF50; }
.toggle-switch input:checked + .toggle-slider::before      { transform: translateX(22px); }
.toggle-switch input:focus-visible + .toggle-slider        { outline: 2px solid var(--water); outline-offset: 2px; }

/* ── Phone number management ────────────────────────────────────────────────── */
.phone-section { display: flex; flex-direction: column; gap: 0.75rem; }

.phone-section-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.phone-list { list-style: none; display: flex; flex-direction: column; gap: 0; }

.phone-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.phone-item:last-child { border-bottom: none; }

.phone-display {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: 'SF Mono', Consolas, monospace;
  color: var(--text);
}

.phone-edit-input {
  flex: 1;
  display: none;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.5rem;
  font-size: 0.9rem;
  font-family: 'SF Mono', Consolas, monospace;
  color: var(--text);
  background: var(--surface);
}

.phone-edit-input:focus { outline: none; border-color: var(--water); }

/* Editing state */
.phone-item.editing .phone-display   { display: none; }
.phone-item.editing .phone-edit-input { display: block; }
.phone-item.editing .phone-edit-btn  { display: none; }
.phone-item.editing .phone-delete-btn { display: none; }
.phone-item:not(.editing) .phone-save-btn   { display: none; }
.phone-item:not(.editing) .phone-cancel-btn { display: none; }

.phone-actions { display: flex; gap: 0.3rem; flex-shrink: 0; }

.phone-save-btn   { color: #4CAF50; border-color: #4CAF50; }
.phone-cancel-btn { color: #9E9E9E; }
.phone-delete-btn { color: #E53935; border-color: #E53935; }

.phone-save-btn:hover   { background: rgba(76,175,80,0.08); }
.phone-delete-btn:hover { background: rgba(229,57,53,0.08); }

.phone-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 0.5rem 0;
}

.phone-add-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.25rem;
}

.phone-add-input {
  flex: 1;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.65rem;
  font-size: 0.9rem;
  font-family: 'SF Mono', Consolas, monospace;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s;
}

.phone-add-input:focus { outline: none; border-color: var(--water); }

.phone-add-confirm { color: var(--water); border-color: var(--water); white-space: nowrap; }
.phone-add-confirm:hover { background: rgba(33,150,243,0.08); }

.phone-add-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: -0.25rem;
}

/* ── Small toggle (per phone number) ─────────────────────────────────────── */
.toggle-switch-sm {
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.toggle-switch-sm .toggle-slider {
  border-radius: 20px;
}

.toggle-switch-sm .toggle-slider::before {
  width: 14px;
  height: 14px;
  left: 3px;
  bottom: 3px;
}

.toggle-switch-sm input:checked + .toggle-slider::before {
  transform: translateX(16px);
}

/* ── Alert hours row ─────────────────────────────────────────────────────── */
.alert-hours-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

.alert-hours-label { font-size: 0.88rem; color: var(--text-muted); }

.alert-hours-input {
  width: 4rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
  text-align: center;
}

.alert-hours-input:focus { outline: none; border-color: var(--water); }

.alert-hours-unit { font-size: 0.88rem; color: var(--text-muted); }

.alert-hours-status { font-size: 0.82rem; }
.alert-hours-ok  { color: #4CAF50; }
.alert-hours-err { color: #ef5350; }

/* ── Server restart card ─────────────────────────────────────────────────── */
.restart-hint {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.admin-danger-btn {
  padding: 0.65rem 1.4rem;
  background: #ef5350;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.admin-danger-btn:hover   { opacity: 0.88; }
.admin-danger-btn:active  { transform: scale(0.97); }
.admin-danger-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.restart-status {
  margin-top: 0.75rem;
  font-size: 0.88rem;
  min-height: 1.2em;
}

.restart-ok  { color: #4CAF50; }
.restart-err { color: #ef5350; }

/* ── Quiet period ────────────────────────────────────────────────────────── */
.quiet-period-block {
  padding: 0.75rem 0 0.5rem;
  border-top: 1px solid var(--border);
  margin-top: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.quiet-period-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.quiet-period-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}

.quiet-period-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.quiet-period-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.quiet-time-input {
  padding: 0.3rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
  width: 7rem;
  color-scheme: dark;
}

.quiet-time-input:focus { outline: none; border-color: var(--water); }

.quiet-period-status { font-size: 0.82rem; }
.quiet-period-ok  { color: #4CAF50; }
.quiet-period-err { color: #ef5350; }

/* ── Next alert indicator ────────────────────────────────────────────────── */
.next-alert-box {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  margin: 0.75rem 0 0.25rem;
}

.next-alert-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  white-space: nowrap;
}

.next-alert-value {
  font-size: 0.9rem;
  color: var(--text);
}

/* State-based accent colours on the left border */
.next-alert-box[data-state="normal"]  { border-left: 3px solid #4CAF50; }
.next-alert-box[data-state="soon"]    { border-left: 3px solid #FF9800; }
.next-alert-box[data-state="sent"]    { border-left: 3px solid #2196F3; }
.next-alert-box[data-state="muted"]   { border-left: 3px solid var(--border); }

/* ── SMS templates link row ──────────────────────────────────────────────── */
.sms-templates-link-row {
  padding: 0.5rem 0 0.75rem;
}

.sms-templates-link {
  display: inline-block;
  text-decoration: none;
  color: var(--water);
  border-color: var(--water);
}

.sms-templates-link:hover { background: rgba(33,150,243,0.08); }

/* ── SMS templates page ──────────────────────────────────────────────────── */
.tpl-intro {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.tpl-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

.tpl-section-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.3rem;
}

.tpl-section-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 1rem;
}

.tpl-section-hint code {
  background: rgba(255,255,255,0.07);
  border-radius: 3px;
  padding: 0.1em 0.35em;
  font-family: monospace;
  font-size: 0.85em;
}

.tpl-field-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 1rem;
}

.tpl-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.tpl-input,
.tpl-textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  padding: 0.55rem 0.75rem;
  resize: vertical;
  transition: border-color 0.15s;
}

.tpl-input:focus,
.tpl-textarea:focus { outline: none; border-color: var(--water); }

.tpl-sender-input { max-width: 14rem; }

.tpl-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
}

.tpl-status {
  min-height: 1.2em;
  font-size: 0.88rem;
  margin-bottom: 0.75rem;
}

.tpl-status-ok  { color: #4CAF50; }
.tpl-status-err { color: #ef5350; }
