/* ==========================================================================
   Lumo SFA — Components
   Requires tokens.css. Vanilla CSS, no framework. Class-based; every class is
   namespaced under `lumo-` where collisions are likely, plain otherwise so it
   reads cleanly in Django templates.
   ========================================================================== */

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

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text);
  background: var(--surface-sunken);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, figure { margin: 0; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--radius);
}

/* ---------- Typographic helpers ------------------------------------------ */
.t-display  { font-size: var(--text-3xl); font-weight: var(--weight-bold);
              line-height: var(--leading-tight); letter-spacing: -0.01em; }
.t-title    { font-size: var(--text-2xl); font-weight: var(--weight-bold);
              line-height: var(--leading-tight); letter-spacing: -0.005em; }
.t-heading  { font-size: var(--text-xl); font-weight: var(--weight-semibold);
              line-height: var(--leading-tight); }
.t-subhead  { font-size: var(--text-lg); font-weight: var(--weight-semibold);
              line-height: var(--leading-tight); }
.t-body     { font-size: var(--text-base); font-weight: var(--weight-regular); }
.t-secondary{ color: var(--text-secondary); }
.t-muted    { color: var(--text-muted); }
.t-caption  { font-size: var(--text-sm); color: var(--text-secondary); }
.t-mono     { font-family: var(--font-mono); }
.t-eyebrow  { font-size: var(--text-xs); font-weight: var(--weight-semibold);
              letter-spacing: var(--tracking-label); text-transform: uppercase;
              color: var(--text-muted); }

/* ==========================================================================
   BUTTONS — primary / secondary / ghost / danger. + sizes, icon, block.
   ========================================================================== */
.btn {
  --btn-h: var(--control-height);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--btn-h);
  padding: 0 var(--space-4);
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  line-height: 1;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}
.btn:hover     { background: var(--gray-50); }
.btn:active    { background: var(--gray-100); }
.btn:disabled,
.btn[aria-disabled="true"] {
  color: var(--text-muted);
  background: var(--gray-50);
  border-color: var(--border);
  cursor: not-allowed;
}

/* Primary */
.btn--primary {
  color: var(--text-on-primary);
  background: var(--primary);
  border-color: var(--primary);
}
.btn--primary:hover  { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn--primary:active { background: var(--primary-active); border-color: var(--primary-active); }
.btn--primary:disabled {
  color: #fff; background: #a9c2ee; border-color: #a9c2ee;
}

/* Secondary = the default .btn (outlined). Explicit alias for clarity. */
.btn--secondary { /* inherits base */ }

/* Ghost — no border until hover */
.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn--ghost:hover  { background: var(--gray-100); color: var(--text); }
.btn--ghost:active { background: var(--gray-200); }

/* Danger */
.btn--danger {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}
.btn--danger:hover  { background: var(--danger-hover); border-color: var(--danger-hover); }

/* Sizes */
.btn--sm { --btn-h: var(--control-height-sm); padding: 0 var(--space-3); font-size: var(--text-sm); }
.btn--lg { --btn-h: 42px; padding: 0 var(--space-6); font-size: var(--text-md); }
.btn--icon { width: var(--btn-h); padding: 0; }
.btn--block { display: flex; width: 100%; }

.btn .ico { width: 16px; height: 16px; flex: none; }

/* ==========================================================================
   FORMS — label, control, help, validation states, select, textarea, check.
   ========================================================================== */
.field { display: flex; flex-direction: column; gap: var(--space-2); }

.label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text);
}
.label .req { color: var(--danger); margin-left: 2px; }
.label .optional { color: var(--text-muted); font-weight: var(--weight-regular); margin-left: var(--space-1); }

.input,
.select,
.textarea {
  width: 100%;
  height: var(--control-height);
  padding: 0 var(--space-3);
  font-family: inherit;
  font-size: var(--text-base);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  transition: border-color .12s ease, box-shadow .12s ease;
  appearance: none;
}
.textarea { height: auto; min-height: 84px; padding: var(--space-2) var(--space-3);
            line-height: var(--leading-normal); resize: vertical; }
.input::placeholder,
.textarea::placeholder { color: var(--text-muted); }

.input:hover,
.select:hover,
.textarea:hover { border-color: var(--gray-400); }

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  color: var(--text-muted);
  background: var(--gray-50);
  border-color: var(--border);
  cursor: not-allowed;
}

/* Select caret drawn with a background chevron (no decorative color) */
.select {
  padding-right: var(--space-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%2358616e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
}

.help { font-size: var(--text-sm); color: var(--text-secondary); }

/* Validation — error */
.field.is-error .input,
.field.is-error .select,
.field.is-error .textarea { border-color: var(--danger); }
.field.is-error .input:focus,
.field.is-error .select:focus,
.field.is-error .textarea:focus { box-shadow: var(--ring-danger); }
.field.is-error .help { color: var(--danger); }

/* Validation — success */
.field.is-success .input,
.field.is-success .select,
.field.is-success .textarea { border-color: var(--success); }
.field.is-success .help { color: var(--success); }

.help-msg { display: inline-flex; align-items: center; gap: 6px; }
.help-msg .ico { width: 14px; height: 14px; flex: none; }

/* Input group with leading affix (e.g. NMC prefix) */
.input-group { display: flex; }
.input-group .affix {
  display: inline-flex; align-items: center; padding: 0 var(--space-3);
  font-size: var(--text-sm); color: var(--text-secondary);
  background: var(--gray-50); border: 1px solid var(--border-strong);
  border-right: none; border-radius: var(--radius) 0 0 var(--radius);
}
.input-group .input { border-radius: 0 var(--radius) var(--radius) 0; }

/* Checkbox / radio */
.choice { display: inline-flex; align-items: center; gap: var(--space-2);
          font-size: var(--text-base); cursor: pointer; }
.choice input {
  appearance: none; width: 16px; height: 16px; margin: 0; flex: none;
  border: 1px solid var(--border-strong); background: var(--surface);
  cursor: pointer; transition: background-color .12s, border-color .12s;
}
.choice input[type="checkbox"] { border-radius: var(--radius-sm); }
.choice input[type="radio"] { border-radius: 50%; }
.choice input:checked { background: var(--primary); border-color: var(--primary); }
.choice input[type="checkbox"]:checked {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 6.2l2.2 2.3L9.5 3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center;
}
.choice input[type="radio"]:checked {
  box-shadow: inset 0 0 0 3px var(--surface);
}
.choice input:focus-visible { box-shadow: var(--ring); }

/* ==========================================================================
   CARD — the elevated container. One subtle shadow.
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}
.card__header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border);
}
.card__title { font-size: var(--text-md); font-weight: var(--weight-semibold); }
.card__body { padding: var(--space-6); }
.card__footer {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  background: var(--gray-50);
  border-radius: 0 0 var(--radius) var(--radius);
}
/* Flat variant — no shadow, for cards sitting inside other cards or grids */
.card--flat { box-shadow: none; }

/* Stat card — dashboard metric */
.stat { padding: var(--space-6); }
.stat__label { font-size: var(--text-sm); color: var(--text-secondary); font-weight: var(--weight-medium); }
.stat__value { margin-top: var(--space-2); font-size: var(--text-2xl); font-weight: var(--weight-bold);
               line-height: 1; letter-spacing: -0.01em; }
.stat__meta  { margin-top: var(--space-3); font-size: var(--text-sm); display: inline-flex;
               align-items: center; gap: 6px; }
.stat__meta--up   { color: var(--success); }
.stat__meta--down { color: var(--danger); }

/* ==========================================================================
   BADGE / STATUS PILL — rectangular (4px), tinted, never pill-shaped.
   ========================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 var(--space-2);
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  letter-spacing: 0.01em;
  border-radius: var(--radius); border: 1px solid transparent;
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge--neutral { color: var(--gray-600); background: var(--gray-100); border-color: var(--border); }
.badge--primary { color: var(--primary); background: var(--primary-tint); border-color: var(--primary-border); }
.badge--success { color: var(--success); background: var(--success-tint); border-color: var(--success-border); }
.badge--warning { color: var(--warning); background: var(--warning-tint); border-color: var(--warning-border); }
.badge--danger  { color: var(--danger);  background: var(--danger-tint);  border-color: var(--danger-border); }
/* Count badge (nav) */
.badge--count { min-width: 20px; height: 20px; justify-content: center; padding: 0 6px; }

/* ==========================================================================
   ALERT / TOAST — inline banner + floating toast. Left keyline, flat.
   ========================================================================== */
.alert {
  display: flex; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius);
  background: var(--surface);
}
.alert__icon { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.alert__body { flex: 1; min-width: 0; }
.alert__title { font-size: var(--text-base); font-weight: var(--weight-semibold); }
.alert__text { font-size: var(--text-sm); color: var(--text-secondary); margin-top: 2px; }
.alert__close { flex: none; }

.alert--info    { border-left-color: var(--primary); background: var(--primary-tint); border-color: var(--primary-border); }
.alert--info    .alert__icon { color: var(--primary); }
.alert--success { border-left-color: var(--success); background: var(--success-tint); border-color: var(--success-border); }
.alert--success .alert__icon { color: var(--success); }
.alert--warning { border-left-color: var(--warning); background: var(--warning-tint); border-color: var(--warning-border); }
.alert--warning .alert__icon { color: var(--warning); }
.alert--danger  { border-left-color: var(--danger); background: var(--danger-tint); border-color: var(--danger-border); }
.alert--danger  .alert__icon { color: var(--danger); }

/* Toast stack (fixed, floating — allowed the card shadow) */
.toast-stack {
  position: fixed; z-index: 60;
  right: var(--space-6); bottom: var(--space-6);
  display: flex; flex-direction: column; gap: var(--space-3);
  width: min(360px, calc(100vw - var(--space-8)));
}
.toast {
  display: flex; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  animation: toast-in .18s ease-out;
}
.toast--success { border-left-color: var(--success); }
.toast--success .toast__icon { color: var(--success); }
.toast--warning { border-left-color: var(--warning); }
.toast--warning .toast__icon { color: var(--warning); }
.toast--danger  { border-left-color: var(--danger); }
.toast--danger  .toast__icon { color: var(--danger); }
.toast--info .toast__icon { color: var(--primary); }
.toast__icon { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.toast__body { flex: 1; min-width: 0; }
.toast__title { font-size: var(--text-base); font-weight: var(--weight-semibold); }
.toast__text { font-size: var(--text-sm); color: var(--text-secondary); margin-top: 2px; }
.toast.is-leaving { animation: toast-out .16s ease-in forwards; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ==========================================================================
   DATA TABLE — bordered frame, hairline rows, sticky header, zebra optional.
   ========================================================================== */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  background: var(--surface);
}
.table { width: 100%; border-collapse: collapse; font-size: var(--text-base); }
.table thead th {
  position: sticky; top: 0;
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-label); text-transform: uppercase;
  color: var(--text-secondary);
  background: var(--gray-50);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
.table tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--gray-50); }
.table tr.is-selected { background: var(--primary-tint); }
.table--zebra tbody tr:nth-child(even) { background: var(--gray-50); }
.table--zebra tbody tr:hover { background: var(--gray-100); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.table .cell-strong { font-weight: var(--weight-medium); color: var(--text); }
.table .cell-sub { font-size: var(--text-sm); color: var(--text-secondary); }
.table .col-actions { text-align: right; white-space: nowrap; }

/* Table toolbar */
.table-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  flex-wrap: wrap; margin-bottom: var(--space-4);
}
.table-toolbar__filters { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

/* ==========================================================================
   MODAL — scrim + centered sheet with the deeper shadow.
   ========================================================================== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-6);
  background: rgba(20, 26, 35, 0.42);
  animation: fade-in .14s ease;
}
.modal-overlay[hidden] { display: none; }
.modal {
  width: min(520px, 100%);
  max-height: calc(100vh - var(--space-12));
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-modal);
  animation: modal-in .16s ease-out;
}
.modal--wide { width: min(720px, 100%); }
.modal__header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border);
}
.modal__title { font-size: var(--text-lg); font-weight: var(--weight-semibold); }
.modal__subtitle { font-size: var(--text-sm); color: var(--text-secondary); margin-top: 2px; }
.modal__body { padding: var(--space-6); overflow: auto; }
.modal__footer {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
}
@keyframes fade-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   EMPTY STATE
   ========================================================================== */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: var(--space-12) var(--space-6);
  gap: var(--space-2);
}
.empty__glyph {
  display: grid; place-items: center;
  width: 48px; height: 48px; margin-bottom: var(--space-2);
  color: var(--text-muted);
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.empty__glyph .ico { width: 22px; height: 22px; }
.empty__title { font-size: var(--text-md); font-weight: var(--weight-semibold); }
.empty__text { font-size: var(--text-sm); color: var(--text-secondary); max-width: 36ch; }
.empty__actions { margin-top: var(--space-4); display: flex; gap: var(--space-3); }

/* ==========================================================================
   APP SHELL — sidebar nav + topbar. Structure from borders + spacing only.
   ========================================================================== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh;
}
.sidebar__brand {
  display: flex; align-items: center; gap: var(--space-2);
  height: var(--topbar-height); padding: 0 var(--space-4);
  border-bottom: 1px solid var(--border);
  flex: none;
}
.brand-mark {
  display: grid; place-items: center;
  width: 28px; height: 28px; flex: none;
  color: #fff; background: var(--primary);
  border-radius: var(--radius);
  font-weight: var(--weight-bold); font-size: 15px;
}
.brand-name { font-size: var(--text-md); font-weight: var(--weight-bold); letter-spacing: -0.01em; }
.brand-name span { color: var(--text-muted); font-weight: var(--weight-medium); }

.sidebar__nav { flex: 1; overflow-y: auto; padding: var(--space-3) var(--space-2); }

/* Collapsible nav group (the "expanding headers") */
.nav-group { margin-bottom: var(--space-1); }
.nav-group__header {
  display: flex; align-items: center; gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-family: inherit;
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-label); text-transform: uppercase;
  color: var(--text-muted);
  background: none; border: none; cursor: pointer;
  border-radius: var(--radius);
}
.nav-group__header:hover { color: var(--text-secondary); background: var(--gray-50); }
.nav-group__chevron {
  margin-left: auto; width: 14px; height: 14px; flex: none;
  transition: transform .16s ease;
}
.nav-group.is-collapsed .nav-group__chevron { transform: rotate(-90deg); }
.nav-group__items {
  display: grid; grid-template-rows: 1fr;
  transition: grid-template-rows .18s ease;
}
.nav-group.is-collapsed .nav-group__items { grid-template-rows: 0fr; }
.nav-group__items > div { overflow: hidden; }

.nav-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  margin: 1px 0;
  font-size: var(--text-base); font-weight: var(--weight-medium);
  color: var(--text-secondary);
  border-radius: var(--radius);
  cursor: pointer;
}
.nav-item:hover { background: var(--gray-100); color: var(--text); text-decoration: none; }
.nav-item .ico { width: 18px; height: 18px; flex: none; color: var(--text-muted); }
.nav-item .nav-item__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item.is-active {
  color: var(--primary); background: var(--primary-tint); font-weight: var(--weight-semibold);
}
.nav-item.is-active .ico { color: var(--primary); }

.sidebar__footer {
  flex: none; padding: var(--space-3); border-top: 1px solid var(--border);
}
.user-chip {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius); cursor: pointer;
}
.user-chip:hover { background: var(--gray-50); }
.avatar {
  display: grid; place-items: center; flex: none;
  width: 30px; height: 30px;
  font-size: var(--text-sm); font-weight: var(--weight-semibold);
  color: var(--text-secondary); background: var(--gray-100);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.user-chip__meta { min-width: 0; line-height: 1.3; }
.user-chip__name { font-size: var(--text-sm); font-weight: var(--weight-semibold);
                   overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip__role { font-size: var(--text-xs); color: var(--text-muted); }

/* Main column */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: var(--space-4);
  height: var(--topbar-height); padding: 0 var(--space-6);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar__menu { display: none; }
.breadcrumb { display: flex; align-items: center; gap: var(--space-2);
              font-size: var(--text-sm); color: var(--text-secondary); }
.breadcrumb .sep { color: var(--text-muted); }
.breadcrumb .current { color: var(--text); font-weight: var(--weight-medium); }
.topbar__spacer { flex: 1; }
.topbar__search {
  display: flex; align-items: center; gap: var(--space-2);
  width: 260px; height: var(--control-height-sm);
  padding: 0 var(--space-3);
  color: var(--text-muted);
  background: var(--gray-50);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.topbar__search input { border: none; background: none; outline: none; width: 100%;
                        font-family: inherit; font-size: var(--text-sm); color: var(--text); }

.page { padding: var(--space-8) var(--space-6); }
.page__inner { max-width: var(--content-max); margin: 0 auto; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between;
               gap: var(--space-4); margin-bottom: var(--space-8); flex-wrap: wrap; }
.page-title { font-size: var(--text-2xl); font-weight: var(--weight-bold); letter-spacing: -0.005em; }
.page-sub { font-size: var(--text-base); color: var(--text-secondary); margin-top: var(--space-1); }
.page-actions { display: flex; gap: var(--space-3); }

/* ---------- Layout utilities (thin, purposeful) -------------------------- */
.grid { display: grid; gap: var(--space-6); }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.row { display: flex; align-items: center; gap: var(--space-3); }
.row--wrap { flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.stack--sm { gap: var(--space-2); }
.stack--lg { gap: var(--space-8); }
.divider { height: 1px; background: var(--border); border: none; margin: 0; }
.spacer { flex: 1; }

/* ==========================================================================
   RESPONSIVE — reps work on phones. Collapse the shell.
   ========================================================================== */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 40; left: 0; top: 0; width: 280px;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: var(--shadow-modal);
  }
  .app.nav-open .sidebar { transform: none; }
  .scrim {
    position: fixed; inset: 0; z-index: 35; background: rgba(20,26,35,.42);
    opacity: 0; pointer-events: none; transition: opacity .2s ease;
  }
  .app.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .topbar__menu { display: inline-flex; }
  .topbar__search { display: none; }
  .grid--2, .grid--3 { grid-template-columns: 1fr; }
  .page { padding: var(--space-6) var(--space-4); }
}

/* ==========================================================================
   CALENDAR — monthly coverage grid. Days gated by tour-plan approval.
   ========================================================================== */
.cal { border: 1px solid var(--border); border-radius: var(--radius);
       background: var(--surface); box-shadow: var(--shadow-card); overflow: hidden; }
.cal__bar {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.cal__month { font-size: var(--text-lg); font-weight: var(--weight-semibold); min-width: 190px; }
.cal__nav { display: flex; gap: var(--space-1); }
.cal__legend { display: flex; align-items: center; gap: var(--space-4); margin-left: auto; flex-wrap: wrap; }
.cal__legend .lg { display: inline-flex; align-items: center; gap: 6px;
                   font-size: var(--text-xs); color: var(--text-secondary); }
.cal__legend .sw { width: 10px; height: 10px; border-radius: 2px; border: 1px solid transparent; }
.sw--added    { background: var(--success-tint); border-color: var(--success-border); }
.sw--approved { background: var(--primary-tint);  border-color: var(--primary-border); }
.sw--pending  { background: var(--warning-tint);  border-color: var(--warning-border); }

.cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal__dow {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-label); text-transform: uppercase;
  color: var(--text-muted); text-align: left;
  background: var(--gray-50);
  border-bottom: 1px solid var(--border-strong);
  border-right: 1px solid var(--border);
}
.cal__dow:nth-child(7n) { border-right: none; }

.cal__cell {
  display: flex; flex-direction: column; gap: var(--space-2);
  min-height: 108px; padding: var(--space-2) var(--space-3) var(--space-3);
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.cal__cell:nth-child(7n) { border-right: none; }
.cal__cell--muted { background: var(--gray-50); color: var(--text-muted); }
.cal__cell--muted .cal__date { color: var(--text-muted); }
.cal__date { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-secondary); }
.cal__cell--today .cal__date {
  display: inline-grid; place-items: center; width: 24px; height: 24px;
  color: #fff; background: var(--primary); border-radius: var(--radius); margin: -2px 0;
}
/* Approved days are actionable */
.cal__cell--approved { cursor: pointer; }
.cal__cell--approved:hover { background: var(--gray-50); }
.cal__cell--added.cal__cell--approved:hover { background: var(--success-tint); }

.cal-tag {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
  height: 22px; padding: 0 var(--space-2);
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  border-radius: var(--radius); border: 1px solid transparent; white-space: nowrap;
}
.cal-tag .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.cal-tag--added    { color: var(--success); background: var(--success-tint); border-color: var(--success-border); }
.cal-tag--approved { color: var(--primary); background: var(--primary-tint); border-color: var(--primary-border); }
.cal-tag--pending  { color: var(--warning); background: var(--warning-tint); border-color: var(--warning-border); }
.cal__cell .cal-note { font-size: var(--text-xs); color: var(--text-muted); margin-top: auto; }

@media (max-width: 860px) {
  .cal__legend { display: none; }
  .cal__grid { min-width: 640px; }
  .cal-scroll { overflow-x: auto; }
  .cal__month { min-width: 0; font-size: var(--text-md); }
}
