/* ============================================================================
   OpsWiki — Components
   Buttons, inputs, cards, badges, tables, modals, toasts, app shell.
   ========================================================================== */

/* ============================================================================
   APP SHELL
   ========================================================================== */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas: "sidebar topbar" "sidebar main";
  min-height: 100vh;
}

/* ---- Sidebar ------------------------------------------------------------ */
.sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
  z-index: 30;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.sidebar-brand svg { width: 26px; height: 26px; flex: none; }

.wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.12rem;
  letter-spacing: -0.035em;
  color: var(--ink);
}
.wordmark em { color: var(--red); font-style: normal; }

.sidebar-org {
  padding: 12px 12px 8px;
  border-bottom: 1px solid var(--line-soft);
}

.org-switch {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition: all var(--fast);
  font-family: inherit;
  color: var(--ink);
}
.org-switch:hover { border-color: var(--red); background: var(--red-mute); }

.org-avatar {
  width: 30px; height: 30px; flex: none;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--red), var(--red-deep));
  color: #fff;
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 700; font-size: 0.8rem;
  overflow: hidden;
}
/* Once a real picture is loaded the gradient would tint its edges, so drop it. */
.org-avatar.has-logo { background: var(--surface-2); }
.org-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.org-avatar.md { width: 40px; height: 40px; font-size: 1rem; border-radius: 12px; }
.org-avatar.lg { width: 64px; height: 64px; font-size: 1.4rem; border-radius: 16px; }

/* ---------------------------------------------------------------------------
   Picture upload targets — the org logo (square) and a person's avatar (round).

   .logo-overlay is a standalone class on purpose. Scoping its positioning to
   `.logo-picker .logo-overlay` meant it stayed static inside .avatar-picker,
   so the camera icon rendered as a block UNDER the photo instead of covering
   it on hover.
   --------------------------------------------------------------------------- */
.logo-picker,
.avatar-picker {
  position: relative;
  cursor: pointer;
  overflow: hidden;
  flex: none;
  display: block;
  /* No line-height reset here: the initials inside .avatar / .org-avatar
     inherit it, and zeroing it collapses them. The images are display:block
     already, so there is no descender gap to remove. */
}
.logo-picker  { border-radius: 16px; }
.avatar-picker { border-radius: 50%; }

.logo-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 18, 0.62);
  color: #fff;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity var(--fast);
  border-radius: inherit;
  pointer-events: none;    /* the click belongs to the picker, not the overlay */
}
.logo-picker:hover  .logo-overlay,
.avatar-picker:hover .logo-overlay,
.logo-picker:focus-visible  .logo-overlay,
.avatar-picker:focus-visible .logo-overlay { opacity: 1; }

.logo-overlay svg { width: 18px; height: 18px; }

.sidebar-nav { padding: 10px 10px 20px; flex: 1; }

.nav-section {
  font-size: 0.66rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ink-faint);
  padding: 14px 10px 6px;
}

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: 0.9rem; font-weight: 500;
  cursor: pointer;
  transition: all var(--fast);
  border: none; background: none; width: 100%;
  font-family: inherit; text-align: left;
  position: relative;
}
.nav-item:hover { background: var(--surface-hover); color: var(--ink); }
.nav-item.active {
  background: var(--surface-active);
  color: var(--red);
  font-weight: 600;
}
.nav-item.active::before {
  content: ''; position: absolute; left: -10px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 18px;
  background: var(--red);
  border-radius: 0 3px 3px 0;
}
.nav-item svg { width: 17px; height: 17px; flex: none; stroke-width: 1.9; }
.nav-item .nav-count {
  margin-left: auto;
  font-size: 0.7rem; font-weight: 700;
  font-family: var(--font-mono);
  color: var(--ink-faint);
  background: var(--surface-2);
  padding: 1px 6px; border-radius: 20px;
}
.nav-item.active .nav-count { color: var(--red); background: var(--red-mute); }

.nav-item.is-admin { color: var(--red-deep); }
.nav-item.is-admin svg { color: var(--red); }

/* ---- Topbar ------------------------------------------------------------- */
.topbar {
  grid-area: topbar;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 25;
}

.search-trigger {
  display: flex; align-items: center; gap: 9px;
  min-width: 240px; max-width: 400px; flex: 1;
  padding: 7px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink-mute);
  font-size: 0.86rem;
  cursor: pointer;
  transition: all var(--fast);
  font-family: inherit;
}
.search-trigger:hover { border-color: var(--red); color: var(--ink-soft); }
.search-trigger svg { width: 15px; height: 15px; flex: none; }
.search-trigger kbd { margin-left: auto; }

/* ---- Main --------------------------------------------------------------- */
.main {
  grid-area: main;
  padding: 26px 28px 80px;
  max-width: 100%;
  min-width: 0;
  background: var(--bg);
}

.page-head {
  display: flex; align-items: flex-start; gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.page-head h1 { font-size: 1.65rem; }
.page-head .sub { color: var(--ink-mute); font-size: 0.9rem; margin-top: 3px; }


/* ============================================================================
   BUTTONS
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px;
  font-family: var(--font-body);
  font-size: 0.88rem; font-weight: 600;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--fast);
  white-space: nowrap;
  line-height: 1.2;
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--line);
}
.btn:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--line-strong); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; stroke-width: 2; }

.btn-primary {
  background: var(--ink); color: var(--bg-pure); border-color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) {
  background: #000; border-color: #000;
  box-shadow: var(--shadow-md);
}
:root[data-theme="dark"] .btn-primary { background: var(--ink); color: #0b0b12; }
:root[data-theme="dark"] .btn-primary:hover:not(:disabled) { background: #fff; border-color: #fff; }

.btn-red {
  background: var(--red); color: var(--red-ink); border-color: var(--red);
  box-shadow: 0 6px 18px -6px var(--red-glow);
}
.btn-red:hover:not(:disabled) {
  background: var(--red-bright); border-color: var(--red-bright);
  box-shadow: 0 10px 26px -8px var(--red-glow);
}

.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); color: var(--ink); }

.btn-outline { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn-outline:hover:not(:disabled) { border-color: var(--red); color: var(--red); background: var(--red-mute); }

.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { padding: 13px 26px; font-size: 0.98rem; }
.btn-lg svg { width: 18px; height: 18px; }
.btn-block { width: 100%; }

.btn-icon {
  padding: 8px; border-radius: var(--radius-sm);
  background: transparent; border-color: transparent; color: var(--ink-mute);
}
.btn-icon:hover:not(:disabled) { background: var(--surface-hover); color: var(--ink); }
.btn-icon.sm { padding: 5px; }

.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }


/* ============================================================================
   FORMS
   ========================================================================== */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 15px; }

.label {
  font-size: 0.78rem; font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}
.label .req { color: var(--red); margin-left: 2px; }
.hint { font-size: 0.76rem; color: var(--ink-mute); line-height: 1.45; }

.input, .textarea, .select {
  width: 100%;
  padding: 10px 13px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--bg-pure);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: all var(--fast);
  outline: none;
}
.input::placeholder, .textarea::placeholder { color: var(--ink-faint); }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-mute);
}
.input:disabled, .textarea:disabled, .select:disabled {
  background: var(--surface-2); color: var(--ink-mute); cursor: not-allowed;
}

.textarea { resize: vertical; min-height: 84px; line-height: 1.55; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a7a86' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 15px;
  padding-right: 34px;
  cursor: pointer;
}

.input-mono { font-family: var(--font-mono); font-size: 0.84rem; }

.input-icon { position: relative; }
.input-icon svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--ink-faint); pointer-events: none;
}
.input-icon .input { padding-left: 36px; }

.checkbox, .radio {
  display: flex; align-items: flex-start; gap: 9px;
  cursor: pointer; font-size: 0.88rem; color: var(--ink-soft);
  user-select: none;
}
.checkbox input, .radio input {
  width: 17px; height: 17px; margin-top: 1px;
  accent-color: var(--red); cursor: pointer; flex: none;
}

/* Segmented control — used for permission levels */
.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.segmented button {
  padding: 5px 13px;
  border: none; background: none;
  border-radius: 999px;
  font-family: inherit; font-size: 0.78rem; font-weight: 600;
  color: var(--ink-mute); cursor: pointer;
  transition: all var(--fast);
  white-space: nowrap;
}
.segmented button:hover { color: var(--ink); }
.segmented button.on { background: var(--bg-pure); color: var(--ink); box-shadow: var(--shadow-sm); }
.segmented button.on[data-level="none"]  { color: var(--ink-mute); }
.segmented button.on[data-level="view"]  { color: var(--info); }
.segmented button.on[data-level="edit"]  { color: var(--red); }

/* Tag input */
.tag-input {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 7px 9px;
  background: var(--bg-pure);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  min-height: 42px;
}
.tag-input:focus-within { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-mute); }
.tag-input input {
  flex: 1; min-width: 90px; border: none; outline: none;
  background: none; font-family: inherit; font-size: 0.86rem; color: var(--ink);
}


/* ============================================================================
   CARDS
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  transition: all var(--med);
}
.card-hover { cursor: pointer; }
.card-hover:hover {
  border-color: var(--red);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.card-pad-lg { padding: 24px; }
.card-flush { padding: 0; overflow: hidden; }

.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.card-head h3 { font-size: 0.98rem; }
.card-body { padding: 18px; }

/* Stat tile */
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 3px;
  transition: all var(--med);
  cursor: pointer;
  position: relative; overflow: hidden;
}
.stat:hover { border-color: var(--red); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-value {
  font-family: var(--font-display); font-weight: 700;
  font-size: 1.85rem; letter-spacing: -0.04em; line-height: 1;
  color: var(--ink);
}
.stat-label {
  font-size: 0.74rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--ink-mute);
}
.stat-icon {
  position: absolute; right: 14px; top: 14px;
  width: 18px; height: 18px; color: var(--ink-faint); opacity: 0.55;
}
.stat.alert { border-color: var(--warn); background: var(--warn-bg); }
.stat.alert .stat-value { color: var(--warn); }


/* ============================================================================
   BADGES & PILLS
   ========================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px;
  font-size: 0.72rem; font-weight: 700;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-mute);
  border: 1px solid var(--line);
  white-space: nowrap;
  line-height: 1.6;
}
.badge svg { width: 11px; height: 11px; }
.badge-red    { background: var(--red-mute);  color: var(--red);    border-color: transparent; }
.badge-ok     { background: var(--ok-bg);     color: var(--ok);     border-color: transparent; }
.badge-warn   { background: var(--warn-bg);   color: var(--warn);   border-color: transparent; }
.badge-danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.badge-info   { background: var(--info-bg);   color: var(--info);   border-color: transparent; }
.badge-solid  { background: var(--ink); color: var(--bg-pure); border-color: var(--ink); }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px;
  font-size: 0.74rem; font-weight: 500;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.tag button {
  border: none; background: none; cursor: pointer; padding: 0;
  color: var(--ink-faint); display: grid; place-items: center;
}
.tag button:hover { color: var(--danger); }

/* Avatar */
.avatar {
  width: 30px; height: 30px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 0.74rem;
  background: var(--surface-2); color: var(--ink-soft);
  border: 1px solid var(--line);
  overflow: hidden;
}
.avatar.red { background: linear-gradient(135deg, var(--red), var(--red-deep)); color: #fff; border-color: transparent; }
.avatar.lg { width: 44px; height: 44px; font-size: 1rem; }
.avatar.sm { width: 24px; height: 24px; font-size: 0.64rem; }
.avatar.xl { width: 76px; height: 76px; font-size: 1.7rem; }

/* A real photo replaces the initials; drop the tint so it isn't recoloured. */
.avatar.has-photo { background: var(--surface-2); }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Hover-to-change target, used in Settings and on the People page. */
/* .avatar-picker positioning lives with .logo-picker further up, so both
   pickers stay in one place. */


/* ============================================================================
   TABLES & LISTS
   ========================================================================== */
.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
}
.table-scroll { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table th {
  text-align: left;
  padding: 11px 14px;
  font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-mute);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-soft);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--fast); }
.table tbody tr:hover { background: var(--surface-hover); }
.table .num { font-family: var(--font-mono); text-align: right; }

/* List row — the workhorse for SOP/doc/sheet lists */
.list-row {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  transition: background var(--fast);
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--surface-hover); }
.list-row-icon {
  width: 34px; height: 34px; flex: none;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--red-mute); color: var(--red);
}
.list-row-icon svg { width: 17px; height: 17px; }
.list-row-title { font-weight: 600; color: var(--ink); font-size: 0.92rem; }
.list-row-meta { font-size: 0.78rem; color: var(--ink-mute); margin-top: 1px; }

/* The trailing affordance chevron — quieter than a functional icon. */
.list-row > svg { width: 15px; height: 15px; opacity: 0.7; }
.card-hover > .row > svg { width: 15px; height: 15px; opacity: 0.7; }

/* Contextual sizes where the 18px default reads wrong. */
.org-switch > svg { width: 15px; height: 15px; opacity: 0.7; }
.tag svg { width: 12px; height: 12px; }
.crumbs svg { width: 13px; height: 13px; }


/* ============================================================================
   TABS
   ========================================================================== */
.tabs {
  display: flex; gap: 3px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
  overflow-x: auto;
}
.tab {
  padding: 9px 15px;
  border: none; background: none;
  font-family: inherit; font-size: 0.87rem; font-weight: 600;
  color: var(--ink-mute); cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--fast);
  white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.on { color: var(--red); border-bottom-color: var(--red); }


/* ============================================================================
   MODALS
   ========================================================================== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10, 10, 18, 0.5);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: grid; place-items: center;
  padding: 20px;
  z-index: 200;
  animation: fade-in 160ms var(--ease);
  overflow-y: auto;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px;
  max-height: calc(100vh - 40px);
  display: flex; flex-direction: column;
  animation: modal-in 220ms var(--ease);
  margin: auto;
}
.modal.wide { max-width: 760px; }
.modal.xwide { max-width: 1000px; }

.modal-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.modal-head h3 { font-size: 1.1rem; }
.modal-head .sub { font-size: 0.82rem; color: var(--ink-mute); margin-top: 3px; }

.modal-body { padding: 20px 22px; overflow-y: auto; flex: 1; }

.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 9px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--line-soft);
  flex-wrap: wrap;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}


/* ============================================================================
   TOASTS
   ========================================================================== */
.toast-root {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 9px;
  z-index: 400; pointer-events: none;
  max-width: min(400px, calc(100vw - 40px));
}

.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ink-mute);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  font-size: 0.86rem;
  color: var(--ink);
  pointer-events: auto;
  animation: toast-in 240ms var(--ease);
}
.toast.out { animation: toast-out 180ms var(--ease) forwards; }
.toast svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.toast.ok     { border-left-color: var(--ok); }
.toast.ok svg { color: var(--ok); }
.toast.err     { border-left-color: var(--danger); }
.toast.err svg { color: var(--danger); }
.toast.warn     { border-left-color: var(--warn); }
.toast.warn svg { color: var(--warn); }
.toast.info     { border-left-color: var(--info); }
.toast.info svg { color: var(--info); }

@keyframes toast-in  { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }


/* ============================================================================
   EMPTY STATES
   ========================================================================== */
.empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px;
  padding: 56px 24px;
  text-align: center;
}
.empty-icon {
  width: 54px; height: 54px;
  border-radius: 16px;
  display: grid; place-items: center;
  background: var(--red-mute); color: var(--red);
  margin-bottom: 3px;
}
.empty-icon svg { width: 25px; height: 25px; stroke-width: 1.6; }
.empty h3 { font-size: 1.05rem; }
.empty p { font-size: 0.88rem; color: var(--ink-mute); max-width: 400px; }


/* ============================================================================
   MISC
   ========================================================================== */
.divider { height: 1px; background: var(--line); margin: 18px 0; }

.spinner {
  width: 17px; height: 17px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.62s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-hover) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }

.progress {
  height: 7px; background: var(--surface-2);
  border-radius: 999px; overflow: hidden;
  border: 1px solid var(--line-soft);
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--red), var(--red-bright));
  border-radius: 999px;
  transition: width 320ms var(--ease);
}

.callout {
  display: flex; gap: 11px;
  padding: 13px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 0.86rem;
  color: var(--ink-soft);
  line-height: 1.55;
}
.callout svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.callout.warn   { background: var(--warn-bg);   border-color: transparent; color: var(--ink); }
.callout.warn svg { color: var(--warn); }
.callout.danger { background: var(--danger-bg); border-color: transparent; color: var(--ink); }
.callout.danger svg { color: var(--danger); }
.callout.info   { background: var(--info-bg);   border-color: transparent; color: var(--ink); }
.callout.info svg { color: var(--info); }
.callout.ok     { background: var(--ok-bg);     border-color: transparent; color: var(--ink); }
.callout.ok svg { color: var(--ok); }

/* Dropdown menu */
.menu {
  position: absolute;
  min-width: 190px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  padding: 5px;
  z-index: 300;
  animation: modal-in 140ms var(--ease);
}
.menu-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: none; background: none;
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.86rem;
  color: var(--ink-soft); cursor: pointer;
  text-align: left;
  transition: all var(--fast);
}
.menu-item:hover { background: var(--surface-hover); color: var(--ink); }
.menu-item svg { width: 15px; height: 15px; flex: none; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-bg); }
.menu-sep { height: 1px; background: var(--line-soft); margin: 4px 0; }

/* Breadcrumb */
.crumbs {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 0.82rem; color: var(--ink-mute);
  margin-bottom: 10px;
}
.crumbs a { color: var(--ink-mute); }
.crumbs a:hover { color: var(--red); }
.crumbs .sep { color: var(--ink-faint); }

/* Theme toggle */
.theme-toggle {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  display: grid; place-items: center;
  cursor: pointer; color: var(--ink-soft);
  transition: all var(--fast);
  flex: none;
}
.theme-toggle:hover { border-color: var(--red); color: var(--red); transform: rotate(18deg); }
.theme-toggle svg { width: 16px; height: 16px; }

/* Sidebar toggle — mobile only */
.menu-toggle { display: none; }


/* ============================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-areas: "topbar" "main";
  }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: 264px;
    transform: translateX(-100%);
    transition: transform var(--med);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .menu-toggle { display: grid; }
  .main { padding: 18px 16px 70px; }
  .topbar { padding: 0 14px; }
  .search-trigger { min-width: 0; }
  .search-trigger .label-text, .search-trigger kbd { display: none; }
  .sidebar-scrim {
    position: fixed; inset: 0; background: rgba(10,10,18,0.45);
    z-index: 29; animation: fade-in 160ms var(--ease);
  }
}

@media (max-width: 560px) {
  .modal { max-width: 100%; border-radius: var(--radius-lg); }
  .page-head h1 { font-size: 1.35rem; }
  .toast-root { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}
