/* ---- Design tokens ---- */
:root {
  --bg: #f3f4f8;
  --surface: #ffffff;
  --text: #14161f;
  --text-muted: #6b7280;
  --border: #e8e9ef;

  --primary: #3d5afe;
  --primary-dark: #2f46e0;
  --primary-tint: #eef1ff;

  /* Darkened from the original tints so status text on white/tint
     backgrounds clears WCAG AA (4.5:1) for normal-size text. */
  --success: #157a45;
  --success-tint: #e8f7ee;
  --warning: #9a5b0a;
  --warning-tint: #fdf1e0;
  --danger: #b3221f;
  --danger-tint: #fdeceb;
  --info: #4338ca;
  --info-tint: #eef0fe;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-card: 0 1px 2px rgba(20, 22, 31, 0.04), 0 4px 16px rgba(20, 22, 31, 0.05);
  --shadow-pop: 0 8px 30px rgba(20, 22, 31, 0.14);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 120ms;
  --dur: 180ms;
}

* { box-sizing: border-box; }

html { -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* Respect reduced-motion preference: kill transitions/animations, keep function */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Consistent, visible keyboard focus everywhere (accessibility) */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---- Topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.05rem;
  white-space: nowrap;
  border-radius: var(--radius-sm);
  transition: opacity var(--dur-fast) ease;
}
.brand:hover { opacity: 0.75; }

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--text);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex: 0 0 auto;
}
/* When the business has uploaded a logo, the mark holds the image instead of
   the letter fallback. */
.brand-mark.brand-logo { background: transparent; padding: 0; overflow: hidden; }
.brand-mark.brand-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  padding: 4px;
  border-radius: 999px;
}

.topnav a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  min-height: 40px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  transition: background var(--dur) ease, color var(--dur) ease, transform var(--dur-fast) ease;
}

.topnav a svg { width: 16px; height: 16px; }

.topnav a.active {
  background: var(--primary);
  color: white;
}

.topnav a:not(.active):hover { background: var(--border); color: var(--text); }
.topnav a:not(.active):active { transform: scale(0.96); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
  flex: 0 0 auto;
  transition: background var(--dur) ease, color var(--dur) ease, border-color var(--dur) ease, transform var(--dur-fast) ease;
}
.icon-btn:hover { background: var(--bg); color: var(--text); border-color: var(--text-muted); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 18px; height: 18px; }

/* Profile dropdown */
.profile {
  position: relative;
}
.profile-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border: none;
  background: none;
  padding: 2px;
  border-radius: 999px;
  font-family: inherit;
  transition: transform var(--dur-fast) ease;
}
.profile-trigger:hover { opacity: 0.85; }
.profile-trigger:active { transform: scale(0.95); }
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: var(--primary-tint);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex: 0 0 auto;
  border: 2px solid transparent;
  transition: border-color var(--dur) ease;
}
.profile-trigger:hover .avatar { border-color: var(--primary-tint); }

/* Shared "popover" look for profile menu + date filter panel, with an
   animated entrance instead of an instant display:none/block swap. */
.profile-menu,
.date-filter-panel {
  position: absolute;
  right: 0;
  top: 52px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top right;
  transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out), visibility 0s linear var(--dur);
  pointer-events: none;
}
.profile.open .profile-menu,
.date-filter.open .date-filter-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
  pointer-events: auto;
}

.profile-menu { min-width: 210px; padding: 8px; }
.profile-menu .who {
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.profile-menu .who .name { font-weight: 700; font-size: 0.92rem; }
.profile-menu .who .role { color: var(--text-muted); font-size: 0.78rem; text-transform: capitalize; }
.profile-menu a, .profile-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  min-height: 40px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  font-size: 0.88rem;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  transition: background var(--dur-fast) ease;
}
.profile-menu a:hover, .profile-menu button:hover { background: var(--bg); }
.profile-menu button.danger-text { color: var(--danger); }
.profile-menu svg { width: 16px; height: 16px; color: var(--text-muted); flex: 0 0 auto; }

/* ---- Layout ---- */
.container { max-width: 1080px; margin: 0 auto; padding: 28px 24px 60px; }
.container.narrow { max-width: 640px; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-head h1 { margin: 0 0 4px; font-size: 1.5rem; font-weight: 700; }
.page-head .sub { color: var(--text-muted); font-size: 0.92rem; margin: 0; }
.page-head-actions { display: flex; gap: 10px; flex: 0 0 auto; flex-wrap: wrap; }

h2 { font-size: 1.05rem; margin: 0 0 14px; font-weight: 700; }

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px;
  margin-bottom: 18px;
  transition: box-shadow var(--dur) ease;
}

/* ---- Stat cards ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--dur) ease, transform var(--dur) ease;
}
.stat-card:hover { box-shadow: var(--shadow-pop); transform: translateY(-1px); }
.stat-card.highlight {
  background: var(--primary);
  border-color: var(--primary);
}
.stat-card .label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.stat-card.highlight .label { color: rgba(255,255,255,0.85); }
.stat-card .value { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-card.highlight .value { color: white; }

/* ---- Forms ---- */
label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text); margin: 14px 0 6px; }
label .hint { font-weight: 400; color: var(--text-muted); }

input[type=text], input[type=tel], input[type=password], input[type=number], input[type=date], textarea, select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px; /* keeps iOS Safari from auto-zooming on focus */
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  min-height: 44px;
  transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
textarea { resize: vertical; min-height: unset; }
input:hover, textarea:hover, select:hover { border-color: #cfd2dc; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}
input:disabled:hover, textarea:disabled:hover, select:disabled:hover { border-color: transparent; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--primary);
  color: white;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  transition: background var(--dur) ease, transform var(--dur-fast) ease, box-shadow var(--dur) ease;
}
.btn svg { width: 16px; height: 16px; flex: 0 0 auto; }
.btn:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(61, 90, 254, 0.25); }
.btn:active { transform: scale(0.97); box-shadow: none; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; box-shadow: none; transform: none; }
.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--bg); box-shadow: none; border-color: #cfd2dc; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #921a18; box-shadow: 0 4px 12px rgba(179, 34, 31, 0.25); }
.btn.pill-toggle { min-height: 38px; padding: 8px 14px; font-size: 0.85rem; border-radius: 999px; }

/* ---- Filter bar ---- */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar .search-field { flex: 2; min-width: 220px; position: relative; }
.filter-bar .search-field svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-muted);
  pointer-events: none;
}
.filter-bar .search-field input { padding-left: 36px; }
.filter-bar select { width: auto; min-width: 150px; }
.filter-bar > div:not(.search-field) { flex: 1; min-width: 130px; }
/* Actions (Filter + optional Clear) hug their content so showing "Clear
   filters" doesn't steal width from the search box and dropdowns. */
.filter-bar .filter-actions { flex: 0 0 auto; min-width: 0; display: flex; align-items: center; gap: 14px; }
.clear-filters { color: var(--text-muted); font-size: 0.85rem; font-weight: 500; text-decoration: none; white-space: nowrap; }
.clear-filters:hover { color: var(--primary); text-decoration: underline; }

/* ---- Template preview + char count ---- */
.tmpl-preview-label { margin-top: 12px; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.tmpl-preview { margin-top: 4px; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); white-space: pre-wrap; font-size: 0.88rem; color: var(--text); min-height: 1.5em; }
.tmpl-charcount { margin-top: 6px; font-size: 0.78rem; }
.tmpl-charcount.over-limit { color: var(--danger); }

/* ---- Landing page (bare root domain) ---- */
.landing { max-width: 960px; margin: 0 auto; padding: 0 20px 60px; }
.landing-nav { display: flex; align-items: center; justify-content: space-between; padding: 20px 0; }
.hero { text-align: center; padding: 56px 0 40px; }
.hero h1 { font-size: 2.2rem; line-height: 1.15; margin: 0 0 16px; letter-spacing: -0.02em; }
.hero-sub { color: var(--text-muted); font-size: 1.05rem; max-width: 620px; margin: 0 auto 26px; line-height: 1.6; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 20px 0 40px; }
.feature h3 { margin: 0 0 6px; font-size: 1rem; }
.feature p { margin: 0; }
.contact { max-width: 620px; margin: 0 auto; }
.landing-foot { text-align: center; padding-top: 40px; }
@media (max-width: 560px) { .hero h1 { font-size: 1.7rem; } .hero { padding: 32px 0 24px; } }

/* ---- Toast (transient action feedback) ---- */
.toast-region { position: fixed; top: 18px; right: 18px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px;
  min-width: 240px; max-width: min(92vw, 400px);
  padding: 12px 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-pop);
  font-size: 0.9rem; font-weight: 500;
  pointer-events: auto;
  opacity: 0; transform: translateY(-8px) scale(0.98);
  transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
}
.toast.toast-show { opacity: 1; transform: none; }
.toast.toast-hide { opacity: 0; transform: translateY(-8px) scale(0.98); }
.toast-icon { display: inline-flex; flex: 0 0 auto; }
.toast-icon svg { width: 20px; height: 20px; }
.toast-msg { flex: 1 1 auto; }
.toast-close { flex: 0 0 auto; border: none; background: none; color: var(--text-muted); font-size: 1.2rem; line-height: 1; cursor: pointer; padding: 2px 4px; border-radius: 4px; }
.toast-close:hover { color: var(--text); background: var(--bg); }
.toast-success { border-left-color: var(--success); }
.toast-success .toast-icon { color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-error .toast-icon { color: var(--danger); }
.toast-info { border-left-color: var(--info); }
.toast-info .toast-icon { color: var(--info); }
@media (max-width: 480px) {
  .toast-region { top: 12px; right: 10px; left: 10px; }
  .toast { min-width: 0; max-width: 100%; }
}

/* ---- Back link (generic, e.g. order detail) ---- */
.btn-link-back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 14px; color: var(--text-muted); font-size: 0.85rem; font-weight: 500; text-decoration: none; }
.btn-link-back:hover { color: var(--primary); }

/* ---- Table ---- */
.table-scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 560px; }
th, td { text-align: left; padding: 13px 10px; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
th { color: var(--text-muted); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr { transition: background var(--dur-fast) ease; }
tbody tr:last-child td { border-bottom: none; }
table.row-hover tbody tr { cursor: pointer; }
table.row-hover tbody tr:hover { background: var(--bg); }
table.row-hover tbody tr:focus-within { background: var(--bg); }
td .order-code { font-weight: 700; text-decoration: none; transition: color var(--dur-fast) ease; }
a.order-code:hover, a.order-code:focus-visible { color: var(--primary); text-decoration: underline; }
td .timestamp { color: var(--text-muted); font-size: 0.8rem; }
tbody tr[data-href] { cursor: pointer; }

/* Copy-to-clipboard button (e.g. next to phone numbers) */
.copyable { display: inline-flex; align-items: center; gap: 6px; }
.copy-btn {
  border: none; background: none; color: var(--text-muted); cursor: pointer;
  padding: 4px; border-radius: 6px; display: inline-flex; flex: 0 0 auto;
  transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
}
.copy-btn:hover { background: var(--bg); color: var(--text); }
.copy-btn.copied { color: var(--success); }
.copy-btn svg { width: 15px; height: 15px; }

/* Sortable table headers */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--text); }
th.sortable::after { content: "\2195"; margin-left: 5px; opacity: 0.35; font-size: 0.85em; }
th.sortable.sort-asc::after { content: "\2191"; opacity: 1; color: var(--primary); }
th.sortable.sort-desc::after { content: "\2193"; opacity: 1; color: var(--primary); }

/* Row status select in the dashboard table */
.row-status-select {
  min-height: 40px;
  padding: 6px 10px;
  border-color: var(--border);
  width: 200px;
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.row-status-select:hover { border-color: #cfd2dc; }

/* Status text (color + label, not color-only: label always shown) */
.status-text {
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.status-text.received, .status-text.out_for_delivery { color: var(--info); }
.status-text.ready_pickup, .status-text.ready_delivery { color: var(--warning); }
.status-text.delivered, .status-text.picked_up { color: var(--success); }
.status-text.cancelled { color: var(--danger); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.badge.received, .badge.out_for_delivery { background: var(--info-tint); color: var(--info); }
.badge.ready_pickup, .badge.ready_delivery { background: var(--warning-tint); color: var(--warning); }
.badge.delivered, .badge.picked_up { background: var(--success-tint); color: var(--success); }
.badge.cancelled { background: var(--danger-tint); color: var(--danger); }

/* ---- Misc ---- */
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 180px; }

.error {
  background: var(--danger-tint);
  color: var(--danger);
  border: 1px solid #f5c6c7;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.88rem;
  font-weight: 500;
}

.item-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.item-row input { min-width: 0; } /* let inputs shrink so the row never overflows on mobile */
.item-row input[type=text] { flex: 3; }
.item-row input[type=number] { flex: 1; max-width: 90px; }
/* Keep the remove (x) button a fixed square even under the mobile .btn{width:100%} rule */
.item-row button { flex: 0 0 auto; width: 44px; padding-left: 0; padding-right: 0; }

.muted { color: var(--text-muted); font-size: 0.88rem; }
.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-muted);
}
/* Icon sits in a soft circular badge so it reads clearly on the white card
   (was var(--border) — nearly invisible). box-sizing keeps the 64px total. */
.empty-state svg {
  width: 64px; height: 64px; padding: 18px;
  margin: 0 auto 16px;
  background: var(--bg); color: var(--text-muted);
  border-radius: 999px; box-sizing: border-box;
}
.empty-state p { margin: 0; font-size: 0.95rem; line-height: 1.6; }
.empty-state a { color: var(--primary); font-weight: 600; text-decoration: none; }
.empty-state a:hover { text-decoration: underline; }

/* Login/OTP screens: vertically centre the card instead of pinning it near
   the top with a big empty gap below. */
.container.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: 24px;
  padding-bottom: 40px;
}
.login-wrap { width: 100%; max-width: 380px; margin: 0; }
.login-wrap .brand { justify-content: center; margin-bottom: 22px; font-size: 1.2rem; }
.login-wrap .brand .brand-mark { width: 42px; height: 42px; border-radius: 12px; font-size: 1.1rem; }

.checkbox-row { display: flex; align-items: center; gap: 9px; margin-top: 12px; }
.checkbox-row input { width: 18px; height: 18px; min-height: unset; accent-color: var(--primary); cursor: pointer; }
.checkbox-row label { cursor: pointer; }

.status-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.msg-log { margin-top: 8px; display: flex; flex-direction: column; gap: 10px; }
.msg-log .entry {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--border);
  background: var(--bg);
  font-size: 0.85rem;
}
.msg-log .entry.sent { border-color: var(--success); }
.msg-log .entry.failed { border-color: var(--danger); }
.msg-log .entry .meta { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; font-weight: 600; }

.chip-group { display: flex; gap: 8px; flex-wrap: wrap; }

.divider { height: 1px; background: var(--border); margin: 18px 0; border: none; }

/* ---- Confirmation modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 26, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur) ease, visibility 0s linear var(--dur);
}
.modal-overlay.show {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--dur) ease;
}
.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: 22px;
  max-width: 380px;
  width: 100%;
  transform: translateY(10px) scale(0.97);
  transition: transform var(--dur) var(--ease-out);
}
.modal-overlay.show .modal-box { transform: translateY(0) scale(1); }
.modal-box .modal-title { font-weight: 700; font-size: 1.05rem; margin-bottom: 8px; }
.modal-box .modal-message { color: var(--text-muted); font-size: 0.92rem; margin-bottom: 20px; line-height: 1.5; white-space: pre-line; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

/* ---- Editable field affordance ---- */
input.editable-field:disabled, textarea.editable-field:disabled, select.editable-field:disabled {
  background: var(--bg);
  color: var(--text);
  border-color: transparent;
  cursor: default;
}
.edit-actions { display: none; gap: 10px; margin-top: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.edit-actions.visible { display: flex; }

/* ---- Date filter row ---- */
.date-range { display: flex; align-items: center; gap: 8px; }
.date-range input[type=date] { min-width: 140px; }

/* ---- Date filter popover (single calendar-icon trigger) ---- */
.date-filter { position: relative; display: inline-block; }
.date-filter-panel {
  padding: 16px;
  width: 240px;
  max-width: calc(100vw - 32px);
}
.date-filter-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* ---- Breakpoints ---- */
@media (max-width: 900px) {
  .container { max-width: 100%; }
}

@media (max-width: 720px) {
  .topbar { padding: 10px 14px; gap: 10px; }
  .brand span:last-child { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topnav a span { display: none; }
  .topnav a { padding: 10px; }
  .container { padding: 18px 14px 60px; }
  .filter-bar select { min-width: 110px; }
  .page-head { gap: 12px; }
  .page-head h1 { font-size: 1.3rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .date-filter-panel, .profile-menu { right: -8px; }
}

@media (max-width: 480px) {
  .container { padding: 14px 10px 50px; }
  .card { padding: 16px; border-radius: var(--radius); }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px 16px; }
  .stat-card .value { font-size: 1.4rem; }
  .btn { width: 100%; }
  .page-head-actions { width: 100%; }
  .page-head-actions .btn, .page-head-actions .date-filter { flex: 1; }
  .date-filter .btn { width: 100%; }
  .status-form { flex-direction: column; }
  .status-form form { width: 100%; }
  .status-form .btn { width: 100%; }
  .modal-actions .btn { flex: 1; }
}
