/* ═══════════════════════════════════════════
   DT Hedonista CRM — styles.css
   Mobile-first. Phone is the primary target.
═══════════════════════════════════════════ */

/* ── Variables ────────────────────────────── */
:root {
  --bg: #f7f6f4;
  --panel: #ffffff;
  --text: #182126;
  --muted: #5c676d;
  --line: rgba(24, 33, 38, 0.12);
  --accent: #b84c2a;
  --accent-2: #227c70;
  --accent-3: #d5a021;
  --accent-4: #375a7f;
  --danger: #912f2f;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --r: 16px;       /* base border-radius */
  --r-lg: 22px;    /* panel / card radius */
  --gap: 0.65rem;  /* base gap */
}

/* ── Reset ────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-width: 320px;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

a { color: inherit; text-decoration: none; }

button, input, select, textarea { font: inherit; }

h1, h2, h3, strong {
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

p { margin: 0.25rem 0 0; }

/* ── Desktop shell header ─────────────────── */
/* Hidden on mobile; shown at ≥921px          */
.shell-header { display: none; }

/* ── Mobile navigation ────────────────────── */
.mobile-nav {
  position: fixed;
  left: 50%;
  bottom: max(10px, var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 20;
  width: min(500px, calc(100% - 12px));
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.mobile-nav-link {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 4px;
  border-radius: 13px;
  font-size: 0.78rem;
  text-align: center;
  letter-spacing: 0.01em;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  width: 100%;
}

.mobile-nav-link.is-active {
  background: var(--text);
  color: #ffffff;
}

/* ── Mobile "Više" sheet ──────────────────── */
.mobile-more-overlay,
.mobile-more-sheet {
  display: none;
}

.mobile-more-overlay[hidden],
.mobile-more-sheet[hidden] {
  display: none !important;
}

.mobile-more-overlay:not([hidden]) {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 24;
  background: rgba(24, 33, 38, 0.25);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.mobile-more-sheet:not([hidden]) {
  display: block;
  position: fixed;
  right: 8px;
  bottom: calc(72px + var(--safe-bottom));
  left: 8px;
  z-index: 25;
  max-width: 420px;
  margin: 0 auto;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 8px 32px rgba(24, 33, 38, 0.12);
}

.mobile-more-links {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.mobile-more-link {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  font-size: 0.95rem;
}

.mobile-more-link.is-active {
  background: var(--text);
  color: #ffffff;
  border-color: var(--text);
}

.mobile-more-logout button { width: 100%; }

/* ── Page shell ───────────────────────────── */
.app-page {
  min-height: 100vh;
  min-height: 100dvh;
}

.page-shell {
  padding:
    0.75rem
    max(0.75rem, var(--safe-right))
    calc(80px + var(--safe-bottom))
    max(0.75rem, var(--safe-left));
}

/* ── Eyebrow label ────────────────────────── */
.eyebrow {
  margin: 0 0 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-size: 0.68rem;
  color: var(--muted);
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
}

/* ── Page top action bar ──────────────────── */
.page-top {
  display: flex;
  justify-content: flex-end;
  margin-bottom: var(--gap);
}

.page-top--split {
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.page-top strong {
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.inline-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.customers-page-actions {
  justify-content: flex-end;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.customers-page-note {
  white-space: nowrap;
}

.customers-create-button {
  width: auto;
  min-height: 42px;
  padding: 0.7rem 1rem;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1;
  white-space: nowrap;
}

.delivery-actions {
  margin-top: 0.75rem;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.form-notice {
  margin: 0;
  color: #1f7a57;
  font-size: 0.9rem;
}

.range-tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: nowrap;
  justify-content: flex-end;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.range-tabs::-webkit-scrollbar {
  display: none;
}

.range-tab {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  font-size: 0.82rem;
  white-space: nowrap;
  flex: 0 0 auto;
}

.range-tab.is-active {
  background: var(--text);
  color: #ffffff;
  border-color: var(--text);
}

/* ── Panels ───────────────────────────────── */
.panel {
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--panel);
  overflow: hidden;
}

/* ── Driver card ──────────────────────────── */
.driver-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}

.user-management-panel {
  margin-bottom: 1rem;
}

.user-perm-groups {
  display: grid;
  gap: 0.9rem;
}

.perm-group {
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #ffffff;
}

.perm-group-title {
  margin: 0 0 0.65rem;
  font-size: 0.9rem;
}

.checkbox-stack {
  display: grid;
  gap: 0.5rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.92rem;
}

.checkbox-label input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  min-height: 0;
  padding: 0;
  margin: 0;
  flex-shrink: 0;
}

.form-actions {
  display: flex;
  justify-content: flex-start;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.compact-submit {
  width: auto;
}

.managed-user-form-actions .ghost-button,
.managed-user-form-actions button {
  width: auto;
  min-width: 132px;
}

.user-card-grid {
  align-items: start;
}

.user-card {
  display: grid;
  gap: 0.9rem;
}

.user-email {
  margin: 0.2rem 0 0;
}

.user-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.76rem;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--muted);
  white-space: nowrap;
}

.badge-soft {
  background: rgba(24, 33, 38, 0.06);
  color: var(--text);
}

.badge-muted,
.pill-muted {
  color: var(--muted);
  background: rgba(24, 33, 38, 0.05);
}

.user-card-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.user-card-actions form {
  margin: 0;
}

.schedule-panel {
  margin-bottom: 0.75rem;
}

.schedule-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(84px, 1fr);
  gap: 0.55rem;
  overflow-x: auto;
  padding-bottom: 0.1rem;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.schedule-grid::-webkit-scrollbar {
  display: none;
}

.schedule-day-card {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
  padding: 0.75rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #ffffff;
  color: inherit;
}

.schedule-day-month {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.schedule-day-number {
  font-size: 1.45rem;
  line-height: 1;
}

.schedule-day-count {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.2;
}

.schedule-day-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.15rem;
}

.schedule-day-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  padding: 0.14rem 0.45rem;
  border-radius: 999px;
  font-size: 0.68rem;
  line-height: 1.15;
  white-space: nowrap;
}

/* ── Delivery card recipient name ─────────── */
.recipient {
  display: block;
  margin: 0.2rem 0 0.1rem;
  font-size: 1rem;
}

/* ── Stat cards ───────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
  margin-bottom: var(--gap);
}

.stat-card {
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--panel);
  font-size: 0.85rem;
}

.stat-card strong {
  display: block;
  margin-top: 0.35rem;
  font-size: 1.55rem;
  line-height: 1.1;
}

.stat-label {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  display: block;
  margin-top: 0.4rem;
  font-size: 1.7rem;
  line-height: 1.1;
}

.stat-issue {
  color: var(--danger);
}

.stat-done {
  color: #1f7a57;
}

.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.stats-summary-grid .stat-card {
  min-width: 0;
}

.stats-summary-grid--secondary {
  margin-bottom: 1rem;
}

.stats-insights-grid {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}

.stats-panel {
  padding: 1rem;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.panel-title {
  margin: 0;
  font-size: 1.1rem;
}

.metric-list {
  display: grid;
  gap: 0.7rem;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 0.8rem 0;
  border-top: 1px solid var(--line);
}

.metric-row:first-child {
  border-top: none;
  padding-top: 0;
}

.metric-row:last-child {
  padding-bottom: 0;
}

.metric-main {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}

.metric-main strong {
  font-size: 1rem;
}

.metric-nums {
  display: grid;
  gap: 0.25rem;
  text-align: right;
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.metric-nums strong {
  color: var(--text);
}

.stats-daily-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.stats-daily-card {
  display: grid;
  gap: 0.4rem;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #ffffff;
}

.stats-daily-date {
  color: var(--muted);
  font-size: 0.82rem;
}

.stats-daily-total {
  font-size: 1.4rem;
  line-height: 1;
}

.stats-daily-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  color: var(--muted);
  font-size: 0.82rem;
}

/* ── Content grids ────────────────────────── */
.card-grid,
.two-column {
  display: grid;
  gap: var(--gap);
}

/* Filters: 2-col on mobile for compact layout */
.filters-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  margin-bottom: var(--gap);
  align-items: end;
}

/* Form: single column on mobile */
.form-grid {
  display: grid;
  gap: var(--gap);
}

.full-span { grid-column: 1 / -1; }

.form-subsection {
  display: grid;
  gap: 0.75rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #ffffff;
}

.delivery-items-list {
  display: grid;
  gap: 0.75rem;
}

.delivery-item-row {
  display: grid;
  gap: 0.75rem;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #ffffff;
}

.item-remove-button {
  width: auto;
  justify-self: start;
}

.article-active-toggle {
  align-self: end;
}

/* ── List components ──────────────────────── */
.list-stack { display: grid; gap: 0.7rem; }

.list-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: flex-start;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.88rem;
  color: var(--muted);
}

.delivery-topline {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}

/* ── Status chips & pills ─────────────────── */
.pill,
.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: rgba(24, 33, 38, 0.08);
  font-size: 0.78rem;
  white-space: nowrap;
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
}

.status-new      { background: rgba(55, 90, 127, 0.14); }
.status-scheduled { background: rgba(213, 160, 33, 0.22); }
.status-route    { background: rgba(34, 124, 112, 0.22); }
.status-done     { background: rgba(34, 124, 112, 0.34); }
.status-issue    { background: rgba(145, 47, 47, 0.22); color: var(--danger); }

/* ── Stat card accents ────────────────────── */
.accent-a { border-left: 3px solid var(--accent-4); }
.accent-b { border-left: 3px solid var(--accent-2); }
.accent-c { border-left: 3px solid var(--accent); }
.accent-d { border-left: 3px solid var(--accent-3); }

/* ── Priority badges ──────────────────────── */
.priority-badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
  margin-bottom: 0.3rem;
}

.priority-standard { background: rgba(24, 33, 38, 0.08); color: var(--text); }
.priority-high     { background: rgba(213, 160, 33, 0.2); color: #4a3000; }
.priority-critical { background: rgba(184, 76, 42, 0.12); color: var(--accent); }

/* ── Delivery cards ───────────────────────── */
.delivery-card {
  position: relative;
  cursor: pointer;
  transition: border-color 0.12s;
}

.delivery-card:hover { border-color: rgba(24, 33, 38, 0.3); }

.delivery-card h3 {
  margin: 0.2rem 0 0.15rem;
  font-size: 1rem;
  line-height: 1.2;
}

.delivery-card p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.3;
}

.delivery-card .meta-row { margin-top: 0.55rem; }

.delivery-card-tags {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.quick-status-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.6rem;
  align-items: end;
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--line);
}

.quick-status-label {
  display: grid;
  gap: 0.3rem;
  min-width: 0;
}

.quick-status-label span {
  color: var(--muted);
  font-size: 0.8rem;
}

.quick-status-select {
  width: 100%;
  min-width: 0;
}

.quick-status-submit {
  width: auto;
  min-width: 96px;
}

.card-link { color: inherit; font-size: 0.82rem; font-family: "Trebuchet MS", monospace; }

/* ── Form elements ────────────────────────── */
label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

label span { color: var(--text); }

input,
select,
textarea,
button,
.primary-link,
.ghost-button {
  border-radius: var(--r);
  border: 1px solid var(--line);
  padding: 0.8rem 0.9rem;
  background: #ffffff;
  box-shadow: none;
  width: 100%;
  min-height: 48px;
  font-size: 1rem; /* 16px — prevents iOS Safari auto-zoom on input focus */
}

button,
.primary-link {
  background: var(--text);
  color: #fff;
  cursor: pointer;
  text-align: center;
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
}

.ghost-button {
  background: transparent;
  color: var(--text);
  width: auto;
}

.danger-button {
  color: var(--danger);
  border-color: rgba(145, 47, 47, 0.25);
}

.compact-button {
  min-height: 36px;
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
  width: auto;
}

.history-filters {
  margin-bottom: 0.8rem;
}

.history-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 0.8rem;
}

.history-table-panel {
  padding-top: 0.8rem;
}

.history-table .muted {
  font-size: 0.9em;
}

.table-link {
  color: inherit;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.92rem;
}

/* Enforce width: auto in flex context (page-head buttons) */
.page-head .primary-link,
.page-head .ghost-button {
  width: auto;
  white-space: nowrap;
  flex-shrink: 0;
}

input[readonly] {
  background: rgba(24, 33, 38, 0.04);
  color: var(--muted);
  cursor: default;
}

.form-error {
  color: var(--danger);
  margin: 0;
  font-size: 0.88rem;
}

/* ── Tables — card view on mobile (default) ─ */
.table-panel { overflow-x: visible; }

.table-panel table {
  display: block;
  min-width: 0;
  width: 100%;
  border-collapse: collapse;
}

.table-panel thead { display: none; }
.table-panel tbody { display: block; }

.table-panel tr {
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--r);
  margin-bottom: 0.6rem;
  padding: 0.2rem 0.85rem;
  background: var(--panel);
}

.table-panel td {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
  gap: 0.75rem;
  font-size: 0.9rem;
}

.table-panel td:last-child { border-bottom: none; }

.table-panel td::before {
  content: attr(data-label);
  color: var(--muted);
  font-size: 0.8rem;
  flex-shrink: 0;
  min-width: 5rem;
}

/* Action cells: no label, right-aligned */
.table-panel td.table-actions {
  justify-content: flex-end;
  padding-bottom: 0.8rem;
  border-bottom: none;
}
.table-panel td.table-actions::before { display: none; }

/* Customers search: full-width input on mobile */
.customers-filter {
  grid-template-columns: 1fr;
}

.articles-page-actions {
  width: auto;
}

.articles-filter {
  margin-bottom: 0.8rem;
}

.articles-table-panel {
  padding-top: 0.85rem;
}

.articles-table td[data-label="Naziv"] .table-link {
  font-family: inherit;
  font-size: 1rem;
}

/* ── Login ────────────────────────────────── */
.login-panel {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding:
    calc(1rem + var(--safe-top))
    max(1rem, var(--safe-right))
    calc(1rem + var(--safe-bottom))
    max(1rem, var(--safe-left));
}

.login-panel .panel { width: min(460px, 100%); }

/* ── Form stack (login) ───────────────────── */
.form-stack {
  display: grid;
  gap: 0.85rem;
}

/* Password field with show/hide toggle */
.password-field {
  position: relative;
  display: flex;
}

.password-field input {
  padding-right: 3rem;
}

.password-toggle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 3rem;
  min-height: unset;
  padding: 0;
  border: none;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 0 var(--r) var(--r) 0;
  font-size: 1rem;
}

.password-toggle:hover { background: rgba(0,0,0,0.04); }

/* Remember me row */
.remember-me-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text);
}

.remember-me-row label { display: block; }

.remember-me-row input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  min-height: unset;
  flex-shrink: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 3px;
  cursor: pointer;
}

/* No nav padding on auth pages (login) */
.auth-page .page-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  padding-top: 0;
  padding-bottom: 1rem;
}

/* ── Utilities ────────────────────────────── */
.muted { color: var(--muted); font-size: 0.88rem; }
.align-right { text-align: right; }

.empty-state {
  grid-column: 1 / -1;
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--r-lg);
  font-size: 0.9rem;
}

/* ═══════════════════════════════════════════
   TABLET  641–920px — restore 2-col layouts
═══════════════════════════════════════════ */
@media (min-width: 641px) and (max-width: 920px) {
  .schedule-grid { grid-auto-flow: row; grid-template-columns: repeat(4, minmax(0, 1fr)); }

  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid  { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .delivery-item-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats-summary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stats-insights-grid { grid-template-columns: 1fr; }
  .stats-daily-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .user-perm-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .filters-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .customers-filter {
    grid-template-columns: 1fr auto;
  }
  .customers-filter > label {
    grid-column: 1 / -1;
  }
}

/* ═══════════════════════════════════════════
   DESKTOP  ≥921px — full layout
═══════════════════════════════════════════ */
@media (min-width: 921px) {
  :root {
    --r: 14px;
    --r-lg: 24px;
    --gap: 1rem;
  }

  body { font-size: 16px; }

  /* Show desktop nav, hide mobile nav */
  .shell-header {
    display: block;
    border-bottom: 1px solid var(--line);
    background: #ffffff;
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .shell-header-inner {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    align-items: center;
    width: min(1040px, calc(100% - 2rem));
    margin: 0 auto;
    padding:
      calc(0.85rem + var(--safe-top))
      0
      0.85rem;
  }

  .shell-nav {
    display: flex;
    gap: 0.55rem;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .shell-nav::-webkit-scrollbar { display: none; }

  .shell-nav a {
    white-space: nowrap;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #ffffff;
    font-size: 0.92rem;
  }

  .shell-nav a.is-active {
    background: var(--text);
    color: #ffffff;
    border-color: var(--text);
  }

  .shell-logout { justify-self: end; }

  /* Hide mobile nav completely */
  .mobile-nav,
  .mobile-more-overlay,
  .mobile-more-sheet { display: none !important; }

  /* Page shell */
  .page-shell {
    width: min(1040px, calc(100% - 2rem));
    margin: 1.5rem auto 0;
    padding: 0 0 2rem;
  }

  .panel          { padding: 1.15rem; border-radius: 24px; }
  .stat-card      { border-radius: 24px; }
  .stat-card strong { font-size: 1.8rem; }
  .schedule-grid  {
    grid-auto-flow: row;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.75rem;
    overflow: visible;
  }

  /* Grids */
  .stats-grid    { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
  .card-grid     { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
  .two-column    { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
  .filters-grid  { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.5rem; align-items: end; }
  .form-grid     { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
  .list-stack    { gap: 0.9rem; }
  .stats-summary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
  .stats-insights-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-daily-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .user-perm-groups { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .delivery-item-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  /* Form elements */
  input, select, textarea, button, .primary-link, .ghost-button {
    border-radius: 14px;
    padding: 0.85rem 0.95rem;
    font-size: 1rem;
  }

  /* Tables: restore proper table layout on desktop */
  .table-panel { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  .table-panel table {
    display: table;
    min-width: 640px;
    width: 100%;
    border-collapse: collapse;
  }

  .table-panel thead { display: table-header-group; }
  .table-panel tbody { display: table-row-group; }
  .table-panel tr    { display: table-row; border: none; border-radius: 0; margin: 0; padding: 0; background: transparent; }
  .table-panel td    { display: table-cell; padding: 0.85rem 0.5rem; border-bottom: 1px solid var(--line); font-size: 1rem; }
  .table-panel td::before { display: none; }

  th, td {
    text-align: left;
    padding: 0.85rem 0.5rem;
    border-bottom: 1px solid var(--line);
  }

  thead th {
    font-size: 0.82rem;
    color: var(--muted);
    font-family: "Trebuchet MS", "Gill Sans", sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding-bottom: 0.6rem;
  }

  /* Action column: shrink to content, right-align */
  .table-panel td.table-actions,
  th.table-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
    border-bottom: 1px solid var(--line);
    padding-bottom: 0.85rem;
  }

  /* Customers filter: restore 2-col on tablet+ */
  .customers-filter {
    grid-template-columns: 1fr auto;
  }
  .customers-filter > label {
    grid-column: 1 / -1;
  }

  .meta-row { font-size: 0.9rem; }
  .history-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .page-top--split {
    flex-direction: column;
    align-items: flex-start;
  }

  .articles-page-top {
    gap: 0.6rem;
  }

  .articles-page-actions {
    width: 100%;
  }

  .articles-page-actions .primary-link {
    width: auto;
    min-width: 0;
  }

  .articles-filter {
    padding: 0.85rem;
  }

  .articles-table-panel {
    padding: 0.75rem;
  }

  .articles-table tr {
    padding: 0.35rem 0.8rem;
  }

  .articles-table td {
    padding: 0.7rem 0;
    align-items: flex-start;
  }

  .articles-table td::before {
    min-width: 4.6rem;
  }

  .articles-table td[data-label="Naziv"] {
    display: grid;
    gap: 0.15rem;
  }

  .articles-table td[data-label="Naziv"]::before {
    min-width: 0;
  }

  .articles-table td.table-actions {
    justify-content: flex-start;
    padding-top: 0.85rem;
  }

  .articles-table td.table-actions .ghost-button {
    width: auto;
    min-width: 96px;
  }

  .customers-page-actions {
    width: 100%;
    align-items: flex-start;
    gap: 0.6rem;
  }

  .customers-page-note {
    white-space: normal;
  }

  .range-tabs {
    width: 100%;
    justify-content: flex-start;
    padding-bottom: 0.1rem;
  }

  .schedule-grid {
    margin-inline: -0.1rem;
    padding-inline: 0.1rem;
  }

  .schedule-day-card {
    min-width: 88px;
  }

  .delivery-card-tags {
    justify-content: flex-start;
  }

  .history-filters {
    grid-template-columns: 1fr;
  }

  .history-stats {
    grid-template-columns: 1fr;
  }

  .history-table-panel {
    padding: 0.75rem;
  }

  .quick-status-form {
    grid-template-columns: 1fr;
  }

  .quick-status-submit {
    width: 100%;
  }

  .panel-head,
  .metric-row {
    flex-direction: column;
  }

  .metric-nums {
    width: 100%;
    text-align: left;
  }

  /* Filter submit buttons: full-width on small screens */
  .filters-grid > button[type="submit"] {
    grid-column: 1 / -1;
  }
}
