/* ==================================================================
   TrueAsset Razor — Design tokens + utilities
   Ported from the design prototype (TrueAsset App.html + TAShared.jsx)
   ================================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; }

/* ── Dark theme (default) ── */
[data-theme="dark"] {
  --bg:          #0d0d0f;
  --nav-bg:      #111113;
  --surface:     #18181b;
  --surface-hi:  #1f1f23;
  --border:      #2a2a2f;
  --border-hi:   #3a3a42;
  --text:        #e4e4e7;
  --text-2:      #8a8a96;
  --text-3:      #4a4a54;
  --on-accent:   #0b0d12;
}

/* ── Light theme ── */
[data-theme="light"] {
  --bg:          #f0f2f8;
  --nav-bg:      #ffffff;
  --surface:     #ffffff;
  --surface-hi:  #f4f6fc;
  --border:      #dde3f0;
  --border-hi:   #b0bcd8;
  --text:        #0f1623;
  --text-2:      #4a5570;
  --text-3:      #9ca8bf;
  --on-accent:   #ffffff;
}

:root {
  --accent:  #f59032;
  --success: #34d399;
  --danger:  #f87171;
  --warning: #fbbf24;
  --info:    #38bdf8;
  --purple:  #a78bfa;
}

body {
  font-family: 'IBM Plex Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 3px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes drawerIn {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ── App shell ─────────────────────────────────────────────────── */
.app-shell { display: flex; width: 100%; height: 100vh; overflow: hidden; }
.app-main  { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.app-page  { flex: 1; overflow-y: auto; padding: 28px 32px; width: 100%; }

/* Mobile nav drawer: hamburger toggle (topbar) + backdrop, hidden on desktop. */
.ta-topbar-hamburger {
  display: none; background: none; border: none; color: var(--text-2);
  cursor: pointer; padding: 4px 7px; font-size: 18px; line-height: 1;
  border-radius: 6px; align-items: center;
}
.ta-topbar-hamburger:hover { color: var(--text); background: var(--surface-hi); }
.ta-sidebar-backdrop { display: none; position: fixed; inset: 0; z-index: 150; background: rgba(0,0,0,0.5); }
.ta-sidebar-backdrop.show { display: block; }

/* ── Sidebar ──────────────────────────────────────────────────── */
.ta-nav {
  width: 220px; min-width: 220px; height: 100vh;
  background: var(--nav-bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: width 0.2s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden; flex-shrink: 0; position: relative; z-index: 100;
}
.ta-nav.collapsed { width: 56px; min-width: 56px; }

.ta-nav-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 14px; border-bottom: 1px solid var(--border);
  min-height: 56px;
}
.ta-nav.collapsed .ta-nav-logo {
  flex-direction: column; padding: 12px 0; gap: 8px; justify-content: center;
}
.ta-nav-logo-mark {
  width: 28px; height: 28px; border-radius: 6px; background: var(--accent);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  font-family: 'IBM Plex Mono', monospace; font-size: 14px; font-weight: 800; color: #0b0d12;
}
.ta-nav-logo-text { min-width: 0; }
.ta-nav.collapsed .ta-nav-logo-text { display: none; }
.ta-nav-logo-name { font-weight: 700; font-size: 14px; color: var(--text); letter-spacing: -0.01em; }
.ta-nav-logo-sub  { font-size: 10px; color: var(--accent); font-family: 'IBM Plex Mono', monospace; letter-spacing: 0.06em; }

.ta-nav-collapse-btn {
  margin-left: auto; background: transparent; border: none; cursor: pointer;
  color: var(--text-3); padding: 4px; display: flex; align-items: center;
  justify-content: center; font-family: inherit; border-radius: 4px;
}
.ta-nav-collapse-btn:hover { color: var(--text); background: var(--surface-hi); }
.ta-nav-collapse-btn i { font-size: 14px; transition: transform 0.2s; }
.ta-nav.collapsed .ta-nav-collapse-btn { margin-left: 0; }
.ta-nav.collapsed .ta-nav-collapse-btn i { transform: rotate(180deg); }

.ta-nav-list { flex: 1; overflow-y: auto; padding: 8px 0; overflow-x: hidden; }
.ta-nav-section {
  padding: 12px 16px 4px; font-size: 9px; font-weight: 700;
  letter-spacing: 0.12em; color: var(--text-3); text-transform: uppercase;
}
.ta-nav.collapsed .ta-nav-section { display: none; }
.ta-nav.collapsed .ta-nav-section-spacer { height: 8px; }

.ta-nav-item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; background: transparent; border: none; cursor: pointer;
  text-decoration: none; transition: background 0.12s;
  border-left: 2px solid transparent; color: var(--text-2);
  font-family: inherit; font-size: 13px;
}
.ta-nav.collapsed .ta-nav-item { padding: 9px 0; justify-content: center; }
.ta-nav-item:hover { background: var(--surface-hi); color: var(--text); }
.ta-nav-item.active {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
  border-left: 2px solid var(--accent);
  font-weight: 600;
}
.ta-nav-item-icon { font-size: 16px; width: 16px; text-align: center; flex-shrink: 0; }
.ta-nav-item-label { flex: 1; text-align: left; white-space: nowrap; }
.ta-nav.collapsed .ta-nav-item-label,
.ta-nav.collapsed .ta-nav-item-badge { display: none; }
.ta-nav-item-badge {
  font-size: 10px; background: var(--accent); color: #0b0d12;
  border-radius: 10px; padding: 1px 6px; font-weight: 700;
  font-family: 'IBM Plex Mono', monospace;
}
.ta-nav-item-badge.danger { background: var(--danger); }

.ta-nav-bottom { border-top: 1px solid var(--border); padding: 10px 14px; }
.ta-nav.collapsed .ta-nav-bottom { padding: 10px 0; }
.ta-nav-bottom-btn {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 0;
  background: transparent; border: none; cursor: pointer; color: var(--text-3);
  font-size: 12px; margin-bottom: 4px; font-family: inherit; text-decoration: none;
}
.ta-nav.collapsed .ta-nav-bottom-btn { justify-content: center; }
.ta-nav.collapsed .ta-nav-bottom-btn-label { display: none; }
.ta-nav-bottom-btn:hover { color: var(--text); }

.ta-nav-user {
  position: relative;
}
.ta-nav-user-btn {
  width: 100%; display: flex; align-items: center; gap: 10px;
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  padding: 6px; cursor: pointer; transition: all 0.12s; font-family: inherit;
  color: var(--text);
}
.ta-nav.collapsed .ta-nav-user-btn { justify-content: center; }
.ta-nav-user-btn:hover, .ta-nav-user-btn.open {
  background: var(--surface-hi); border-color: var(--border);
}
.ta-nav-user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: #1e2a4a; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; border: 2px solid color-mix(in srgb, var(--accent) 27%, transparent);
  font-size: 12px; font-weight: 700; color: var(--accent);
}
.ta-nav-user-meta { overflow: hidden; text-align: left; flex: 1; }
.ta-nav.collapsed .ta-nav-user-meta { display: none; }
.ta-nav.collapsed .ta-nav-user-chevron { display: none; }
.ta-nav-user-name { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ta-nav-user-role { font-size: 10px; color: var(--text-3); white-space: nowrap; }

.ta-nav-user-popover {
  position: absolute; bottom: calc(100% + 8px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5); z-index: 200; overflow: hidden;
}
.ta-nav-user-popover-header { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.ta-nav-user-popover-name { font-size: 13px; font-weight: 600; color: var(--text); }
.ta-nav-user-popover-email { font-size: 11px; color: var(--text-3); font-family: 'IBM Plex Mono', monospace; margin-top: 2px; }
.ta-nav-user-popover-item {
  width: 100%; display: flex; align-items: center; gap: 9px; padding: 10px 14px;
  background: transparent; border: none; cursor: pointer; color: var(--text-2);
  font-size: 13px; font-family: inherit; text-align: left; transition: background 0.1s;
  text-decoration: none;
}
.ta-nav-user-popover-item:hover { background: var(--surface-hi); color: var(--text); }
.ta-nav-user-popover-item.danger { color: var(--danger); border-top: 1px solid var(--border); }
.ta-nav-user-popover-item.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }

/* ── Topbar ──────────────────────────────────────────────────── */
.ta-topbar {
  height: 48px; border-bottom: 1px solid var(--border); background: var(--nav-bg);
  display: flex; align-items: center; padding: 0 20px; gap: 12px; flex-shrink: 0;
}
.ta-topbar-crumb { font-size: 13px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.ta-topbar-crumb-cur { color: var(--text-2); font-weight: 500; text-transform: capitalize; }
.ta-topbar-spacer { flex: 1; }
.ta-topbar-search { position: relative; width: 300px; }
.ta-topbar-search-icon { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; display: flex; }
.ta-topbar-search input {
  background: var(--surface); border: 1px solid var(--border); border-radius: 5px;
  padding: 5px 10px 5px 26px; color: var(--text); font-size: 12px; outline: none; width: 100%;
  font-family: 'IBM Plex Sans', sans-serif;
}
.ta-topbar-search input:focus { border-color: var(--border-hi); }

/* ── Global search typeahead dropdown ────────────────────────── */
.ta-search-results {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 300;
  width: 340px; max-width: calc(100vw - 24px); max-height: 420px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.45);
  padding: 4px 0; animation: msOpen 0.12s ease;
}
.ta-search-results.hidden { display: none; }
.ta-search-group-label {
  padding: 8px 14px 4px; font-size: 10px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.ta-search-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; text-decoration: none; color: var(--text);
  cursor: pointer; border: none; background: none; width: 100%; text-align: left;
  font-family: inherit;
}
.ta-search-item.no-link { cursor: default; }
.ta-search-item:hover, .ta-search-item.active { background: var(--surface-hi); }
.ta-search-item-icon {
  width: 26px; height: 26px; flex-shrink: 0; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-hi); color: var(--text-2); font-size: 12px;
}
.ta-search-item.active .ta-search-item-icon { background: var(--bg); }
.ta-search-item-body { min-width: 0; flex: 1; }
.ta-search-item-title {
  font-size: 13px; color: var(--text); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ta-search-item-sub {
  font-size: 11px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ta-search-empty, .ta-search-hint {
  padding: 20px 14px; text-align: center; color: var(--text-3); font-size: 12px;
}
.ta-topbar-bell {
  position: relative; background: none; border: none; cursor: pointer;
  color: var(--text-2); padding: 4px; display: flex;
}
.ta-topbar-bell:hover { color: var(--text); }
.ta-topbar-bell-dot {
  position: absolute; top: 1px; right: 1px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--danger); border: 2px solid var(--nav-bg);
}
.ta-topbar-bell-badge {
  position: absolute; top: -4px; right: -6px;
  min-width: 13px; height: 13px; padding: 0 3px;
  border-radius: 7px; background: var(--danger); color: #fff;
  font-size: 9px; font-weight: 700; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--nav-bg); box-sizing: content-box;
  font-family: 'IBM Plex Sans', sans-serif;
}

/* ── Notifications popover ───────────────────────────────────── */
.ta-notif { position: relative; display: inline-block; }
.ta-notif-popover {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 200;
  width: 360px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.45);
  animation: msOpen 0.12s ease;
}
.ta-notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.ta-notif-title {
  font-size: 11px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.ta-notif-mark-all {
  background: none; border: none; color: var(--accent);
  font-size: 11px; font-weight: 500; cursor: pointer; padding: 2px 4px;
  font-family: inherit;
}
.ta-notif-mark-all:hover { text-decoration: underline; }
.ta-notif-list { max-height: 380px; overflow-y: auto; padding: 4px 0; }
.ta-notif-empty {
  padding: 28px 14px; text-align: center;
  color: var(--text-3); font-size: 13px;
}
.ta-notif-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 14px; text-decoration: none; color: var(--text);
  border-bottom: 1px solid var(--border);
}
.ta-notif-item:last-child { border-bottom: none; }
.ta-notif-item:hover { background: var(--surface-hi); }
.ta-notif-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-3); margin-top: 6px; flex-shrink: 0;
}
.ta-notif-sev-danger  { background: var(--danger); }
.ta-notif-sev-warning { background: var(--warning); }
.ta-notif-sev-info    { background: var(--info); }
.ta-notif-sev-success { background: var(--success); }
.ta-notif-sev-muted   { background: var(--text-3); }
.ta-notif-body {
  display: flex; flex-direction: column; gap: 2px;
  flex: 1; min-width: 0;
}
.ta-notif-line {
  font-size: 13px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ta-notif-sub {
  font-size: 11px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ta-notif-time {
  font-size: 11px; color: var(--text-3); white-space: nowrap;
  font-family: 'IBM Plex Mono', monospace;
}
.ta-notif-item.is-read .ta-notif-dot { visibility: hidden; }
.ta-notif-item.is-read .ta-notif-line { font-weight: 400; color: var(--text-2); }
.ta-notif-footer {
  display: block; padding: 10px; text-align: center;
  border-top: 1px solid var(--border);
  font-size: 12px; font-weight: 500; color: var(--accent);
  text-decoration: none;
}
.ta-notif-footer:hover { background: var(--surface-hi); }

/* /Notifications full page */
.ta-notif-page {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden;
}
.ta-notif-page .ta-notif-item { padding: 14px 18px; }
.ta-notif-page .ta-notif-line { font-size: 14px; }
.ta-notif-page .ta-notif-sub { font-size: 12px; }
.ta-notif-row {
  display: flex; align-items: stretch;
  border-bottom: 1px solid var(--border);
}
.ta-notif-row:last-child { border-bottom: none; }
.ta-notif-row .ta-notif-item { flex: 1; border-bottom: none; min-width: 0; }
.ta-notif-del {
  background: none; border: none; color: var(--text-3);
  cursor: pointer; padding: 0 16px; font-size: 14px; flex-shrink: 0;
}
.ta-notif-del:hover { color: var(--danger); background: var(--surface-hi); }
/* ── Toolbar row ──────────────────────────────────────────────────
   List-page control strip: search + filters on the left, action buttons
   (secondary actions then the primary CTA) pushed to the right. Wraps
   gracefully on narrow widths. Page titles were removed in favour of the
   topbar breadcrumb, so these rows replace the old .ta-page-header. */
.ta-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.ta-toolbar > form { margin: 0; min-width: 0; }
.ta-toolbar-filters { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ta-toolbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
/* Actions grouped to the right of a tab bar (Maintenance, Reports, admin pages). */
.ta-tabs-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; align-self: center; padding-bottom: 6px; }
/* Ensure the hidden attribute wins over display rules on tab panels. */
[hidden] { display: none !important; }

.ta-section-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}
.ta-section-header-title {
  font-size: 12px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-3);
}

/* ── Buttons ──────────────────────────────────────────────────── */
.ta-btn {
  display: inline-flex; align-items: center; gap: 6px; border: none;
  cursor: pointer; font-family: 'IBM Plex Sans', sans-serif; font-weight: 500;
  transition: all 0.15s; border-radius: 5px; text-decoration: none;
  padding: 7px 14px; font-size: 13px;
}
.ta-btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.ta-btn-sm { padding: 4px 10px; font-size: 12px; }
.ta-btn-lg { padding: 10px 20px; font-size: 14px; }
.ta-btn-primary { background: var(--accent); color: #0b0d12; }
.ta-btn-primary:hover { background: #e07d20; }
.ta-btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.ta-btn-secondary:hover { background: var(--surface-hi); }
.ta-btn-ghost { background: transparent; color: var(--text-2); }
.ta-btn-ghost:hover { background: var(--surface-hi); color: var(--text); }
.ta-btn-danger {
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 27%, transparent);
}
.ta-btn-danger:hover { background: #dc2626; color: #fff; }

/* ── Status badge ─────────────────────────────────────────────── */
.ta-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  white-space: nowrap; font-family: 'IBM Plex Mono', monospace;
}
.ta-badge-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

/* ── Cards ────────────────────────────────────────────────────── */
.ta-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 18px 20px;
}
.ta-card-clickable { cursor: pointer; transition: border-color 0.15s, transform 0.15s; text-decoration: none; color: inherit; }
.ta-card-clickable:hover { transform: translateY(-1px); }
.ta-card-clickable:visited, .ta-card-clickable:focus, .ta-card-clickable:active { color: inherit; text-decoration: none; }

.ta-stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 18px 20px; }
.ta-stat-label { color: var(--text-2); font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 8px; }
.ta-stat-value { color: var(--text); font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.ta-stat-sub   { color: var(--text-3); font-size: 11px; margin-top: 5px; }

.ta-grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 24px; }

/* Dashboard main + sidebar column; collapses to one column on narrow screens (see media queries). */
.ta-dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; }

/* Two-up report cards; collapses to one column on narrow screens (see media queries). */
.ta-reports-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Settings API-key form (name / expiry / button); stacks on narrow screens (see media queries). */
.ta-apikey-form { display: grid; grid-template-columns: 1.3fr 0.8fr auto; gap: 8px; align-items: end; }

/* ── Tables ──────────────────────────────────────────────────── */
.ta-table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.ta-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ta-table thead th {
  padding: 10px 14px; text-align: left; color: var(--text-3);
  font-size: 11px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase;
  border-bottom: 1px solid var(--border); white-space: nowrap;
  background: var(--surface);
}
.ta-table tbody td {
  padding: 11px 14px; color: var(--text); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.ta-table tbody tr { transition: background 0.1s; }
.ta-table tbody tr.hover-row { cursor: pointer; }
.ta-table tbody tr.hover-row:hover { background: var(--surface-hi); }
.ta-table tbody tr:last-child td { border-bottom: none; }
.ta-table-empty { padding: 32px; text-align: center; color: var(--text-3); }
.ta-table-footer {
  padding: 10px 14px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-3);
  display: flex; justify-content: space-between; align-items: center;
}

/* ── Filter pills ─────────────────────────────────────────────── */
.ta-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.ta-pill {
  padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 500;
  background: var(--surface); color: var(--text-2);
  border: 1px solid var(--border); cursor: pointer; transition: all 0.12s;
  font-family: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 5px;
}
.ta-pill:hover { background: var(--surface-hi); color: var(--text); }
.ta-pill.active { background: var(--accent); color: #0b0d12; border-color: var(--accent); }

/* ── Multi-select filter dropdown ────────────────────────────── */
.ta-multiselect { position: relative; display: inline-block; }
.ta-multiselect-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface-hi); color: var(--text);
  border: 1px solid var(--border); border-radius: 5px;
  padding: 8px 10px; font-size: 13px; line-height: 1;
  font-family: 'IBM Plex Sans', sans-serif; cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  min-width: 150px; white-space: nowrap;
}
.ta-multiselect-trigger:hover { border-color: var(--text-3); }
.ta-multiselect-trigger[aria-expanded="true"] { border-color: var(--accent); }
.ta-multiselect-trigger.has-selection { border-color: var(--accent); }
.ta-multiselect-label { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; }
.ta-multiselect-chevron { font-size: 11px; color: var(--text-3); transition: transform 0.15s; }
.ta-multiselect-trigger[aria-expanded="true"] .ta-multiselect-chevron { transform: rotate(180deg); }

.ta-multiselect-popover {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 100;
  min-width: 100%; max-width: 280px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  animation: msOpen 0.12s ease;
}
@keyframes msOpen { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: translateY(0); } }
.ta-multiselect-popover-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.ta-multiselect-popover-title { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.ta-multiselect-clear {
  background: none; border: none; color: var(--accent);
  font-size: 11px; font-weight: 500; cursor: pointer; padding: 2px 4px;
  font-family: inherit;
}
.ta-multiselect-clear:hover { text-decoration: underline; }
.ta-multiselect-popover-body { max-height: 260px; overflow-y: auto; padding: 4px 0; }
.ta-multiselect-option {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; font-size: 13px; color: var(--text);
  cursor: pointer; user-select: none;
}
.ta-multiselect-option:hover { background: var(--surface-hi); }
.ta-multiselect-option input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }

/* ── Form controls ────────────────────────────────────────────── */
.ta-input, .ta-select, .ta-textarea {
  width: 100%; background: var(--surface-hi);
  border: 1px solid var(--border); border-radius: 5px;
  padding: 8px 10px; color: var(--text); font-size: 13px;
  outline: none; box-sizing: border-box;
  font-family: 'IBM Plex Sans', sans-serif;
}
.ta-input:focus, .ta-select:focus, .ta-textarea:focus { border-color: var(--accent); }
.ta-input.mono { font-family: 'IBM Plex Mono', monospace; }
.ta-textarea { resize: vertical; min-height: 80px; font-family: inherit; }
.ta-label { font-size: 12px; font-weight: 500; color: var(--text-2); margin-bottom: 5px; display: block; }
/* Mark labels of required fields with a red asterisk, driven by the control's `required` attribute */
.ta-label:has(+ input[required])::after,
.ta-label:has(+ select[required])::after,
.ta-label:has(+ textarea[required])::after { content: " *"; color: var(--danger); font-weight: 600; }

.ta-search-bar { position: relative; width: 100%; }
.ta-search-bar input {
  background: var(--surface); border: 1px solid var(--border); border-radius: 5px;
  padding: 7px 10px 7px 28px; color: var(--text); font-size: 13px; outline: none;
  width: 100%; font-family: 'IBM Plex Sans', sans-serif;
}
.ta-search-bar-icon {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); pointer-events: none; display: flex;
}

/* ── Modal ────────────────────────────────────────────────────── */
.ta-modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65); z-index: 9000;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; backdrop-filter: blur(2px);
}
.ta-modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  width: 680px; max-width: 100%; max-height: calc(100vh - 80px); overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6); animation: modalIn 0.18s ease;
}
.ta-modal.lg { width: 860px; }
.ta-modal.sm { width: 460px; }
.ta-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.ta-modal-title { font-weight: 600; font-size: 15px; color: var(--text); }
.ta-modal-close { background: none; border: none; color: var(--text-3); cursor: pointer; padding: 2px; line-height: 1; display: flex; }
.ta-modal-close:hover { color: var(--text); }
.ta-modal-body { padding: 20px; }
.ta-modal-footer {
  padding: 16px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
  position: sticky; bottom: 0; background: var(--surface);
}

/* ── Alerts ───────────────────────────────────────────────────── */
.ta-alert {
  padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; color: var(--text); background: var(--surface);
}
.ta-alert-danger { border-color: var(--danger); color: var(--danger); background: rgba(239,68,68,0.08); }
.ta-alert-success { border-color: var(--success); color: var(--success); background: rgba(34,197,94,0.08); }

/* ── Drawer ───────────────────────────────────────────────────── */
.ta-drawer-host:empty { display: none; }
.ta-drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 8000;
}
.ta-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 600px; max-width: 100%;
  background: var(--bg); border-left: 1px solid var(--border);
  z-index: 8100; display: flex; flex-direction: column;
  box-shadow: -16px 0 40px rgba(0,0,0,0.4);
  animation: drawerIn 0.22s cubic-bezier(0.4,0,0.2,1);
}
/* Re-renders of an already-open drawer skip the slide-in so there's no flicker. */
.ta-drawer-noanim { animation: none !important; }
.ta-drawer.lg { width: 680px; }
.ta-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.ta-drawer-title { font-weight: 600; font-size: 15px; color: var(--text); }
.ta-drawer-actions { display: flex; align-items: center; gap: 8px; }
.ta-drawer-close { background: none; border: none; color: var(--text-3); cursor: pointer; padding: 2px; line-height: 1; display: flex; }
.ta-drawer-close:hover { color: var(--text); }
.ta-drawer-body { padding: 20px; flex: 1; overflow-y: auto; }
.ta-drawer-footer {
  padding: 16px 20px; border-top: 1px solid var(--border); flex-shrink: 0;
  display: flex; justify-content: flex-end; gap: 8px; background: var(--bg);
}
.ta-drawer-tabs { display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0; padding: 0 20px; gap: 0; }
.ta-drawer-tab {
  padding: 10px 14px; font-size: 12px; background: transparent; border: none;
  cursor: pointer; color: var(--text-2); border-bottom: 2px solid transparent;
  margin-bottom: -1px; font-family: inherit;
  white-space: nowrap; flex-shrink: 0;
}
.ta-drawer-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.ta-drawer-tab:hover { color: var(--text); }

.ta-detail-row {
  display: grid; grid-template-columns: 140px 1fr; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.ta-detail-row:last-child { border-bottom: none; }
.ta-detail-row-label { color: var(--text-3); font-size: 12px; font-weight: 500; }
.ta-detail-row-value { color: var(--text); font-size: 13px; word-break: break-all; }
.ta-detail-row-value.mono { font-family: 'IBM Plex Mono', monospace; }

/* ── Tabs ─────────────────────────────────────────────────────── */
.ta-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 18px; gap: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ta-tab {
  padding: 10px 18px; font-size: 12px; background: transparent; border: none;
  cursor: pointer; color: var(--text-2); border-bottom: 2px solid transparent;
  margin-bottom: -1px; font-family: inherit; text-decoration: none;
  white-space: nowrap; flex-shrink: 0;
}
.ta-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.ta-tab:hover { color: var(--text); text-decoration: none; }
.ta-tab:visited, .ta-tab:focus, .ta-tab:active { color: inherit; text-decoration: none; }
.ta-tab.active:visited { color: var(--accent); }

/* ── Progress bar ─────────────────────────────────────────────── */
.ta-progress { display: flex; align-items: center; gap: 8px; }
.ta-progress-track { flex: 1; height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; min-width: 60px; }
.ta-progress-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }
.ta-progress-pct { font-size: 11px; font-family: 'IBM Plex Mono', monospace; color: var(--text-3); min-width: 30px; text-align: right; }

/* ── Mono helpers ─────────────────────────────────────────────── */
.mono { font-family: 'IBM Plex Mono', monospace; }
.muted { color: var(--text-3); }
.muted-2 { color: var(--text-2); }

/* ── Misc utility ─────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-20 { gap: 20px; } .gap-24 { gap: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; } .mb-20 { margin-bottom: 20px; } .mb-24 { margin-bottom: 24px; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; }
.text-xs { font-size: 11px; } .text-sm { font-size: 12px; } .text-base { font-size: 13px; } .text-md { font-size: 14px; } .text-lg { font-size: 16px; }
.fw-500 { font-weight: 500; } .fw-600 { font-weight: 600; } .fw-700 { font-weight: 700; }

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-flex; }
.htmx-request.htmx-indicator { display: inline-flex; }

/* SVG icon span */
.icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* Two-column module layout used in Settings, Drawer details etc */
.ta-two-col { display: grid; grid-template-columns: 200px 1fr; gap: 0; min-height: calc(100vh - 200px); }
.ta-two-col-side { border-right: 1px solid var(--border); padding-right: 0; }
.ta-two-col-side .ta-side-item {
  display: block; width: 100%; padding: 9px 14px; font-size: 13px;
  background: transparent; border: none; cursor: pointer; color: var(--text-2);
  text-align: left; font-family: inherit; border-left: 2px solid transparent;
  text-decoration: none;
}
.ta-two-col-side .ta-side-item:hover { background: var(--surface-hi); color: var(--text); }
.ta-two-col-side .ta-side-item.active {
  color: var(--accent); border-left-color: var(--accent); font-weight: 600;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.ta-two-col-content { padding: 0 0 0 24px; }

/* ── Auth pages ───────────────────────────────────────────────── */
.ta-auth { width: 100%; height: 100vh; display: flex; overflow: hidden; background: var(--bg); }
.ta-auth-brand {
  flex: 0 0 44%; position: relative; overflow: hidden;
  background: linear-gradient(155deg, #18181b 0%, #0d0d0f 60%, #1a1410 100%);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 40px 48px;
}
.ta-auth-brand-grid {
  position: absolute; inset: 0;
  background-image: linear-gradient(var(--border) 1px, transparent 1px),
                    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 40px 40px; opacity: 0.25;
  -webkit-mask-image: radial-gradient(ellipse at top right, black 30%, transparent 75%);
          mask-image: radial-gradient(ellipse at top right, black 30%, transparent 75%);
}
.ta-auth-brand-glow {
  position: absolute; top: -150px; right: -150px;
  width: 400px; height: 400px; border-radius: 50%;
  background: radial-gradient(circle, rgba(245,144,50,0.18) 0%, transparent 70%);
}
.ta-auth-form { flex: 1; display: flex; flex-direction: column; overflow-y: auto; position: relative; }
.ta-auth-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; }
.ta-auth-divider::before, .ta-auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.ta-auth-divider span { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.1em; }

.ta-auth-input {
  width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; color: var(--text); font-size: 13.5px; outline: none; box-sizing: border-box;
  font-family: 'IBM Plex Sans', sans-serif; transition: border-color 0.15s;
}
.ta-auth-input:focus { border-color: var(--accent); }

.ta-auth-primary {
  width: 100%; padding: 11px 16px; border-radius: 6px;
  background: var(--accent); border: 1px solid var(--accent); color: #0d0d0f;
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  font-family: 'IBM Plex Sans', sans-serif; transition: background 0.15s;
}
.ta-auth-primary:hover { background: #fb923c; }
.ta-auth-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.ta-auth-secondary {
  width: 100%; padding: 10px 14px; border-radius: 6px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  font-size: 13px; font-weight: 500; cursor: pointer;
  font-family: 'IBM Plex Sans', sans-serif;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  transition: all 0.15s;
}
.ta-auth-secondary:hover { background: var(--surface-hi); border-color: var(--border-hi); }

.ta-auth-step {
  display: flex; align-items: center; gap: 8px;
}
.ta-auth-step-dot {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface-hi); color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; font-family: 'IBM Plex Mono', monospace;
  border: 1px solid var(--border);
}
.ta-auth-step.active .ta-auth-step-dot { background: var(--accent); color: #0d0d0f; border-color: var(--accent); }
.ta-auth-step.done .ta-auth-step-dot { background: var(--accent); color: #0d0d0f; border-color: var(--accent); }
.ta-auth-step-line { flex: 1; height: 1px; background: var(--border); }
.ta-auth-step-line.done { background: var(--accent); }

/* Auth pages on mobile: hide the decorative brand panel, let the form fill
   the screen and scroll, and enlarge inputs (16px avoids iOS focus zoom). */
@media (max-width: 768px) {
  .ta-auth { height: auto; min-height: 100vh; min-height: 100dvh; overflow-y: auto; }
  .ta-auth-brand { display: none; }
  .ta-auth-form > div { padding-left: 20px !important; padding-right: 20px !important; }
  .ta-auth-input { font-size: 16px; padding: 12px 14px; }
  .ta-auth-primary { padding: 13px 16px; font-size: 15px; }
}

/* ── Impersonation banner ───────────────────────────────────────── */
.ta-impersonation-banner {
  position: relative; padding: 8px 20px;
  background: linear-gradient(90deg, rgba(245,144,50,0.18), rgba(245,144,50,0.08));
  border-bottom: 1px solid var(--accent);
  display: flex; align-items: center; gap: 12px;
  font-size: 12.5px; color: var(--accent); font-weight: 500;
}
.ta-impersonation-banner strong { color: var(--text); font-weight: 600; }
.ta-impersonation-banner-pulse {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 8px var(--accent); animation: pulse 1.4s infinite;
}

/* ── Admin chip variants ────────────────────────────────────────── */
.ta-chip-plan-enterprise { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); }
.ta-chip-plan-business   { color: #818cf8; background: rgba(99,102,241,0.12); border: 1px solid rgba(99,102,241,0.3); }
.ta-chip-plan-starter    { color: var(--text-2); background: rgba(120,120,128,0.15); border: 1px solid var(--border-hi); }
.ta-chip-plan-education  { color: var(--success); background: rgba(34,197,94,0.10); border: 1px solid rgba(34,197,94,0.3); }

/* Toggle switch */
.ta-toggle {
  width: 40px; height: 22px; border-radius: 11px; background: var(--border);
  border: none; cursor: pointer; position: relative; transition: background 0.2s; flex-shrink: 0;
  padding: 0;
}
.ta-toggle.on { background: var(--accent); }
.ta-toggle::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: var(--text-3);
  transition: left 0.2s;
}
.ta-toggle.on::after { left: 20px; background: #0b0d12; }

/* ── Workspace shell (Infrastructure + Network pages) ─────────── */
/* Three-column, full-height workspace: left list, center pane, right panel.
   Center pane is widened (two rack elevations render side by side), so the
   flanking list/right columns are trimmed to give the pair more room. */
.rack-workspace {
  display: grid;
  grid-template-columns: 200px minmax(520px, 1fr) 300px;
  gap: 14px;
  /* Full height: viewport minus the 48px topbar and the app-page 28px paddings. */
  height: calc(100vh - 104px);
  min-height: 480px;
}
@media (max-width: 1100px) {
  .rack-workspace { grid-template-columns: 200px 1fr; }
  .rack-right { grid-column: 1 / -1; height: auto; }
}
/* Phones: stack the workspace into a single column and let the page scroll.
   The center pane keeps a viewport-based height so the rack/diagram canvas
   still scrolls internally instead of collapsing. */
@media (max-width: 768px) {
  .rack-workspace {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }
  .rack-list { max-height: 40vh; }
  .rack-pane { height: 70vh; }
  .rack-right { height: auto; }
}

.rack-list,
.rack-pane,
.rack-right {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.rack-list-header,
.rack-pane-header,
.rack-right-tabs {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  flex-shrink: 0;
}
.rack-list-items { flex: 1; overflow-y: auto; padding: 6px 0; }
.rack-list-item {
  width: 100%; text-align: left; background: transparent;
  border: none; border-left: 2px solid transparent;
  border-radius: 0; padding: 9px 14px; cursor: pointer;
  color: var(--text-2);
  display: flex; align-items: center; gap: 10px;
  font-family: inherit; font-size: 13px;
  transition: background 0.12s, color 0.12s;
}
a.rack-list-item { text-decoration: none; }
.rack-list-item:hover { background: var(--surface-hi); color: var(--text); }
.rack-list-item.active {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}
.rack-list-item-icon {
  font-size: 14px; width: 16px; text-align: center; flex-shrink: 0;
  color: var(--text-3);
}
.rack-list-item:hover .rack-list-item-icon { color: var(--text-2); }
.rack-list-item.active .rack-list-item-icon { color: var(--accent); }
.rack-list-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rack-list-name {
  font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rack-list-sub {
  font-size: 11px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rack-list-item.active .rack-list-sub { color: color-mix(in srgb, var(--accent) 70%, var(--text-3)); }
.rack-list-pct {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px; font-weight: 600;
  flex-shrink: 0; color: var(--text-3);
}
.rack-list-pct.ok { color: var(--success); }
.rack-list-pct.warning { color: var(--warning); }
.rack-list-pct.danger { color: var(--danger); }

/* Rack pane */
.rack-pane-header {
  text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--text);
  display: flex; align-items: center; justify-content: space-between;
}
.rack-title { display: flex; flex-direction: column; gap: 2px; }
.rack-name { font-size: 14px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.rack-loc { font-size: 10px; color: var(--text-3); }

.rack-frame {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  background: #0a0d14;
  padding: 14px 10px;
}
[data-theme="light"] .rack-frame { background: #1a1f2e; }
.rack-grid {
  --rack-u-height: 26px;
  display: flex; flex-direction: column;
  border: 2px solid #2a3050;
  border-radius: 6px;
  background: #0a0d14;
  box-shadow: 0 0 30px rgba(0,0,0,0.6), inset 0 0 20px rgba(0,0,0,0.4);
  padding: 6px 4px;
  margin: 0 auto;
  max-width: 640px;
  min-width: 300px;
}
.rack-row {
  display: flex; align-items: stretch; gap: 4px;
  height: calc(var(--rack-u-height) * var(--u-size, 1));
  margin-bottom: 1px;
}
.rack-row-empty { height: var(--rack-u-height); }
.rack-row.drop-target .rack-slot-empty,
.rack-row.drop-target .rack-device-body { outline: 2px dashed var(--success); outline-offset: -2px; background: color-mix(in srgb, var(--success) 12%, transparent); }
.rack-row.drop-invalid .rack-slot-empty,
.rack-row.drop-invalid .rack-device-body { outline: 2px dashed var(--danger); outline-offset: -2px; }
.rack-row.dragging { opacity: 0.4; }
.rack-u-label {
  width: 24px; display: flex; align-items: center; justify-content: flex-end;
  font-size: 9px; color: #2a3a5a; flex-shrink: 0;
}
.rack-rail {
  width: 6px; background: #151c30; border: 1px solid #1e2a44;
  flex-shrink: 0;
}
.rack-rail.left { border-radius: 2px 0 0 2px; }
.rack-rail.right { border-radius: 0 2px 2px 0; }
.rack-slot-empty {
  flex: 1; background: #0e1220; border: 1px solid #131825; border-radius: 2px;
  display: flex; align-items: center; justify-content: stretch;
  padding: 0 8px;
}
.rack-slot-empty::after {
  content: ''; flex: 1; border-top: 1px dashed #1a2030;
}
.rack-device-body {
  flex: 1; background: var(--device-bg, #1a1a2a);
  border: 1px solid color-mix(in srgb, var(--device-bg, #1a1a2a) 60%, #ffffff 15%);
  border-radius: 2px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 10px; cursor: pointer; overflow: hidden;
  position: relative;
}
.rack-device-body:hover { filter: brightness(1.12); }
.rack-device-name {
  flex: 1; min-width: 0;
  font-size: 12px; font-weight: 600; color: var(--device-label, var(--text));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-align: left;
}
.rack-device-range {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: color-mix(in srgb, var(--device-label, var(--text)) 65%, transparent);
  margin-left: auto; padding-left: 8px;
  white-space: nowrap; flex-shrink: 0;
  text-align: right;
}
.rack-device-remove {
  background: transparent; border: none; color: var(--text-3); cursor: pointer;
  padding: 2px 4px; font-size: 12px; opacity: 0.55;
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
}
.rack-device-body:hover .rack-device-remove { opacity: 1; }
.rack-device-remove:hover { color: var(--danger); opacity: 1; }

.rack-row-device { cursor: grab; }
.rack-row-device:active { cursor: grabbing; }

.rack-legend {
  display: flex; flex-wrap: wrap; gap: 14px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  font-size: 10px; color: var(--text-3);
  background: var(--surface);
  flex-shrink: 0;
}
.rack-legend-item { display: flex; align-items: center; gap: 6px; }
.rack-legend-swatch {
  width: 10px; height: 10px; border-radius: 2px;
  border: 1px solid color-mix(in srgb, currentColor 30%, transparent);
  flex-shrink: 0;
}

.rack-footer {
  padding: 10px 14px; border-top: 1px solid var(--border);
  flex-shrink: 0; background: var(--surface);
}
.rack-progress { display: flex; align-items: center; gap: 10px; }
.rack-progress-track {
  flex: 1; height: 6px; background: var(--surface-hi);
  border-radius: 3px; overflow: hidden;
}
.rack-progress-fill { height: 100%; border-radius: 3px; transition: width 0.2s; }

.rack-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; padding: 40px; text-align: center;
}
.rack-empty-title { font-size: 16px; font-weight: 600; color: var(--text); }
.rack-empty-sub { font-size: 13px; color: var(--text-2); max-width: 320px; }

/* Right panel */
.rack-right-tabs {
  display: flex; gap: 0; padding: 0 4px;
  text-transform: none; letter-spacing: 0;
}
.rack-right-tab {
  background: transparent; border: none; border-bottom: 2px solid transparent;
  padding: 10px 12px; font-size: 12px; font-weight: 600; color: var(--text-2);
  cursor: pointer; font-family: inherit;
  display: flex; align-items: center; gap: 6px;
}
.rack-right-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.rack-right-tab:hover:not(.active) { color: var(--text); }
.rack-right-count {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  background: var(--surface-hi); padding: 1px 6px; border-radius: 8px;
  color: var(--text-3);
}
.rack-right-search { padding: 8px 10px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.rack-right-search .ta-input { width: 100%; }
.rack-right-panels { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.rack-right-panel { display: none; flex: 1; overflow-y: auto; flex-direction: column; }
.rack-right-panel.active { display: flex; }
.rack-right-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.rack-right-card {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface-hi); cursor: pointer;
}
.rack-right-card:hover { border-color: var(--border-hi); }
.rack-right-card.in-this-rack { opacity: 0.6; }
.rack-right-card.draggable { cursor: grab; }
.rack-right-card.draggable:active { cursor: grabbing; }
.rack-right-card.dragging { opacity: 0.4; }
.rack-right-swatch { width: 4px; align-self: stretch; border-radius: 2px; flex-shrink: 0; }
.rack-right-text { flex: 1; min-width: 0; line-height: 1.2; }
.rack-right-name { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rack-right-meta { font-size: 10px; color: var(--text-3); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.rack-right-badge {
  font-family: 'IBM Plex Mono', monospace; font-size: 9px;
  padding: 1px 5px; border-radius: 3px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
}
.rack-grip { color: var(--text-3); font-size: 12px; flex-shrink: 0; }
.rack-right-empty { padding: 20px 14px; text-align: center; color: var(--text-3); font-size: 12px; }
.rack-add-by-tag {
  padding: 8px 10px; border-top: 1px solid var(--border);
  display: flex; gap: 6px; flex-shrink: 0; background: var(--surface);
}
.rack-add-by-tag .ta-input { flex: 1; }

/* Toast */
.rack-toast {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--surface); border: 1px solid var(--border-hi);
  color: var(--text); padding: 10px 14px; border-radius: 6px;
  font-size: 12px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  z-index: 1000; opacity: 0; transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}
.rack-toast.show { opacity: 1; transform: translateY(0); }
.rack-toast.ok { border-color: var(--success); }
.rack-toast.err { border-color: var(--danger); color: var(--danger); }

/* ── Mobile nav drawer ────────────────────────────────────────── */
/* Kept at the end of the file so these overrides win over the base
   .ta-nav / .ta-topbar / .ta-nav-collapse-btn rules defined above. */
@media (max-width: 768px) {
  .ta-topbar-hamburger { display: inline-flex; }
  .ta-topbar { padding: 0 14px; }
  .ta-topbar-search { display: none; }
  .app-page { padding: 18px 16px; }
  .ta-nav {
    position: fixed; top: 0; left: 0; height: 100vh; height: 100dvh;
    width: 248px; min-width: 248px; z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.22s cubic-bezier(0.4,0,0.2,1);
  }
  .ta-nav.mobile-open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,0.5); }
  .ta-nav-collapse-btn { display: none; }
}

/* ── Responsive: dashboard & reports ──────────────────────────── */
/* Collapse multi-column page layouts before they get cramped. */
@media (max-width: 960px) {
  .ta-dashboard-grid { grid-template-columns: 1fr; }
  .ta-reports-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  /* Two-up stat cards instead of a long single column on phones. */
  .ta-grid-stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .ta-stat-card { padding: 14px 14px; }
  .ta-stat-value { font-size: 24px; }
  /* Keep calendar cells legible by scrolling rather than crushing 7 columns. */
  .ta-calendar-grid { min-width: 640px; }

  /* Settings: stack the tab rail above the content instead of a fixed side column. */
  .ta-two-col { grid-template-columns: 1fr; min-height: 0; }
  .ta-two-col-side {
    border-right: none; border-bottom: 1px solid var(--border);
    display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  .ta-two-col-side .ta-side-item {
    width: auto; white-space: nowrap; flex-shrink: 0;
    border-left: none; border-bottom: 2px solid transparent;
  }
  .ta-two-col-side .ta-side-item.active { border-left-color: transparent; border-bottom-color: var(--accent); }
  /* Settings: stack the API-key generator fields. */
  .ta-apikey-form { grid-template-columns: 1fr; }
}
