/* ==========================================================================
   Supreonix Medical — Base / Reset
   ========================================================================== */

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

html {
  /* Long unbroken strings (URLs, model codes) must not create horizontal
     overflow on narrow screens. */
  overflow-wrap: break-word;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tight);
  color: var(--c-text);
}

p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, svg, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
  margin: 0;
}

button { cursor: pointer; background: none; border: none; padding: 0; }

table { border-collapse: collapse; width: 100%; }

hr {
  border: 0;
  border-top: 1px solid var(--c-border);
  margin: var(--sp-6) 0;
}

/* ---------- Focus visibility (keyboard only) ---------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* ---------- Selection ---------- */
::selection { background: var(--c-primary-100); color: var(--c-primary-700); }

/* ---------- Scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--c-border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--c-border-strong);
  border-radius: var(--r-full);
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--c-text-faint); background-clip: content-box; }

/* ---------- Accessibility helpers ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--sp-4); top: -60px;
  z-index: 200; padding: var(--sp-3) var(--sp-5);
  background: var(--c-primary); color: #fff;
  border-radius: var(--r-md); font-weight: var(--fw-semibold);
  transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: var(--sp-4); }

/* ==========================================================================
   Layout primitives
   ========================================================================== */

.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--sp-5);
}
@media (max-width: 640px) { .container { padding-inline: var(--sp-4); } }

.stack > * + * { margin-top: var(--sp-4); }
.stack-sm > * + * { margin-top: var(--sp-2); }
.stack-lg > * + * { margin-top: var(--sp-6); }

.row { display: flex; align-items: center; gap: var(--sp-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.row-wrap { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.spacer { flex: 1 1 auto; }

.grid { display: grid; gap: var(--sp-5); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px)  { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px)  {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .grid { gap: var(--sp-4); }
}

/* ==========================================================================
   Typography utilities
   ========================================================================== */

.t-display { font-size: var(--fs-5xl); font-weight: var(--fw-bold); letter-spacing: -0.03em; line-height: 1.08; }
.t-h1 { font-size: var(--fs-4xl); font-weight: var(--fw-bold); letter-spacing: -0.025em; }
.t-h2 { font-size: var(--fs-3xl); font-weight: var(--fw-semibold); }
.t-h3 { font-size: var(--fs-2xl); font-weight: var(--fw-semibold); }
.t-h4 { font-size: var(--fs-xl); font-weight: var(--fw-semibold); }
.t-lg { font-size: var(--fs-lg); }
.t-base { font-size: var(--fs-base); }
.t-sm { font-size: var(--fs-sm); }
.t-xs { font-size: var(--fs-xs); }
.t-muted { color: var(--c-text-muted); }
.t-secondary { color: var(--c-text-secondary); }
.t-faint { color: var(--c-text-faint); }
.t-medium { font-weight: var(--fw-medium); }
.t-semibold { font-weight: var(--fw-semibold); }
.t-bold { font-weight: var(--fw-bold); }
.t-mono { font-family: var(--font-mono); }
.t-center { text-align: center; }
.t-right { text-align: right; }
.t-uppercase { text-transform: uppercase; letter-spacing: .06em; }
.t-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.t-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

@media (max-width: 700px) {
  .t-display { font-size: var(--fs-4xl); }
  .t-h1 { font-size: var(--fs-3xl); }
  .t-h2 { font-size: var(--fs-2xl); }
  .t-h3 { font-size: var(--fs-xl); }
}

/* ==========================================================================
   Buttons
   Hierarchy: primary (the one action) > secondary (supporting) >
   tertiary (low priority text action). Only one primary per context.
   ========================================================================== */

.btn {
  --btn-h: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: var(--btn-h);
  padding: 0 var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease);
  user-select: none;
}
.btn:disabled, .btn[aria-disabled="true"] {
  opacity: .5; cursor: not-allowed; pointer-events: none;
}
.btn svg { width: 16px; height: 16px; flex: none; }

/* Primary — solid, confident, reserved for the single main action */
.btn-primary {
  background: var(--c-primary);
  color: #fff;
  border-color: var(--c-primary);
  font-weight: var(--fw-semibold);
}
.btn-primary:hover { background: var(--c-primary-600); border-color: var(--c-primary-600); }
.btn-primary:focus-visible { box-shadow: var(--ring); }

/* Secondary — supporting action. Neutral, no shadow, no colour competition */
.btn-secondary {
  background: var(--c-surface);
  color: var(--c-text);
  border-color: var(--c-border-strong);
}
.btn-secondary:hover { background: var(--c-surface-sunken); border-color: var(--c-text-faint); }

/* Outline — supporting action on coloured or busy backgrounds */
.btn-outline {
  background: transparent;
  color: var(--c-text);
  border-color: var(--c-border-strong);
}
.btn-outline:hover { background: var(--c-surface-sunken); border-color: var(--c-text-faint); }

/* Ghost — minimal weight, still a control */
.btn-ghost {
  background: transparent;
  color: var(--c-text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--c-surface-sunken); color: var(--c-text); }

/* Tertiary — low-priority text action. Reads as a link, not a button */
.btn-tertiary {
  background: transparent;
  color: var(--c-text-secondary);
  border-color: transparent;
  padding: 0 var(--sp-2);
  font-weight: var(--fw-medium);
}
.btn-tertiary:hover { color: var(--c-primary); background: transparent; }
.btn-tertiary:hover span { text-decoration: underline; text-underline-offset: 3px; }

.btn-danger {
  background: var(--c-danger);
  color: #fff;
  border-color: var(--c-danger);
  font-weight: var(--fw-semibold);
}
.btn-danger:hover { background: #96180f; border-color: #96180f; }
.btn-danger:focus-visible { box-shadow: var(--ring-danger); }

.btn-danger-ghost {
  background: transparent;
  color: var(--c-danger);
  border-color: transparent;
}
.btn-danger-ghost:hover { background: var(--c-danger-bg); }

.btn-success {
  background: var(--c-success);
  color: #fff;
  border-color: var(--c-success);
  font-weight: var(--fw-semibold);
}
.btn-success:hover { background: #0d6b4d; border-color: #0d6b4d; }

/* Solid light button, for use on dark/coloured bands */
.btn-white {
  background: #fff; color: var(--c-primary-700); border-color: #fff;
  font-weight: var(--fw-semibold);
}
.btn-white:hover { background: var(--c-primary-50); }

/* WhatsApp — commercially important, so it keeps brand recognition,
   but toned down from the previous neon treatment. */
.btn-wa {
  background: #1da851; color: #fff; border-color: #1da851;
  font-weight: var(--fw-semibold);
}
.btn-wa:hover { background: #178a42; border-color: #178a42; }

.btn-sm { --btn-h: 32px; padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { --btn-h: 44px; padding: 0 var(--sp-5); font-size: var(--fs-md); }
.btn-lg svg { width: 17px; height: 17px; }
.btn-block { width: 100%; }
.btn-icon { width: var(--btn-h); padding: 0; }

/* Button loading state */
.btn.is-loading { color: transparent !important; position: relative; pointer-events: none; }
.btn.is-loading::after {
  content: "";
  position: absolute; inset: 0; margin: auto;
  width: 16px; height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  color: #fff;
  animation: spin .6s linear infinite;
}
.btn-secondary.is-loading::after, .btn-ghost.is-loading::after,
.btn-outline.is-loading::after { color: var(--c-text-secondary); }

@keyframes spin { to { transform: rotate(360deg); } }

/* Button group */
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: var(--r-md) 0 0 var(--r-md); }
.btn-group .btn:last-child { border-radius: 0 var(--r-md) var(--r-md) 0; }
.btn-group .btn + .btn { margin-left: -1px; }

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-xs);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-5) 0;
}
.card-header.has-border { padding-bottom: var(--sp-4); border-bottom: 1px solid var(--c-border); }
/* Header text must be allowed to shrink next to the actions slot. */
.card-header > div { min-width: 0; }
.card-title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.01em;
}
.card-subtitle { font-size: var(--fs-sm); color: var(--c-text-muted); margin-top: 2px; }
.card-body { padding: var(--sp-5); }
.card-body.flush { padding: 0; }
.card-footer {
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--c-border);
  background: var(--c-surface-2);
}
.card-hover { transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.card-hover:hover { box-shadow: var(--sh-md); border-color: var(--c-border-strong); }

/* ==========================================================================
   Badges / status indicators
   Status should read at a glance without becoming the loudest element on
   the page. Colour carries meaning; decoration does not.
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  line-height: 1.6;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge svg { width: 12px; height: 12px; }

/* Quiet neutral is the default — most metadata is not a status */
.badge-neutral { background: var(--c-surface-sunken); color: var(--c-text-secondary); border-color: var(--c-border); }
.badge-primary { background: var(--c-primary-50); color: var(--c-primary-700); border-color: var(--c-primary-100); }

/* Semantic statuses — colour is the signal */
.badge-success { background: var(--c-success-bg); color: var(--c-success); border-color: var(--c-success-border); }
.badge-warning { background: var(--c-warning-bg); color: var(--c-warning); border-color: var(--c-warning-border); }
.badge-danger  { background: var(--c-danger-bg);  color: var(--c-danger);  border-color: var(--c-danger-border); }
.badge-info    { background: var(--c-info-bg);    color: var(--c-info);    border-color: var(--c-info-border); }
.badge-accent  { background: var(--c-accent-50);  color: var(--c-accent);  border-color: #b8e6df; }

.badge-dot::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex: none;
}

/* Outlined status — for product imagery overlays where a solid tint
   would fight with the photograph. */
.badge-solid {
  background: rgba(255,255,255,.94);
  color: var(--c-text);
  border-color: var(--c-border);
  box-shadow: none;
  backdrop-filter: blur(6px);
}
.badge-solid.badge-featured { color: var(--c-primary-700); border-color: var(--c-primary-100); }

/* ==========================================================================
   Forms
   ========================================================================== */

.field { display: block; }
.field + .field { margin-top: var(--sp-5); }

.label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--c-text);
  margin-bottom: var(--sp-2);
}
.label .req { color: var(--c-danger); margin-left: 2px; }
.label-hint { font-weight: var(--fw-regular); color: var(--c-text-muted); font-size: var(--fs-xs); }

.input, .select, .textarea {
  display: block;
  width: 100%;
  min-height: 38px;
  padding: 8px var(--sp-3);
  background: var(--c-surface);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-md);
  font-size: var(--fs-base);
  color: var(--c-text);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--c-text-faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--c-text-faint); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--c-primary);
  box-shadow: var(--ring);
}
.input:disabled, .select:disabled, .textarea:disabled {
  background: var(--c-surface-sunken); color: var(--c-text-muted); cursor: not-allowed;
}
.textarea { min-height: 100px; resize: vertical; line-height: var(--lh-base); }

.select {
  appearance: none;
  padding-right: var(--sp-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--sp-3) center;
  cursor: pointer;
}

/* Input with leading icon */
.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-left: 38px; }
.input-group .input-icon {
  position: absolute; left: var(--sp-3);
  width: 16px; height: 16px; color: var(--c-text-faint); pointer-events: none;
}
.input-group .input-suffix {
  position: absolute; right: var(--sp-3); font-size: var(--fs-sm); color: var(--c-text-muted);
}

.help { margin-top: var(--sp-2); font-size: var(--fs-xs); color: var(--c-text-muted); }
.error-text { margin-top: var(--sp-2); font-size: var(--fs-xs); color: var(--c-danger); font-weight: var(--fw-medium); }

.field.has-error .input, .field.has-error .select, .field.has-error .textarea {
  border-color: var(--c-danger);
}
.field.has-error .input:focus { box-shadow: var(--ring-danger); }
.field.is-valid .input, .field.is-valid .select { border-color: var(--c-success); }

/* Checkbox & radio */
.check {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  cursor: pointer; font-size: var(--fs-base); line-height: var(--lh-snug);
}
.check input[type="checkbox"], .check input[type="radio"] {
  appearance: none;
  flex: none;
  width: 18px; height: 18px; margin-top: 1px;
  border: 1.5px solid var(--c-border-strong);
  border-radius: var(--r-xs);
  background: #fff;
  transition: all var(--dur-fast) var(--ease);
  cursor: pointer;
}
.check input[type="radio"] { border-radius: 50%; }
.check input:checked {
  background: var(--c-primary); border-color: var(--c-primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center;
}
.check input[type="radio"]:checked {
  background-image: none; box-shadow: inset 0 0 0 4px #fff;
}
.check input:focus-visible { outline: none; box-shadow: var(--ring); }
.check-text { color: var(--c-text-secondary); }

/* Toggle switch */
.switch { display: inline-flex; align-items: center; gap: var(--sp-3); cursor: pointer; }
.switch input { appearance: none; position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  position: relative; width: 40px; height: 23px; flex: none;
  background: var(--c-border-strong); border-radius: var(--r-full);
  transition: background var(--dur) var(--ease);
}
.switch-track::after {
  content: ""; position: absolute; top: 2.5px; left: 2.5px;
  width: 18px; height: 18px; background: #fff; border-radius: 50%;
  box-shadow: var(--sh-sm); transition: transform var(--dur) var(--ease-out);
}
.switch input:checked + .switch-track { background: var(--c-primary); }
.switch input:checked + .switch-track::after { transform: translateX(17px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--ring); }

/* Form section */
.form-section + .form-section {
  margin-top: var(--sp-7);
  padding-top: var(--sp-7);
  border-top: 1px solid var(--c-border);
}
.form-section-head { margin-bottom: var(--sp-5); }
.form-section-head h3 { font-size: var(--fs-md); font-weight: var(--fw-semibold); }
.form-section-head p { font-size: var(--fs-sm); color: var(--c-text-muted); margin-top: 3px; }

.form-grid { display: grid; gap: var(--sp-5); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .col-span-2 { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }

/* File upload / dropzone */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-7) var(--sp-5);
  border: 1.5px dashed var(--c-border-strong);
  border-radius: var(--r-lg);
  background: var(--c-surface-2);
  text-align: center;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.dropzone:hover, .dropzone.is-drag { border-color: var(--c-primary); background: var(--c-primary-50); }
.dropzone-icon { color: var(--c-text-faint); }
.dropzone strong { font-size: var(--fs-base); font-weight: var(--fw-semibold); }
.dropzone span { font-size: var(--fs-xs); color: var(--c-text-muted); }

/* Image preview grid (admin uploads) */
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--sp-3); }
.thumb {
  position: relative; aspect-ratio: 4/3; border-radius: var(--r-md);
  overflow: hidden; border: 1px solid var(--c-border); background: var(--c-surface-sunken);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-actions {
  position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.thumb:hover .thumb-actions { opacity: 1; }
.thumb-actions .btn {
  --btn-h: 26px; width: 26px; padding: 0; border-radius: var(--r-sm);
  background: rgba(16,24,40,.72); color: #fff; backdrop-filter: blur(4px);
}
.thumb-actions .btn:hover { background: rgba(16,24,40,.9); }
.thumb-actions .btn.del:hover { background: var(--c-danger); }
.thumb-badge {
  position: absolute; left: 6px; bottom: 6px;
  padding: 2px 7px; border-radius: var(--r-xs);
  background: rgba(16,24,40,.72); color: #fff; font-size: 10px;
  font-weight: var(--fw-semibold); backdrop-filter: blur(4px);
}

/* ==========================================================================
   Tables
   ========================================================================== */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table { min-width: 100%; font-size: var(--fs-base); }
.table th {
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--c-text-muted);
  background: var(--c-surface-2);
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--c-text); }
.table th .sort-ind { display: inline-block; margin-left: 4px; opacity: .4; }
.table th.sorted .sort-ind { opacity: 1; color: var(--c-primary); }
.table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
}
.table tbody tr { transition: background var(--dur-fast) var(--ease); }
.table tbody tr:hover { background: var(--c-surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .cell-tight { width: 1%; white-space: nowrap; }
.table .cell-actions { text-align: right; white-space: nowrap; }

.table-check { width: 40px; }
.table-check input { appearance: none; width: 17px; height: 17px; border: 1.5px solid var(--c-border-strong); border-radius: var(--r-xs); background: #fff; cursor: pointer; }
.table-check input:checked {
  background: var(--c-primary); border-color: var(--c-primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center;
}

/* List row with leading media (used in tables + lists) */
.media { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.media-img {
  width: 40px; height: 40px; flex: none;
  border-radius: var(--r-sm); object-fit: cover;
  border: 1px solid var(--c-border); background: var(--c-surface-sunken);
}
.media-img.lg { width: 48px; height: 48px; }
.media-body { min-width: 0; }
.media-title { font-weight: var(--fw-semibold); color: var(--c-text); }
.media-sub { font-size: var(--fs-xs); color: var(--c-text-muted); }

/* ==========================================================================
   Toolbar (search / filter bar above tables)
   ========================================================================== */

.toolbar {
  display: flex; align-items: center; gap: var(--sp-3);
  flex-wrap: wrap;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface);
}
.toolbar .search { flex: 1 1 260px; max-width: 380px; }
.toolbar .toolbar-spacer { flex: 1 1 auto; }
@media (max-width: 640px) {
  .toolbar { padding: var(--sp-3) var(--sp-4); }
  .toolbar .search { max-width: none; }
  .toolbar .filter-select { flex: 1 1 140px; }
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.pagination {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap;
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--c-border);
}
.pagination-info { font-size: var(--fs-sm); color: var(--c-text-muted); }
.pagination-pages { display: flex; align-items: center; gap: var(--sp-1); }
.page-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 var(--sp-2);
  border-radius: var(--r-sm); border: 1px solid transparent;
  font-size: var(--fs-sm); font-weight: var(--fw-medium);
  color: var(--c-text-secondary);
  transition: all var(--dur-fast) var(--ease);
}
.page-btn:hover { background: var(--c-surface-sunken); color: var(--c-text); }
.page-btn.is-active { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.page-btn.is-disabled { opacity: .4; pointer-events: none; }
.page-ellipsis { color: var(--c-text-faint); padding: 0 2px; }

/* ==========================================================================
   Dropdown / menu
   ========================================================================== */

.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 200px; padding: var(--sp-2);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
  z-index: var(--z-modal);
  opacity: 0; visibility: hidden; transform: translateY(-6px) scale(.98);
  transform-origin: top right;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease-out), visibility var(--dur);
}
.dropdown-menu.left { right: auto; left: 0; transform-origin: top left; }
.dropdown-menu.wide { min-width: 280px; }
.dropdown.is-open .dropdown-menu { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.dropdown-item {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  font-size: var(--fs-base); color: var(--c-text-secondary);
  text-align: left; transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.dropdown-item:hover { background: var(--c-surface-sunken); color: var(--c-text); }
.dropdown-item svg { width: 16px; height: 16px; color: var(--c-text-faint); flex: none; }
.dropdown-item:hover svg { color: var(--c-text-secondary); }
.dropdown-item.danger { color: var(--c-danger); }
.dropdown-item.danger:hover { background: var(--c-danger-bg); }
.dropdown-item.danger svg { color: var(--c-danger); }
.dropdown-divider { height: 1px; background: var(--c-border); margin: var(--sp-2) 0; }
.dropdown-header {
  padding: var(--sp-2) var(--sp-3); font-size: var(--fs-xs);
  font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: .05em;
  color: var(--c-text-faint);
}

/* ==========================================================================
   Modal / dialog
   ========================================================================== */

.modal-backdrop {
  position: fixed; inset: 0; z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-5);
  background: var(--c-overlay);
  opacity: 0; visibility: hidden;
  transition: opacity var(--dur) var(--ease), visibility var(--dur);
  backdrop-filter: blur(2px);
}
.modal-backdrop.is-open { opacity: 1; visibility: visible; }
.modal {
  width: 100%; max-width: 520px; max-height: calc(100vh - 2 * var(--sp-5));
  display: flex; flex-direction: column;
  background: var(--c-surface);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-xl);
  transform: translateY(10px) scale(.98);
  transition: transform var(--dur-slow) var(--ease-out);
  overflow: hidden;
}
.modal-backdrop.is-open .modal { transform: translateY(0) scale(1); }
.modal.sm { max-width: 420px; }
.modal.lg { max-width: 720px; }
.modal.xl { max-width: 960px; }
.modal-header {
  display: flex; align-items: flex-start; gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--c-border);
}
.modal-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.modal-subtitle { font-size: var(--fs-sm); color: var(--c-text-muted); margin-top: 3px; }
.modal-header > div { min-width: 0; }
.modal-close {
  flex: none; width: 32px; height: 32px; border-radius: var(--r-md);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--c-text-muted); transition: all var(--dur-fast) var(--ease);
}
.modal-close:hover { background: var(--c-surface-sunken); color: var(--c-text); }
.modal-body { padding: var(--sp-6); overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--c-border);
  background: var(--c-surface-2);
}
.modal-icon {
  width: 44px; height: 44px; flex: none; border-radius: var(--r-full);
  display: inline-flex; align-items: center; justify-content: center;
}
.modal-icon.danger { background: var(--c-danger-bg); color: var(--c-danger); }
.modal-icon.warning { background: var(--c-warning-bg); color: var(--c-warning); }
.modal-icon.success { background: var(--c-success-bg); color: var(--c-success); }
.modal-icon.info { background: var(--c-info-bg); color: var(--c-info); }
@media (max-width: 640px) {
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { max-width: none; max-height: 92vh; border-radius: var(--r-xl) var(--r-xl) 0 0; }
  .modal-header, .modal-body, .modal-footer { padding-inline: var(--sp-5); }
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; }
}

/* ==========================================================================
   Toasts
   ========================================================================== */

.toast-region {
  position: fixed; top: calc(var(--header-h) + var(--sp-3)); right: var(--sp-5);
  z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: var(--sp-3);
  width: min(380px, calc(100vw - 2 * var(--sp-4)));
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-left: 3px solid var(--c-neutral);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
  min-width: 0;
  pointer-events: auto;
  animation: toast-in var(--dur-slow) var(--ease-out);
}
.toast.leaving { animation: toast-out var(--dur) var(--ease) forwards; }
.toast-icon { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: var(--fw-semibold); font-size: var(--fs-base); }
.toast-msg { font-size: var(--fs-sm); color: var(--c-text-muted); margin-top: 2px; }
.toast-close { flex: none; color: var(--c-text-faint); padding: 2px; }
.toast-close:hover { color: var(--c-text); }
.toast.success { border-left-color: var(--c-success); }
.toast.success .toast-icon { color: var(--c-success); }
.toast.error { border-left-color: var(--c-danger); }
.toast.error .toast-icon { color: var(--c-danger); }
.toast.warning { border-left-color: var(--c-warning); }
.toast.warning .toast-icon { color: var(--c-warning); }
.toast.info { border-left-color: var(--c-info); }
.toast.info .toast-icon { color: var(--c-info); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(16px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateX(16px); }
}
@media (max-width: 640px) {
  .toast-region { top: auto; bottom: calc(var(--bottomnav-h) + var(--sp-3)); left: var(--sp-4); right: var(--sp-4); width: auto; }
}

/* ==========================================================================
   Empty / loading / error states
   ========================================================================== */

.state {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: var(--sp-10) var(--sp-5);
}
.state.compact { padding: var(--sp-7) var(--sp-5); }
.state-icon {
  width: 56px; height: 56px; border-radius: var(--r-full);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--c-primary-50); color: var(--c-primary);
  margin-bottom: var(--sp-5);
}
.state-icon.neutral { background: var(--c-surface-sunken); color: var(--c-text-faint); }
.state-icon.danger { background: var(--c-danger-bg); color: var(--c-danger); }
.state-icon svg { width: 26px; height: 26px; }
.state-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.state-desc { font-size: var(--fs-base); color: var(--c-text-muted); max-width: 42ch; margin-top: var(--sp-2); }
.state-actions { display: flex; gap: var(--sp-3); margin-top: var(--sp-6); flex-wrap: wrap; justify-content: center; }

/* Skeleton loaders */
.skeleton {
  position: relative; overflow: hidden;
  background: var(--c-surface-sunken);
  border-radius: var(--r-sm);
}
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.75), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-line { height: 12px; margin-bottom: var(--sp-2); }
.sk-line.w-40 { width: 40%; } .sk-line.w-60 { width: 60%; }
.sk-line.w-80 { width: 80%; } .sk-line.w-100 { width: 100%; }
.sk-title { height: 18px; width: 55%; margin-bottom: var(--sp-4); }
.sk-img { aspect-ratio: 4/3; border-radius: var(--r-md); }
.sk-avatar { width: 40px; height: 40px; border-radius: var(--r-full); flex: none; }

/* ==========================================================================
   Alerts (inline)
   ========================================================================== */

.alert {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  border: 1px solid var(--c-border);
  font-size: var(--fs-base);
}
.alert svg { flex: none; width: 18px; height: 18px; margin-top: 1px; }
/* The text block must be allowed to shrink inside the flex row. */
.alert > div { min-width: 0; }
.alert-title { font-weight: var(--fw-semibold); }
.alert-desc { color: var(--c-text-secondary); font-size: var(--fs-sm); margin-top: 2px; }
.alert-info    { background: var(--c-info-bg);    border-color: var(--c-info-border);    color: var(--c-info); }
.alert-success { background: var(--c-success-bg); border-color: var(--c-success-border); color: var(--c-success); }
.alert-warning { background: var(--c-warning-bg); border-color: var(--c-warning-border); color: var(--c-warning); }
.alert-danger  { background: var(--c-danger-bg);  border-color: var(--c-danger-border);  color: var(--c-danger); }
.alert-desc { color: inherit; opacity: .82; }

/* ==========================================================================
   Tabs
   ========================================================================== */

.tabs {
  display: flex; gap: var(--sp-1);
  border-bottom: 1px solid var(--c-border);
  overflow-x: auto;
}
.tab {
  position: relative;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-base); font-weight: var(--fw-medium);
  color: var(--c-text-muted); white-space: nowrap;
  transition: color var(--dur-fast) var(--ease);
}
.tab:hover { color: var(--c-text); }
.tab.is-active { color: var(--c-primary); font-weight: var(--fw-semibold); }
.tab.is-active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px; background: var(--c-primary); border-radius: 2px 2px 0 0;
}

/* ==========================================================================
   Progress
   ========================================================================== */

.progress { height: 8px; background: var(--c-surface-sunken); border-radius: var(--r-full); overflow: hidden; }
.progress-bar { height: 100%; background: var(--c-primary); border-radius: inherit; transition: width var(--dur-slow) var(--ease-out); }
.progress-bar.success { background: var(--c-success); }
.progress-bar.warning { background: var(--c-warning); }
.progress-bar.danger { background: var(--c-danger); }

/* ==========================================================================
   Avatars
   ========================================================================== */

.avatar {
  width: 34px; height: 34px; flex: none; border-radius: var(--r-full);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--c-primary-50); color: var(--c-primary-700);
  font-size: var(--fs-sm); font-weight: var(--fw-semibold);
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 28px; height: 28px; font-size: var(--fs-xs); }
.avatar.lg { width: 44px; height: 44px; font-size: var(--fs-md); }

/* ==========================================================================
   Utility
   ========================================================================== */

.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); } .gap-4 { gap: var(--sp-4); }
.gap-5 { gap: var(--sp-5); } .gap-6 { gap: var(--sp-6); }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); } .mt-5 { margin-top: var(--sp-5); } .mt-6 { margin-top: var(--sp-6); }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: var(--sp-2); } .mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); } .mb-5 { margin-bottom: var(--sp-5); } .mb-6 { margin-bottom: var(--sp-6); }
.w-full { width: 100%; }
.relative { position: relative; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divider { height: 1px; background: var(--c-border); }
@media (min-width: 641px) { .hide-desktop { display: none !important; } }
@media (max-width: 640px) { .hide-mobile { display: none !important; } }
