/* ============================================================================
   SAMM Admin — Design System
   ----------------------------------------------------------------------------
   Colour tokens (the --bg / --fg / --primary / ... palette) are NOT defined
   here — they live in themes.css, one block per theme, selected by the
   <html data-theme="..."> attribute. themes.css is linked before app.css so
   every var() below resolves. See themes.css + app/utils/theming.py.

   Direction: this stylesheet is bidirectional. Layout uses CSS logical
   properties (margin-inline-start, inset-inline-end, text-align:start, ...)
   so it mirrors automatically under <html dir="rtl">. The few cases logical
   properties cannot express are handled in the [dir="rtl"] block at the end.
   ============================================================================ */

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Fira Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

code, pre, .mono { font-family: 'Fira Code', 'JetBrains Mono', Consolas, monospace; }

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

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--fg-dim); }

/* ============================================================================
   Layout
   ============================================================================ */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--bg-elev);
  border-inline-end: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
.sidebar__brand {
  padding: 20px 18px 16px;
  display: flex; flex-direction: column; gap: 6px;
  border-bottom: 1px solid var(--border);
}
.sidebar__brand-row {
  display: flex; align-items: center; gap: 10px;
}
.sidebar__brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center; overflow: hidden;
  flex-shrink: 0;
  animation: logo-glow 3.5s ease-in-out infinite;
}
.sidebar__brand-mark img { width: 100%; height: 100%; display: block; border-radius: inherit; }
.sidebar__brand-text {
  font-weight: 800; font-size: 26px; line-height: 32px;
  letter-spacing: -.5px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.sidebar__brand-sub  { font-size: 10.5px; color: var(--fg-dim); line-height: 1.35; max-width: 200px; }
.sidebar__group     { padding: 14px 12px 4px; font-size: 13px; text-transform: uppercase;
                       letter-spacing: .6px; color: var(--fg); font-weight: 700; }
.sidebar__nav { padding: 6px 8px; display: flex; flex-direction: column; gap: 2px; }
.sidebar__link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 8px;
  color: var(--fg-muted); font-size: 13px; font-weight: 500;
  transition: background .15s, color .15s, transform .18s cubic-bezier(.25,.46,.45,.94);
}
.sidebar__link:hover { background: var(--bg-hover); color: var(--fg); text-decoration: none; transform: translateX(3px); }
.sidebar__link.is-active {
  background: linear-gradient(180deg, rgba(59,130,246,.15), rgba(59,130,246,.05));
  color: var(--fg);
  box-shadow: inset 2px 0 0 var(--primary);
}
.sidebar__link svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar__badge {
  margin-inline-start: auto; padding: 1px 7px; border-radius: 999px;
  background: var(--primary); color: #fff; font-size: 10px; font-weight: 600;
}
.sidebar__footer {
  margin-top: auto; padding: 12px;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--fg-dim);
}

.topbar {
  height: 56px; padding: 0 24px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 30;
  backdrop-filter: blur(8px);
}
.topbar__heading { display: flex; align-items: center; gap: 10px; }
.topbar__mark {
  width: 28px; height: 28px; border-radius: 7px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid; place-items: center;
  color: #fff; font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
.topbar__mark svg { width: 15px; height: 15px; }
.topbar__title { font-size: 15px; font-weight: 600; animation: fade-up .25s ease-out both; }
.topbar__crumb { color: var(--fg-dim); font-size: 13px; margin-inline-start: 4px; }
.topbar__spacer { flex: 1; }
.topbar__clock {
  font-family: 'Fira Code', monospace; font-size: 12px;
  color: var(--fg-muted); padding: 4px 10px; border: 1px solid var(--border);
  border-radius: 6px;
}
.topbar__icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 8px; color: var(--fg-muted); cursor: pointer;
  background: transparent; border: 1px solid transparent;
  transition: background .15s;
}
.topbar__icon-btn:hover { background: var(--bg-hover); color: var(--fg); border-color: var(--border); }
.topbar__icon-btn svg { width: 16px; height: 16px; }
/* Compact language / theme pickers in the header (extend .select). */
.topbar__select {
  width: auto; min-width: 0; max-width: 140px;
  height: 34px; padding-block: 0; font-size: 12px;
  color: var(--fg-muted);
}
.topbar__select:hover { color: var(--fg); border-color: var(--border-strong); }
.topbar__user {
  display: flex; align-items: center; gap: 10px;
  padding: 4px; padding-inline-end: 10px; border-radius: 24px;
  border: 1px solid var(--border); cursor: pointer;
}
.topbar__user:hover { background: var(--bg-hover); }
.topbar__user-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 600;
}

.main { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }
.content { padding: 24px; max-width: 1600px; width: 100%; margin: 0 auto; flex: 1; }

/* ============================================================================
   Components
   ============================================================================ */

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  /* As a grid/flex child the default min-width:auto lets a wide table inside
     .table-wrap stretch the card past the viewport; 0 lets it shrink so the
     table scrolls inside .table-wrap instead of overflowing the page. */
  min-width: 0;
}
.card__header {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.card__title { font-size: 14px; font-weight: 600; margin: 0; display: inline-flex; align-items: center; gap: 8px; }
.card__title svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--fg-muted); }
.card__sub { font-size: 12px; color: var(--fg-dim); margin: 0; }
.card__body { padding: 18px; }
.card__footer {
  padding: 12px 18px; border-top: 1px solid var(--border);
  background: var(--surface-2); border-radius: 0 0 12px 12px;
  font-size: 12px; color: var(--fg-muted);
}

/* KPI tile */
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.kpi__label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--fg-dim); margin-bottom: 8px;
}
.kpi__value {
  font-size: 28px; font-weight: 600;
  font-family: 'Fira Code', monospace;
  letter-spacing: -.5px;
  line-height: 1;
}
.kpi__delta { font-size: 11px; color: var(--fg-muted); margin-top: 6px; }
.kpi__delta--up   { color: var(--accent); }
.kpi__delta--down { color: var(--danger); }
.kpi__icon {
  position: absolute; top: 14px; inset-inline-end: 14px;
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center; color: var(--fg-muted);
  background: var(--bg-elev-2);
}
.kpi__icon svg { width: 16px; height: 16px; }
.kpi--primary .kpi__icon  { color: var(--primary); }
.kpi--accent  .kpi__icon  { color: var(--accent); }
.kpi--warn    .kpi__icon  { color: var(--warn); }
.kpi--danger  .kpi__icon  { color: var(--danger); }
.kpi--info    .kpi__icon  { color: var(--info); }
a.kpi,
a.kpi:link,
a.kpi:visited,
a.kpi:hover,
a.kpi:active,
a.kpi:focus {
  text-decoration: none;
  color: var(--fg);
  display: block;
  cursor: pointer;
  transition: border-color .15s ease, transform .1s ease, box-shadow .15s ease;
}
a.kpi:hover {
  border-color: var(--primary);
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 10px 30px rgba(0,0,0,.2), 0 0 0 1px var(--primary);
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 500; line-height: 1.4;
  min-height: 36px;
  border: 1px solid var(--border);
  background: var(--surface); color: var(--fg);
  cursor: pointer;
  box-sizing: border-box;
  position: relative; overflow: hidden;
  transition: background .15s, border-color .15s, transform .08s, box-shadow .15s;
  text-decoration: none; white-space: nowrap;
  vertical-align: middle;
}
.btn::after {
  content: ''; pointer-events: none;
  position: absolute; inset: 0; border-radius: inherit;
  background: rgba(255,255,255,.22);
  opacity: 0; transition: opacity .2s;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:active::after { opacity: 1; transition: none; }
.btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; }

.btn--primary { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.btn--primary:hover { background: var(--primary-hov); border-color: var(--primary-hov); color: #fff; }
.btn--accent  { background: var(--accent);  color: #fff; border-color: var(--accent); }
.btn--accent:hover  { background: var(--accent-hov);  border-color: var(--accent-hov); }
.btn--danger  { background: transparent;  color: var(--danger); border-color: var(--danger); }
.btn--danger:hover  { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn--info  { background: #4ade80; color: #14532d; border-color: #4ade80; }
.btn--info:hover  { background: #22c55e; border-color: #22c55e; color: #fff; }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--bg-hover); border-color: var(--border); }
.btn--sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; min-height: 30px; }
.btn--xs { padding: 3px 8px; font-size: 11px; border-radius: 5px; min-height: 24px; }
.btn--icon { width: 32px; height: 32px; padding: 0; }
.btn-group { display: inline-flex; gap: 0; }
.btn-group form { display: contents; }
.btn-group .btn { border-radius: 0; border-right-width: 0; }
.btn-group .btn:first-child { border-radius: 8px 0 0 8px; }
.btn-group .btn:last-child  { border-radius: 0 8px 8px 0; border-right-width: 1px; }
.btn-group .btn.is-active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Inputs */
.field { display: block; margin-bottom: 14px; }
.field__label {
  display: block; font-size: 12px; font-weight: 500;
  color: var(--fg-muted); margin-bottom: 6px;
}
.field__hint { font-size: 11px; color: var(--fg-dim); margin-top: 4px; }
.field__error { font-size: 11px; color: var(--danger); margin-top: 4px; }
.input, .select, .textarea {
  width: 100%; padding: 8px 12px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  font-family: inherit; font-size: 13px;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring);
}
.input::placeholder { color: var(--fg-dim); }
.input--mono { font-family: 'Fira Code', monospace; }
/* number inputs without the up/down spinner */
.input--no-spin::-webkit-inner-spin-button,
.input--no-spin::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.input--no-spin { -moz-appearance: textfield; appearance: textfield; }
.select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239aa3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  padding-inline-end: 30px;
}
.textarea { resize: vertical; min-height: 80px; }

.checkbox-row { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.checkbox-row input { accent-color: var(--primary); width: 16px; height: 16px; }

/* Switch */
.switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch__track {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border-strong); border-radius: 999px;
  transition: background .15s;
}
.switch__track::before {
  content: ""; position: absolute; inset-inline-start: 2px; top: 2px;
  width: 16px; height: 16px; background: #fff; border-radius: 50%;
  transition: transform .15s;
}
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::before { transform: translateX(16px); }
.switch--lg { width: 46px; height: 26px; }
.switch--lg .switch__track::before { width: 20px; height: 20px; }
.switch--lg input:checked + .switch__track::before { transform: translateX(20px); }

/* Toggle rows (label + switch) */
.toggle-row { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; font-size: 14px; user-select: none; }
.toggle-section { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }

/* Form rows */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row--3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 640px) { .form-row, .form-row--3 { grid-template-columns: 1fr; } }

/* Toggle chips — multi-select pills, a friendlier replacement for a row of
   raw checkboxes. Markup: <label class="chip"><input class="chip__cb"
   type="checkbox" ...><span class="chip__dot"></span>label</label> */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  --chip-accent: var(--primary);
  position: relative;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px;
  font-size: 12.5px; font-weight: 500; line-height: 1;
  color: var(--fg-muted);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer; user-select: none;
  transition: background .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: var(--border-strong); color: var(--fg); }
.chip__cb {  /* visually hidden, still focusable for keyboard users */
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  opacity: 0; pointer-events: none;
}
.chip__dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  background: var(--border-strong);
  transition: background .15s, box-shadow .15s;
}
.chip:has(.chip__cb:checked) {
  background: color-mix(in srgb, var(--chip-accent) 15%, var(--surface));
  border-color: var(--chip-accent);
  color: var(--fg);
}
.chip:has(.chip__cb:checked) .chip__dot {
  background: var(--chip-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--chip-accent) 28%, transparent);
}
.chip:has(.chip__cb:focus-visible) {
  border-color: var(--chip-accent);
  box-shadow: 0 0 0 3px var(--ring);
}

/* Sectioned form — groups related fields under a quiet uppercase heading. */
.form-section { margin-bottom: 20px; }
.form-section:last-of-type { margin-bottom: 0; }
.form-section__title {
  font-size: 11px; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--fg-dim);
  margin: 0 0 12px; padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
}
.form-grid {
  display: grid; gap: 12px 14px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.form-grid .field { margin-bottom: 0; }
.form-grid__full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

/* Tables */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
.table th {
  text-align: start; padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 11px; text-transform: uppercase;
  letter-spacing: .6px; color: var(--fg-muted);
  position: sticky; top: 0;
}
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
}
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-bottom: none; }
.table--compact td { padding: 8px 14px; }
.table--mono td { font-family: 'Fira Code', monospace; font-size: 12px; }
.table .num { text-align: end; font-variant-numeric: tabular-nums; font-family: 'Fira Code', monospace; }
.table .actions { text-align: end; white-space: nowrap; }
.table__empty { padding: 36px; text-align: center; color: var(--fg-dim); }

/* Badges & pills */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 500; line-height: 1.5;
  background: var(--bg-elev-2); color: var(--fg-muted);
  border: 1px solid var(--border);
}
.badge--dot::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; display: inline-block;
}
.badge--accent  { color: var(--accent);  background: rgba(16,185,129,.10); border-color: rgba(16,185,129,.25); }
.badge--primary { color: var(--primary); background: rgba(59,130,246,.10); border-color: rgba(59,130,246,.25); }
.badge--warn    { color: var(--warn);    background: rgba(245,158,11,.10); border-color: rgba(245,158,11,.25); }
.badge--danger  { color: var(--danger);  background: rgba(239,68,68,.10);  border-color: rgba(239,68,68,.25); }
.badge--info    { color: var(--info);    background: rgba(6,182,212,.10);  border-color: rgba(6,182,212,.25); }
.badge--muted   { color: var(--fg-dim); }
.badge--rect    { border-radius: 4px; padding: 3px 8px; }

/* Current → Active plan pair (rendered in users.html when a next_plan swap is in effect). */
.plan-swap { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.plan-swap__arrow {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; color: var(--fg-dim); opacity: 0.7;
}
.plan-swap__arrow svg { width: 14px; height: 14px; stroke: currentColor;
  fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--fg-dim); margin-inline-end: 6px;
}
.dot--ok   { background: var(--accent); box-shadow: 0 0 0 3px rgba(16,185,129,.18); }
.dot--warn { background: var(--warn);   box-shadow: 0 0 0 3px rgba(245,158,11,.18); }
.dot--err  { background: var(--danger); box-shadow: 0 0 0 3px rgba(239,68,68,.18); }
.dot--live { background: var(--accent); animation: pulse 1.6s infinite; }
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(16,185,129,.6); }
  50%     { box-shadow: 0 0 0 6px rgba(16,185,129,0); }
}

/* Toolbar (above tables) */
.toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 12px 18px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.toolbar__search {
  position: relative; flex: 1; min-width: 200px; max-width: 360px;
}
.toolbar__search svg {
  position: absolute; inset-inline-start: 10px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--fg-dim);
}
.toolbar__search input { padding-inline-start: 32px; }
.toolbar__spacer { flex: 1; }

/* Pagination */
.pagination {
  display: flex; gap: 4px; align-items: center; justify-content: center;
  padding: 14px;
}
.pagination .page-link {
  min-width: 32px; height: 32px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 6px;
  color: var(--fg-muted); font-size: 12px;
  background: var(--surface); cursor: pointer;
}
.pagination .page-link:hover { background: var(--bg-hover); color: var(--fg); text-decoration: none; }
.pagination .page-link.is-active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .page-link.is-disabled { opacity: .4; pointer-events: none; }

/* Tabs */
.tabs {
  display: flex; gap: 0; padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  overflow-x: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;           /* Firefox */
}
.tabs::-webkit-scrollbar { display: none; } /* Chrome/Safari */
.tab {
  /* Unified 44 px height for consistent touch targets on all platforms */
  padding: 0 14px; height: 44px; flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 500;
  color: var(--fg-muted); border-bottom: 2px solid transparent;
  cursor: pointer; transition: color .15s, background .15s, border-color .15s;
  white-space: nowrap; text-decoration: none; border-radius: 0;
}
.tab:hover { color: var(--fg); background: var(--bg-hover); text-decoration: none; }
.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }
/* <button class="tab"> — reset native chrome so it matches <a class="tab"> */
button.tab {
  background: none; border: 0; border-bottom: 2px solid transparent;
  font-family: inherit; color: var(--fg-muted);
}
button.tab:hover { background: var(--bg-hover); }
button.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }
.tab svg { width: 14px; height: 14px; flex-shrink: 0; }

/* ---- Tab scroll wrapper — injected by enhanceTabs() in app.js ----
   Hosts the bottom border, gradient-fade edge indicators, and arrow buttons.
   Keeps the template markup clean: no changes needed in individual pages. */
.tabs-wrap {
  position: relative;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
/* The wrapper now owns the bottom border; remove it from the inner .tabs. */
.tabs-wrap > .tabs { border-bottom: none; padding-inline: 0; }
/* Gradient edge fades — hint that more tabs exist off-screen. */
.tabs-wrap::before,
.tabs-wrap::after {
  content: '';
  position: absolute; top: 0; bottom: 0; width: 48px;
  pointer-events: none; z-index: 4;
  opacity: 0; transition: opacity .2s;
}
.tabs-wrap::before {
  left: 0;
  background: linear-gradient(to right, var(--surface) 30%, transparent);
}
.tabs-wrap::after {
  right: 0;
  background: linear-gradient(to left, var(--surface) 30%, transparent);
}
.tabs-wrap.has-fade-left::before  { opacity: 1; }
.tabs-wrap.has-fade-right::after  { opacity: 1; }
/* Scroll arrow buttons (only on pointer/mouse devices). */
.tabs-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 5;
  width: 36px; height: 36px; padding: 0; border-radius: 8px;
  background: var(--surface); color: var(--fg);
  border: 1px solid var(--border-strong);
  cursor: pointer; box-shadow: var(--shadow);
  display: none; place-items: center;
  transition: background .15s, color .15s, box-shadow .15s, transform .1s;
}
.tabs-arrow.is-visible { display: grid; }
.tabs-arrow:hover {
  background: var(--primary); color: #fff;
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-50%) scale(1.08);
}
.tabs-arrow:active { transform: translateY(-50%) scale(0.96); }
.tabs-arrow svg { width: 16px; height: 16px; pointer-events: none; }
.tabs-arrow--left  { left:  6px; }
.tabs-arrow--right { right: 6px; }
/* On touch-only devices users swipe naturally — no arrows needed. */
@media (hover: none) { .tabs-arrow { display: none !important; } }

/* Sub-tabs - nested under .tabs (e.g. Hotspot Servers > Server / Login Page) */
.subtabs {
  display: flex; gap: 4px; padding: 8px 12px 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  margin-bottom: 14px;
  overflow-x: auto;
}
.subtab {
  padding: 7px 14px; font-size: 12px; font-weight: 500;
  color: var(--fg-muted);
  background: transparent;
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  border-radius: 6px 6px 0 0;
  cursor: pointer; transition: color .15s, background .15s, border-color .15s;
  white-space: nowrap; text-decoration: none;
}
.subtab:hover { color: var(--fg); background: var(--bg-hover); text-decoration: none; }
.subtab.is-active {
  color: var(--primary);
  border-color: var(--border);
  border-bottom-color: transparent;
  background: var(--surface);
}

/* Hotspot design gallery */
.design-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.design-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color .15s, transform .05s;
}
.design-card:hover { border-color: var(--primary); }
.design-card__thumb {
  aspect-ratio: 4 / 3;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.design-card__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.design-card__thumb svg { width: 60%; height: 60%; opacity: .35; }
.design-card__body { padding: 12px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.design-card__title { font-weight: 600; font-size: 14px; color: var(--fg); }
.design-card__desc { font-size: 12px; color: var(--fg-muted); line-height: 1.4; }
.design-card__footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex; gap: 6px; justify-content: flex-end;
  flex-wrap: wrap;
}
.design-card__active-badge {
  background: rgba(16,185,129,.15);
  color: rgb(16,185,129);
  border: 1px solid rgba(16,185,129,.4);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Color swatch input wrapper */
.swatch-row { display: flex; gap: 10px; align-items: center; padding: 6px 0; }
.swatch-row label { min-width: 110px; font-size: 12px; color: var(--fg-muted); text-transform: capitalize; }
.swatch-row input[type=color] { width: 42px; height: 32px; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; padding: 0; background: transparent; }
.swatch-row input[type=text] { flex: 1; font-family: 'Fira Code', monospace; font-size: 12px; }

/* Hotspot editor: page switcher above the live preview */
.preview-pages { display: flex; flex-wrap: wrap; margin-bottom: 12px; }

/* Hotspot editor: prev / next template browser */
.tpl-nav { display: flex; align-items: center; gap: 8px; }
.tpl-nav__count { font-size: 12px; color: var(--fg-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tpl-nav .btn {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}
.tpl-nav .btn:hover {
  background: #bbf7d0;
  color: #14532d;
  border-color: #4ade80;
}

/* Editor live preview iframe */
.design-editor-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 18px;
}
@media (max-width: 768px) {
  .design-editor-grid { grid-template-columns: 1fr; }
  .design-editor-grid > :first-child { order: 2; }
  .design-editor-grid > :last-child  { order: 1; }
}

.design-preview-frame {
  width: 100%;
  height: 70vh;
  min-height: 480px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
@media (max-width: 768px) {
  .design-preview-frame { min-height: 320px; height: 55vh; }
}

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(2,6,23,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
  backdrop-filter: blur(2px);
  /* Fade instead of snap — use visibility+opacity so the transition fires */
  visibility: hidden; opacity: 0; pointer-events: none;
  transition: opacity .22s ease, visibility 0s .22s;
}
.modal-backdrop.is-open {
  visibility: visible; opacity: 1; pointer-events: auto;
  transition: opacity .22s ease;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px;
  max-height: calc(100vh - 40px); overflow-y: auto;
  animation: pop .15s ease-out;
}
.modal--lg { max-width: 800px; }
.modal--xl { max-width: 1100px; }
.modal__header {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.modal__title { font-weight: 600; font-size: 15px; flex: 1; }
.modal__body { padding: 18px; }
.modal__footer {
  padding: 12px 18px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
  background: var(--surface-2); border-radius: 0 0 14px 14px;
}
.modal__close {
  width: 32px; height: 32px; border-radius: 7px; flex-shrink: 0;
  display: grid; place-items: center; cursor: pointer;
  color: #fff; background: #dc2626; border: none;
}
.modal__close svg { width: 16px; height: 16px; }
.modal__close:hover { background: #b91c1c; color: #fff; }
@keyframes pop { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Confirmation dialog — styled replacement for the native confirm() box.
   Built lazily by app.js (window.confirmDialog) and reused on both portals. */
.confirm-dialog { z-index: 300; }
.modal--confirm { max-width: 440px; }
.confirm-dialog__main {
  display: flex; gap: 14px;
  padding: 22px 22px 20px;
}
.confirm-dialog__icon {
  flex-shrink: 0;
  width: 44px; height: 44px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(239, 68, 68, .14);
  color: var(--danger);
}
.confirm-dialog__icon svg { width: 24px; height: 24px; }
.confirm-dialog.confirm-dialog--primary .confirm-dialog__icon {
  background: rgba(59, 130, 246, .14);
  color: var(--primary);
}
.confirm-dialog__content { flex: 1; min-width: 0; padding-top: 1px; }
.confirm-dialog__title {
  font-weight: 600; font-size: 15px;
  color: var(--fg);
  margin-bottom: 5px;
}
.confirm-dialog__message {
  font-size: 13px; line-height: 1.55;
  color: var(--fg-muted);
  white-space: pre-line;
  word-break: break-word;
}
.confirm-dialog .modal__footer .btn {
  min-width: 92px;
  justify-content: center;
  text-align: center;
}
.confirm-dialog .btn:disabled,
.confirm-dialog .btn[disabled] { opacity: .45; cursor: not-allowed; }
/* "type X to confirm" gate */
.confirm-dialog__field { margin-top: 13px; }
.confirm-dialog__field-label {
  display: block;
  font-size: 12px;
  color: var(--fg-muted);
  margin-bottom: 5px;
}
.confirm-dialog__field .input { width: 100%; }

/* Toast */
.toasts {
  position: fixed; top: 70px; inset-inline-end: 24px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  max-width: 360px;
}
.toast {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: flex-start; gap: 10px;
  animation: slide-in .25s ease-out;
}
@keyframes slide-in { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* Reusable spinner — circle with one colored arc that rotates.
   Default size is 32px; override via inline style for smaller variants
   (e.g. inline status indicators). */
.samm-spinner {
  display:inline-block; width:32px; height:32px;
  border:3px solid var(--border);
  border-top-color: var(--primary);
  border-radius:50%;
  animation: spin .8s linear infinite;
  vertical-align:middle;
}

/* Full-viewport loading overlay. Hidden by default; pages add `.is-visible`
   to fade it in (typically right before a form-driven page navigation). */
.samm-loading-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  gap: 14px;
  z-index: 9999;
  opacity: 0; pointer-events: none;
  transition: opacity .15s ease-in;
}
.samm-loading-overlay.is-visible { opacity: 1; pointer-events: auto; }
.samm-loading-overlay__label {
  color: #fff; font-size: 14px; font-weight: 500;
  text-shadow: 0 1px 2px rgba(0,0,0,.45);
}
.toast--success { border-inline-start: 3px solid var(--accent); }
.toast--error   { border-inline-start: 3px solid var(--danger); }
.toast--warn    { border-inline-start: 3px solid var(--warn); }
.toast--info    { border-inline-start: 3px solid var(--info); }
.toast__title { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.toast__msg { font-size: 12px; color: var(--fg-muted); }

/* Detail / page header */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; flex-wrap: wrap; gap: 12px;
}
.page-header__title { font-size: 20px; font-weight: 600; margin: 0 0 4px; }
.page-header__sub { font-size: 13px; color: var(--fg-muted); margin: 0; }
.page-header__actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Reports page filter bar */
.reports-filter { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.reports-filter__date { width: 138px; }
.reports-filter__sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; flex-shrink: 0; }

/* Stat row */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-row--6 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* Description list (key/value) */
.dl {
  display: grid; grid-template-columns: max-content 1fr; gap: 10px 18px;
  font-size: 13px;
}
.dl dt { color: var(--fg-dim); font-size: 12px; }
.dl dd { margin: 0; color: var(--fg); }

/* Progress bar */
.progress {
  height: 6px; background: var(--bg-elev-2); border-radius: 999px; overflow: hidden;
}
.progress__bar {
  height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .3s ease;
}
.progress__bar--warn   { background: var(--warn); }
.progress__bar--danger { background: var(--danger); }

/* Code block / pre */
.code-block {
  background: var(--bg-elev-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px;
  font-family: 'Fira Code', monospace; font-size: 12px;
  white-space: pre-wrap; word-break: break-all;
  color: var(--fg-muted);
}

/* Alert */
.alert {
  padding: 12px 14px; border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13px; display: flex; gap: 10px; align-items: flex-start;
  margin-bottom: 14px;
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }
.alert--info    { background: rgba(6,182,212,.06);  border-color: rgba(6,182,212,.25);  color: var(--info); }
.alert--warn    { background: rgba(245,158,11,.06); border-color: rgba(245,158,11,.25); color: var(--warn); }
.alert--danger  { background: rgba(239,68,68,.06);  border-color: rgba(239,68,68,.25);  color: var(--danger); }
.alert--success { background: rgba(16,185,129,.06); border-color: rgba(16,185,129,.25); color: var(--accent); }

/* Login page */
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1000px 400px at 70% 10%, rgba(59,130,246,.10), transparent 60%),
    radial-gradient(800px 400px at 20% 90%, rgba(16,185,129,.08), transparent 60%),
    var(--bg);
}
.auth__card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px; padding: 28px;
  box-shadow: var(--shadow-lg);
}
.auth__brand {
  display: flex; align-items: center; gap: 12px; margin-bottom: 18px;
}
.auth__brand-mark {
  width: 44px; height: 44px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 20px;
  box-shadow: 0 0 24px rgba(59,130,246,.4);
}
.auth__title { font-size: 20px; font-weight: 600; margin: 0; }
.auth__sub { font-size: 12px; color: var(--fg-muted); margin: 0; }
.auth__divider {
  height: 1px; background: var(--border); margin: 18px 0 14px;
}

/* Charts hosting */
.chart-wrap { position: relative; width: 100%; }
.chart-wrap canvas { max-width: 100%; }

/* Utility */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 12px; }
.text-md { font-size: 13px; }
.text-lg { font-size: 16px; }
.text-muted { color: var(--fg-muted); }
.text-dim { color: var(--fg-dim); }
.text-mono { font-family: 'Fira Code', monospace; }
.text-right { text-align: end; }
.text-center { text-align: center; }
.text-bold { font-weight: 600; }
.full-width { width: 100%; }
.hidden { display: none !important; }

/* Context menu (right-click & three-dots on tables) */
.ctx-menu {
  position: fixed;
  z-index: 250;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  font-size: 13px;
  display: none;
  animation: pop .12s ease-out;
}
.ctx-menu.is-open { display: block; }
.ctx-menu__item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 6px;
  color: var(--fg); cursor: pointer; user-select: none;
  background: transparent; border: 0; width: 100%; text-align: start;
  font-size: 13px;
}
.ctx-menu__item:hover { background: var(--bg-hover); }
.ctx-menu__item svg { width: 14px; height: 14px; color: var(--fg-muted); flex-shrink: 0; }
.ctx-menu__item--danger { color: var(--danger); }
.ctx-menu__item--danger svg { color: var(--danger); }
.ctx-menu__sep { height: 1px; background: var(--border); margin: 6px 4px; }
.ctx-menu__label {
  padding: 7px 12px 3px;
  font-size: 10px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--fg-dim);
}

.row-link { cursor: pointer; }
.row-link td { transition: background .1s; }
.row-link.is-target td { background: var(--bg-hover); }
.btn-icon-dots {
  width: 28px; height: 28px; padding: 0;
  border-radius: 6px; border: 1px solid transparent;
  background: transparent; color: var(--fg-muted);
  display: inline-grid; place-items: center; cursor: pointer;
}
.btn-icon-dots:hover { background: var(--bg-hover); color: var(--fg); border-color: var(--border); }
.btn-icon-dots svg { width: 14px; height: 14px; }

.grid { display: grid; }
.grid-2 { grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); gap: 14px; }
/* Main-content + narrow side-panel (e.g. user detail, settings). Collapses to
   a single column on small screens so the side panel stacks below the content. */
.grid-aside { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
/* Value input + unit selector (e.g. "5 | GB"). Stays 2-column at all sizes —
   both fields are narrow enough even on 320 px phones. */
.grid-value-unit { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; }
/* 4-column quota row: [down val][down unit][up val][up unit].
   Reflows to 2×2 on small screens so each pair stays on its own line. */
.grid-quota-pair { display: grid; grid-template-columns: 2fr 1fr 2fr 1fr; gap: 8px; }
@media (max-width: 560px) { .grid-quota-pair { grid-template-columns: 1fr 1fr; } }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
/* !important so the single-column collapse also wins over per-row inline
   `style="grid-template-columns: ..."` overrides (e.g. the dashboard grids),
   which otherwise force multi-column layout and overflow narrow screens. */
@media (max-width: 700px)  { .grid-3, .grid-2, .grid-aside { grid-template-columns: 1fr !important; } }

/* Responsive sidebar */
.sidebar-toggle {
  display: none; width: 34px; height: 34px;
  border-radius: 8px; background: transparent; border: 1px solid var(--border);
  color: var(--fg-muted); cursor: pointer; place-items: center;
}
.sidebar-toggle svg { width: 16px; height: 16px; }

/* Backdrop behind the mobile drawer — tapping it closes the sidebar. */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0; z-index: 59;
  background: rgba(2, 6, 23, 0.45);
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);
}
.sidebar-backdrop.is-open { display: block; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 60;
    width: 240px; transform: translateX(-100%);
    transition: transform .2s ease;
  }
  .sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-toggle { display: grid; width: 40px; height: 40px; }
  .topbar__title { font-size: 14px; }
  .content { padding: 16px; }
  /* Hide server clock — too wide on mobile */
  .topbar__clock { display: none; }
  /* Larger touch targets for topbar controls */
  .topbar__icon-btn { width: 40px; height: 40px; }
  /* Minimum touch-friendly button height (44px is ideal; 40px is acceptable for
     secondary/dense UI where space is constrained) */
  .btn { min-height: 40px; }
  .btn--sm { min-height: 34px; }
  .btn--xs { min-height: 28px; }
  /* 44px minimum height + 16px font for text inputs to prevent iOS auto-zoom
     when the field is focused. */
  .input, .select, .textarea { min-height: 44px; font-size: 16px; }
  /* Pagination links: taller touch area */
  .pagination .page-link { min-width: 40px; height: 40px; }
  /* Three-dots menu button: bigger touch area */
  .btn-icon-dots { width: 36px; height: 36px; }
  /* Help-tip icon: slightly larger on mobile */
  .help-tip { width: 20px; height: 20px; font-size: 12px; }
}

/* Extra-small screens: collapse topbar to essentials only */
@media (max-width: 560px) {
  /* Language/theme quick-switch hidden — accessible via Profile page */
  .topbar__select { display: none; }
  /* Show avatar only; hide username text to conserve space */
  .topbar__user .text-sm { display: none; }
  .topbar__user { padding-inline-end: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ============================================================================
   Support tickets — customer + admin portals (tickets.html / ticket_detail.html)
   ============================================================================ */

/* "Reply needed" status colour. */
.badge--violet { color: var(--violet); background: rgba(139,92,246,.12); border-color: rgba(139,92,246,.32); }

/* Admin list — status filter chips with live counts. */
.tk-filterbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 14px 14px 0; }
.tk-count {
  display: inline-block; min-width: 17px; padding: 0 5px; margin-left: 3px;
  border-radius: 999px; background: rgba(127,127,127,.22);
  font-size: 10px; font-weight: 600; text-align: center;
}

/* Ticket description block, shown under the meta on both detail pages. */
.tk-desc {
  margin-top: 12px; padding: 12px 14px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
}

/* Conversation / follow-up thread. */
.tk-thread { display: flex; flex-direction: column; }
.tk-event {
  text-align: center; font-size: 11.5px; color: var(--fg-dim);
  margin: 8px 0; padding: 0 12px;
}
.tk-msg {
  border: 1px solid var(--border); border-inline-start-width: 3px; border-radius: 10px;
  padding: 11px 14px; margin-bottom: 10px; background: var(--surface);
}
.tk-msg--customer { border-inline-start-color: var(--primary); }
.tk-msg--admin    { border-inline-start-color: var(--accent); }
.tk-msg--internal { border-inline-start-color: var(--warn); background: rgba(245,158,11,.06); }
.tk-msg__head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 12px; }
.tk-msg__who { font-weight: 600; }
.tk-msg__time { margin-inline-start: auto; color: var(--fg-dim); font-size: 11px; white-space: nowrap; }
.tk-msg__body {
  font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
}

/* Customer "reply needed" call-to-action banner. */
.tk-reply-cta {
  margin-top: 14px; padding: 12px 14px; border-radius: 10px;
  background: rgba(139,92,246,.10); border: 1px solid rgba(139,92,246,.32);
  color: var(--violet); font-size: 13px; line-height: 1.55;
}

/* Priority picker (customer new-ticket modal) + visibility picker (admin note).
   Native radios are visually hidden; the label is the control. */
.tk-prio-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.tk-vis-pick { display: flex; flex-direction: column; gap: 8px; }
.tk-prio, .tk-vis {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; font-size: 13px; user-select: none;
}
.tk-vis { width: 100%; }
.tk-prio input, .tk-vis input { position: absolute; opacity: 0; width: 0; height: 0; }
.tk-prio__dot, .tk-vis__dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: var(--fg-dim);
}
.tk-prio--normal   .tk-prio__dot { background: var(--accent); }
.tk-prio--moderate .tk-prio__dot { background: var(--warn); }
.tk-prio--critical .tk-prio__dot { background: var(--danger); }
.tk-vis--public   .tk-vis__dot { background: var(--accent); }
.tk-vis--internal .tk-vis__dot { background: var(--warn); }
.tk-prio:has(input:checked), .tk-vis:has(input:checked) {
  border-color: var(--border-strong); background: var(--bg-hover);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
.tk-prio:has(input:focus-visible), .tk-vis:has(input:focus-visible) {
  outline: 2px solid var(--ring); outline-offset: 2px;
}

/* ============================================================================
   Help tips — a small blue "?" icon that opens a short popover explaining a
   non-obvious feature or control. Keeps the UI uncluttered: the help is one
   click away instead of sitting on the page. First used in the MikroTik tabs;
   now shared app-wide so every page uses the same affordance.

   Markup (the "?" glyph + a11y attributes are filled in by app.js):
     <span class="help-tip" data-help="Short explanation. \n New line."></span>
   A <button class="help-tip" ...>?</button> (the tip() macro) behaves the same.
   A literal "\n" in data-help renders as a line break.
   ============================================================================ */
.help-tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; padding: 0; margin: 0; margin-inline-start: 6px;
  background: rgba(59,130,246,.15);
  border: 1px solid rgba(59,130,246,.55);
  color: rgb(96,165,250);
  border-radius: 50%;
  font-size: 11px; font-weight: 700; line-height: 1;
  font-family: inherit;
  cursor: pointer; vertical-align: -2px;
  flex-shrink: 0;
}
.help-tip:hover { background: rgba(59,130,246,.30); }
.help-tip:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
/* In an uppercase table header / quiet label the glyph must stay upright. */
th .help-tip,
.form-section__title .help-tip { text-transform: none; letter-spacing: normal; }

/* The popover — one element created by app.js, anchored under the icon. */
.help-pop {
  position: absolute; z-index: 2000;
  max-width: 320px;
  padding: 10px 12px;
  background: var(--bg-elev-2);
  color: var(--fg);
  border: 1px solid rgba(59,130,246,.45);
  border-radius: 8px;
  font-size: 13px; font-weight: 400; line-height: 1.5;
  letter-spacing: normal; text-transform: none;
  white-space: pre-line;
  box-shadow: var(--shadow-lg);
  animation: fade-up .14s ease-out;
}
.help-pop::before {
  content: ""; position: absolute; top: -7px; inset-inline-start: 14px;
  width: 12px; height: 12px; background: inherit;
  border-left: 1px solid rgba(59,130,246,.45);
  border-top:  1px solid rgba(59,130,246,.45);
  transform: rotate(45deg);
}

/* ============================================================================
   Footer
   ============================================================================ */
.samm-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  padding: 18px 24px;
  flex-shrink: 0;
  animation: fade-up .3s ease-out both;
  animation-delay: 220ms;
}
.samm-footer__inner {
  max-width: 1600px; margin: 0 auto;
  display: flex; align-items: center; gap: 16px;
  flex-wrap: wrap;
}

/* Brand block */
.samm-footer__brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: inherit;
  opacity: .9; transition: opacity .15s;
}
.samm-footer__brand:hover { opacity: 1; text-decoration: none; }
.samm-footer__brand:hover .samm-footer__brand-mark { box-shadow: 0 0 22px rgba(59,130,246,.55); }
.samm-footer__brand-mark {
  width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
  display: grid; place-items: center; overflow: hidden;
  box-shadow: 0 0 18px rgba(59,130,246,.35);
}
.samm-footer__brand-mark img { width: 100%; height: 100%; display: block; border-radius: inherit; }
.samm-footer__brand-info { display: flex; align-items: baseline; gap: 5px; }
.samm-footer__brand-name {
  font-weight: 800; font-size: 14px; letter-spacing: -.3px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.samm-footer__brand-by { font-size: 11px; color: var(--fg-dim); }

/* Copyright */
.samm-footer__copy {
  flex: 1; font-size: 11.5px; color: var(--fg-dim);
  margin: 0; text-align: center;
}

/* Claude attribution badge */
.samm-footer__claude {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px 7px 10px; border-radius: 24px;
  background: linear-gradient(135deg,
    rgba(201,93,45,.13) 0%, rgba(232,143,60,.07) 100%);
  border: 1px solid rgba(201,93,45,.28);
  text-decoration: none;
  font-size: 12px; color: var(--fg-muted);
  transition: background .2s, border-color .2s, transform .15s, box-shadow .2s;
  white-space: nowrap; flex-shrink: 0;
}
.samm-footer__claude:hover {
  background: linear-gradient(135deg,
    rgba(201,93,45,.24) 0%, rgba(232,143,60,.14) 100%);
  border-color: rgba(201,93,45,.55);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(201,93,45,.22);
  text-decoration: none; color: var(--fg-muted);
}
.samm-footer__claude-spark {
  display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, rgba(201,93,45,.2), rgba(232,143,60,.15));
  color: #C95D2D;
  transition: transform .2s;
}
.samm-footer__claude:hover .samm-footer__claude-spark {
  transform: rotate(30deg) scale(1.15);
}
.samm-footer__claude-spark svg { width: 13px; height: 13px; }
.samm-footer__claude-text strong {
  color: #C95D2D; font-weight: 700; margin-inline: 3px;
}
.samm-footer__claude-sub { color: var(--fg-dim); }

@media (max-width: 640px) {
  .samm-footer { padding: 16px; }
  .samm-footer__inner {
    flex-direction: column; align-items: center;
    text-align: center; gap: 10px;
  }
  .samm-footer__copy { flex: none; }
}

/* ============================================================================
   Motion & Entrance animations
   ============================================================================ */

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes row-in {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes logo-glow {
  0%, 100% { box-shadow: 0 0 18px rgba(59,130,246,.35); }
  50%       { box-shadow: 0 0 32px rgba(59,130,246,.65); }
}

/* Page content — each top-level section in .content fades + slides up */
.content > * {
  animation: fade-up .3s ease-out both;
}
.content > *:nth-child(1) { animation-delay: 0ms; }
.content > *:nth-child(2) { animation-delay: 55ms; }
.content > *:nth-child(3) { animation-delay: 110ms; }
.content > *:nth-child(4) { animation-delay: 160ms; }
.content > *:nth-child(n+5) { animation-delay: 200ms; }

/* Table rows — stagger as they enter on page load */
.table tbody tr {
  animation: row-in .22s ease-out both;
}
.table tbody tr:nth-child(1)  { animation-delay: 60ms; }
.table tbody tr:nth-child(2)  { animation-delay: 85ms; }
.table tbody tr:nth-child(3)  { animation-delay: 108ms; }
.table tbody tr:nth-child(4)  { animation-delay: 130ms; }
.table tbody tr:nth-child(5)  { animation-delay: 150ms; }
.table tbody tr:nth-child(6)  { animation-delay: 168ms; }
.table tbody tr:nth-child(7)  { animation-delay: 184ms; }
.table tbody tr:nth-child(n+8) { animation-delay: 198ms; }

/* ============================================================================
   RTL overrides
   ----------------------------------------------------------------------------
   The bulk of the stylesheet mirrors automatically because it uses logical
   properties. These rules cover the handful of cases that cannot: inset
   box-shadows, explicit translateX() distances, the physical
   background-position of the <select> chevron, and the off-canvas mobile
   drawer. They apply only under <html dir="rtl"> (Arabic and future RTL
   languages) — LTR rendering is untouched.
   ============================================================================ */
[dir="rtl"] .sidebar__link.is-active { box-shadow: inset -2px 0 0 var(--primary); }
[dir="rtl"] .sidebar__link:hover { transform: translateX(-3px); }

/* <select> chevron: move it to the (visual) left and pad on that side so the
   selected-option text clears the chevron instead of running under it.
   direction:rtl must be explicit (not just inherited) — Blink/Gecko take a
   different code path for appearance:none selects when direction is inherited
   vs. set directly, and may still render the value text at the physical left.
   text-align:right is a belt-and-suspenders for the same issue. Physical
   padding (not logical) removes any remaining browser ambiguity. */
[dir="rtl"] .select {
  direction: rtl;
  text-align: right;
  background-position: left 10px center;
  padding-right: 12px;
  padding-left: 30px;
}

/* Toggle-switch knob travels the opposite way. */
[dir="rtl"] .switch input:checked + .switch__track::before { transform: translateX(-16px); }
[dir="rtl"] .switch--lg input:checked + .switch__track::before { transform: translateX(-20px); }

/* Segmented button group: flip the rounded ends and the collapsed borders. */
[dir="rtl"] .btn-group .btn { border-right-width: 1px; border-left-width: 0; }
[dir="rtl"] .btn-group .btn:first-child { border-radius: 0 8px 8px 0; }
[dir="rtl"] .btn-group .btn:last-child  { border-radius: 8px 0 0 8px; border-left-width: 1px; }

/* Off-canvas mobile sidebar slides in from the right under RTL. */
@media (max-width: 900px) {
  [dir="rtl"] .sidebar {
    left: auto; right: 0;
    transform: translateX(100%);
  }
  [dir="rtl"] .sidebar.is-open { transform: translateX(0); }
  [dir="rtl"] .sidebar-backdrop.is-open { display: block; }
}
