:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-soft: #f8faff;
  --surface-muted: #eef3fa;
  --text: #172033;
  --muted: #68758a;
  --line: #dfe6f0;
  --line-strong: #cbd5e3;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #e9f0ff;
  --accent: #0d9488;
  --success: #07815f;
  --warning: #b66a05;
  --danger: #c9364a;
  --sidebar: #0b1220;
  --sidebar-soft: #111c30;
  --sidebar-line: rgba(255, 255, 255, .09);
  --shadow-sm: 0 1px 2px rgba(22, 34, 54, .05);
  --shadow: 0 16px 44px rgba(31, 42, 68, .08);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
body.sidebar-open { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
svg { display: block; }

:focus-visible {
  outline: 3px solid rgba(37, 99, 235, .28);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 12px;
  z-index: 2000;
  transform: translateY(-160%);
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  font-weight: 750;
}
.skip-link:focus { transform: translateY(0); }

.app-shell {
  display: grid;
  grid-template-columns: 284px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 100vh;
  height: 100dvh;
  min-width: 0;
  padding: 20px 16px 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(circle at 10% 0%, rgba(37, 99, 235, .22), transparent 34%),
    linear-gradient(180deg, #0c1527 0%, var(--sidebar) 100%);
  color: #dce6f8;
  border-right: 1px solid rgba(255, 255, 255, .04);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 0 6px 18px;
  border-bottom: 1px solid var(--sidebar-line);
}

.brand, .auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brand-mark {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #3b82f6 55%, var(--accent));
  box-shadow: 0 10px 28px rgba(37, 99, 235, .34);
  font-size: 18px;
  font-weight: 900;
}
.brand-copy { min-width: 0; }
.brand-copy strong, .brand-copy small { display: block; }
.brand-copy strong { color: #fff; font-size: 15px; letter-spacing: .01em; }
.brand-copy small { margin-top: 2px; color: #8fa0bc; font-size: 11px; }

.sidebar-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #263550 transparent;
  padding: 10px 3px 20px;
}
.nav-label {
  margin: 20px 11px 8px;
  color: #6f819e;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.sidebar-nav { display: grid; gap: 4px; }
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: #aab8ce;
  font-size: 14px;
  font-weight: 680;
  transition: color .18s ease, background .18s ease, border-color .18s ease, transform .18s ease;
}
.nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, .055);
  transform: translateX(2px);
}
.nav-link.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(37, 99, 235, .28), rgba(37, 99, 235, .13));
  border-color: rgba(96, 165, 250, .18);
  box-shadow: inset 3px 0 0 #60a5fa;
}
.nav-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: #7185a5;
}
.nav-link:hover .nav-icon, .nav-link.active .nav-icon { color: #8ec5ff; }
.nav-icon svg, .icon-button svg, .button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 24px 8px 0;
  padding: 13px;
  border: 1px solid var(--sidebar-line);
  border-radius: 13px;
  background: rgba(255, 255, 255, .035);
}
.sidebar-status strong, .sidebar-status small { display: block; }
.sidebar-status strong { color: #dfe8f7; font-size: 12px; }
.sidebar-status small { margin-top: 2px; color: #7f91ad; font-size: 10px; }
.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 5px rgba(52, 211, 153, .1);
}

.sidebar-footer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 9px;
  padding: 15px 4px 1px;
  border-top: 1px solid var(--sidebar-line);
}
.user-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: #dce9ff;
  background: #1b2a43;
  border: 1px solid #2b3e5e;
  font-weight: 850;
}
.user-copy { min-width: 0; }
.user-copy strong, .user-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-copy strong { color: #edf3fc; font-size: 12px; }
.user-copy small { margin-top: 2px; color: #8192ad; font-size: 10px; }
.sidebar-footer form { margin: 0; }

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: #8495af;
  cursor: pointer;
  transition: color .18s ease, background .18s ease, border-color .18s ease;
}
.icon-button:hover {
  color: #fff;
  background: rgba(255, 255, 255, .07);
  border-color: rgba(255, 255, 255, .07);
}
.sidebar-close, .menu-toggle { display: none; }
.sidebar-overlay { display: none; }

.app-main {
  min-width: 0;
  min-height: 100vh;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 35;
  min-height: 88px;
  padding: 20px clamp(22px, 3vw, 42px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: rgba(243, 246, 251, .88);
  border-bottom: 1px solid rgba(210, 220, 234, .72);
  backdrop-filter: blur(16px);
}
.topbar-leading {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
}
.topbar h1 {
  margin: 3px 0 0;
  overflow: hidden;
  color: #111a2c;
  font-size: clamp(22px, 2.2vw, 29px);
  line-height: 1.2;
  letter-spacing: -.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.eyebrow {
  display: block;
  color: var(--primary);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.content {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 10px clamp(22px, 3vw, 42px) 48px;
}

.button,
button:not(.icon-button):not(.sidebar-overlay) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 18px rgba(37, 99, 235, .16);
  font-weight: 760;
  line-height: 1;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.button:hover,
button:not(.icon-button):not(.sidebar-overlay):hover {
  background: var(--primary-dark);
  box-shadow: 0 10px 24px rgba(37, 99, 235, .23);
  transform: translateY(-1px);
}
.button.secondary {
  color: #28446f;
  background: #eef3fb;
  border-color: #dce5f2;
  box-shadow: none;
}
.button.secondary:hover { color: var(--primary-dark); background: #e5edf9; }
.button.ghost {
  color: #41516b;
  background: #fff;
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}
.button.ghost:hover { color: var(--primary); background: var(--primary-soft); }
.button.danger, button.danger { background: var(--danger); box-shadow: none; }
.wide { width: 100%; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin: 3px 0 18px;
}
.page-head h1 { margin: 3px 0 0; font-size: clamp(22px, 3vw, 32px); letter-spacing: -.025em; }
.page-head p { margin: 0; }

.panel, .card, .stats article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.panel, .card { padding: clamp(18px, 2.2vw, 24px); }
.card + .card, .grid-two + .grid-two { margin-top: 18px; }
.panel h2, .card h2, .panel h3, .card h3 { color: #1a263b; }
.panel h2, .card h2 { margin: 0 0 16px; font-size: 19px; letter-spacing: -.015em; }
.panel h3, .card h3 { margin: 0 0 14px; font-size: 16px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.panel-head h2, .panel-head p { margin-top: 0; }
.panel-head h2 { margin-bottom: 4px; }
.panel-head p { margin-bottom: 0; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}
.stats article {
  position: relative;
  min-width: 0;
  padding: 22px;
  overflow: hidden;
}
.stats article::after {
  content: "";
  position: absolute;
  right: -28px;
  top: -28px;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: rgba(37, 99, 235, .065);
}
.stats article:nth-child(2)::after { background: rgba(217, 119, 6, .08); }
.stats article:nth-child(3)::after { background: rgba(13, 148, 136, .08); }
.stats span { color: var(--muted); font-size: 13px; font-weight: 650; }
.stats strong { display: block; margin: 7px 0 2px; color: #111a2c; font-size: clamp(29px, 3vw, 38px); letter-spacing: -.04em; }
.stats small, .muted, small { color: var(--muted); }

.grid-two {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, .9fr);
  gap: 18px;
}
.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.quick-grid a {
  min-width: 0;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-soft);
  transition: border-color .18s ease, background .18s ease, transform .18s ease, box-shadow .18s ease;
}
.quick-grid a:hover {
  transform: translateY(-2px);
  background: #fff;
  border-color: #bcd0f5;
  box-shadow: 0 12px 28px rgba(35, 70, 130, .08);
}
.quick-grid b, .quick-grid span { display: block; }
.quick-grid b { color: #21304a; font-size: 14px; }
.quick-grid span { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.45; }

.progress-row { display: flex; justify-content: space-between; gap: 16px; margin: 17px 0 8px; font-size: 13px; }
progress { width: 100%; height: 9px; overflow: hidden; border: 0; border-radius: 999px; background: var(--surface-muted); }
progress::-webkit-progress-bar { border-radius: 999px; background: var(--surface-muted); }
progress::-webkit-progress-value { border-radius: 999px; background: linear-gradient(90deg, var(--primary), #60a5fa); }
progress::-moz-progress-bar { border-radius: 999px; background: var(--primary); }

.badge, .pill {
  display: inline-flex;
  align-items: center;
  width: max-content;
  max-width: 100%;
  padding: 5px 9px;
  border-radius: 999px;
  background: #edf2f8;
  color: #4c5c75;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  text-transform: capitalize;
}
.badge.success { color: #087a62; background: #e5f8f1; }
.pill { background: var(--primary-soft); color: var(--primary-dark); }
.badge.priority-high { color: #9a5c06; background: #fff2d5; }
.badge.priority-urgent { color: #b42336; background: #ffe7eb; }
.badge.status-open, .badge.status-pending { color: #2457b7; background: #e9f0ff; }
.badge.status-resolved { color: #087a62; background: #e5f8f1; }
.badge.status-closed { color: #53627a; background: #edf2f8; }
.ticket-link { color: var(--primary); font-weight: 820; }
.ticket-link:hover { color: var(--primary-dark); text-decoration: underline; text-underline-offset: 3px; }

input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
  box-shadow: inset 0 1px 1px rgba(20, 35, 60, .025);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):hover,
select:hover,
textarea:hover { border-color: #aebcd0; }
input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #7da4f2;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .1);
}
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; margin: 0; accent-color: var(--primary); }
input[type="color"] { width: 100%; height: 44px; padding: 4px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff; }
input[type="file"] { padding: 8px; background: var(--surface-soft); }
.search { max-width: 300px !important; }

.stack { display: grid; gap: 15px; }
.stack label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: #34425a;
  font-size: 13px;
  font-weight: 720;
}
.stack label:has(input[type="checkbox"]), .stack label:has(input[type="radio"]) {
  display: flex;
  align-items: center;
  gap: 9px;
  width: max-content;
  max-width: 100%;
}
.form-panel { width: 100%; max-width: 920px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
form.card { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; }
form.card > label { display: grid; gap: 6px; min-width: 160px; color: #34425a; font-size: 12px; font-weight: 720; }

.table-wrap { width: 100%; margin-top: 16px; overflow-x: auto; border-radius: 12px; }
table { width: 100%; min-width: 760px; border-collapse: collapse; }
th, td { padding: 14px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; font-size: 13px; }
th { color: var(--muted); background: var(--surface-soft); font-size: 10px; font-weight: 850; letter-spacing: .07em; text-transform: uppercase; }
tbody tr { transition: background .15s ease; }
tbody tr:hover { background: #f8faff; }
tbody tr:last-child td { border-bottom: 0; }
tfoot th { color: #24344f; background: #eef3fb; }

.tenant-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.tenant-row:last-child { border-bottom: 0; }
.tenant-row b, .tenant-row small { display: block; overflow-wrap: anywhere; }
.tenant-row small { margin-top: 3px; }
.color-dot { width: 14px; height: 40px; border-radius: 8px; background: var(--tenant-color); }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); font-weight: 850; }

.ticket-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, .8fr); gap: 18px; }
.ticket-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-bottom: 18px; color: var(--muted); font-size: 13px; }
.prose { margin: 22px 0; color: #2c3950; line-height: 1.72; overflow-wrap: anywhere; }
.comment { padding: 18px 0; border-top: 1px solid var(--line); }
.comment.internal { margin: 10px 0; padding: 16px; border: 1px solid #f3d497; border-left: 4px solid #d99118; border-radius: 10px; background: #fff9e9; }
.comment header { display: flex; justify-content: space-between; gap: 16px; }
.comment header span { color: var(--muted); font-size: 12px; }
.comment p { line-height: 1.6; overflow-wrap: anywhere; }
details { margin-top: 10px; }
summary { width: max-content; color: var(--primary); font-size: 12px; font-weight: 750; cursor: pointer; }
details form { margin-top: 10px; }

.alert {
  margin: 14px 0;
  padding: 12px 14px;
  border: 1px solid #f5c5ce;
  border-radius: 11px;
  background: #fff0f2;
  color: var(--danger);
}
pre {
  max-width: 100%;
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #101827;
  color: #dbeafe;
}
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

dialog.modal {
  width: min(620px, calc(100vw - 32px));
  max-height: min(760px, calc(100dvh - 32px));
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 30px 90px rgba(4, 13, 31, .28);
}
dialog.modal::backdrop {
  background: rgba(7, 15, 29, .58);
  backdrop-filter: blur(4px);
}
.dialog-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 22px 17px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(12px);
}
.dialog-head h2 { margin: 0 0 5px; font-size: 20px; }
.dialog-head p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.dialog-head .icon-button { flex: 0 0 auto; color: #53627a; background: var(--surface-soft); border-color: var(--line); }
.dialog-body { padding: 22px; }
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.field-help { margin: -2px 0 0; color: var(--muted); font-size: 11px; font-weight: 500; line-height: 1.4; }
.empty-state { padding: 30px 10px; color: var(--muted); text-align: center; font-size: 13px; }
.empty-state strong { display: block; margin-bottom: 6px; color: #2b3950; font-size: 15px; }
.empty-state p { margin: 0 0 15px; }
.alert.success { color: #087a62; background: #e8f8f2; border-color: #b8ead9; }

.auth-shell {
  background:
    radial-gradient(circle at 90% 0%, rgba(37, 99, 235, .17), transparent 32%),
    radial-gradient(circle at 5% 95%, rgba(13, 148, 136, .11), transparent 30%),
    #f5f7fb;
}
.auth-main { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: min(440px, 100%);
  padding: clamp(22px, 5vw, 32px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 26px 70px rgba(31, 42, 68, .13);
}
.auth-brand small, .auth-brand strong { display: block; }
.auth-brand strong { color: #16213a; }
.auth-brand small { margin-top: 2px; font-size: 11px; }
.auth-card h1 { margin: 30px 0 6px; font-size: 28px; letter-spacing: -.025em; }
.auth-card .muted { margin-top: 0; line-height: 1.5; }
.tiny { margin-top: 18px; color: var(--muted); text-align: center; font-size: 11px; }

@media (max-width: 1100px) {
  .app-shell { display: block; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(320px, 88vw);
    transform: translateX(-102%);
    box-shadow: 24px 0 70px rgba(3, 10, 24, .28);
    transition: transform .24s cubic-bezier(.2, .8, .2, 1);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-close, .menu-toggle { display: inline-grid; }
  .sidebar-close { color: #91a3bd; }
  .menu-toggle {
    flex: 0 0 auto;
    color: #3f4f69;
    background: #fff;
    border-color: var(--line);
    box-shadow: var(--shadow-sm);
  }
  .menu-toggle:hover { color: var(--primary); background: var(--primary-soft); border-color: #bdd0f1; }
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 45;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: rgba(5, 12, 25, .48);
    box-shadow: none;
    opacity: 0;
    visibility: hidden;
    cursor: default;
    transition: opacity .22s ease, visibility .22s ease;
  }
  .sidebar-overlay:hover { background: rgba(5, 12, 25, .48); box-shadow: none; transform: none; }
  body.sidebar-open .sidebar-overlay { display: block; opacity: 1; visibility: visible; }
  .topbar { min-height: 80px; }
}

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats article:last-child { grid-column: 1 / -1; }
  .grid-two, .ticket-grid { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .topbar {
    min-height: 72px;
    padding: 14px 16px;
    gap: 12px;
  }
  .topbar h1 { font-size: 21px; }
  .topbar-new-ticket { width: 42px; min-width: 42px; padding: 0; }
  .topbar-new-ticket .button-label { display: none; }
  .content { padding: 12px 16px 36px; }
  .stats { grid-template-columns: 1fr; gap: 12px; }
  .stats article:last-child { grid-column: auto; }
  .quick-grid, .form-grid { grid-template-columns: 1fr; }
  .panel-head, .page-head { align-items: stretch; flex-direction: column; }
  .panel-head .search { max-width: none !important; }
  .actions { align-items: stretch; flex-direction: column-reverse; }
  .actions .button, .actions button { width: 100%; }
  form.card { align-items: stretch; flex-direction: column; }
  form.card > label { width: 100%; }
  form.card > .button, form.card > button { width: 100%; }
  .table-wrap:has(.responsive-table) { overflow: visible; border-radius: 0; }
  .responsive-table { min-width: 0; }
  .responsive-table thead { display: none; }
  .responsive-table tbody, .responsive-table tfoot, .responsive-table tr, .responsive-table td, .responsive-table th { display: block; width: 100%; }
  .responsive-table tbody { display: grid; gap: 12px; }
  .responsive-table tbody tr {
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: #fff;
    box-shadow: var(--shadow-sm);
  }
  .responsive-table tbody tr[hidden] { display: none; }
  .responsive-table td {
    display: grid;
    grid-template-columns: minmax(100px, 38%) minmax(0, 1fr);
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
    text-align: right;
    overflow-wrap: anywhere;
  }
  .responsive-table td:last-child { border-bottom: 0; }
  .responsive-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 10px;
    font-weight: 850;
    letter-spacing: .06em;
    text-align: left;
    text-transform: uppercase;
  }
  .responsive-table td .badge { margin-left: auto; }
  .responsive-table tfoot { margin-top: 12px; }
  .responsive-table tfoot tr {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    padding: 14px;
    border-radius: 12px;
    background: #eaf0fa;
  }
  .responsive-table tfoot th { padding: 0; border: 0; background: transparent; }
  .responsive-table tfoot th[colspan] { display: block; }
  .comment header { align-items: flex-start; flex-direction: column; gap: 5px; }
  .dialog-actions { align-items: stretch; flex-direction: column-reverse; }
  .dialog-actions .button, .dialog-actions button { width: 100%; }
}

@media (max-width: 480px) {
  .sidebar { width: min(300px, 92vw); padding-left: 13px; padding-right: 13px; }
  .eyebrow { font-size: 9px; }
  .topbar h1 { max-width: 190px; }
  .panel, .card, .stats article { border-radius: 14px; }
  .panel, .card { padding: 16px; }
  .stats article { padding: 18px; }
  .tenant-row { align-items: start; }
  .tenant-row .badge { margin-top: 2px; }
  .responsive-table td { grid-template-columns: 1fr; gap: 5px; text-align: left; }
  .responsive-table td .badge { margin-left: 0; }
  .auth-main { padding: 16px; }
  .auth-card h1 { font-size: 25px; }
  dialog.modal {
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - 12px);
    margin: auto 0 0;
    border-radius: 20px 20px 0 0;
  }
  .dialog-head, .dialog-body { padding-left: 17px; padding-right: 17px; }
}

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