:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f0f4f7;
  --ink: #18212d;
  --muted: #667085;
  --line: #d9e1e8;
  --line-strong: #c6d1dc;
  --brand: #176b87;
  --brand-dark: #0f4f66;
  --brand-soft: #e5f3f7;
  --accent: #d97706;
  --green: #16845b;
  --green-soft: #e7f6ee;
  --red: #c43f4b;
  --red-soft: #fae8ea;
  --amber: #b86b00;
  --amber-soft: #fff0d4;
  --blue: #2563eb;
  --blue-soft: #e9efff;
  --sidebar: #111827;
  --sidebar-line: rgba(255, 255, 255, .1);
  --shadow: 0 20px 60px rgba(30, 41, 59, .12);
  --radius: 8px;
  --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(23, 107, 135, .08), rgba(246, 247, 251, 0) 300px),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.sprite {
  display: none;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 22px 18px;
  background: var(--sidebar);
  color: #f9fafb;
  border-right: 1px solid rgba(255, 255, 255, .08);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  min-height: 48px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: #ffffff;
  background: #176b87;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .25);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 17px;
  font-weight: 800;
}

.brand small {
  margin-top: 2px;
  color: #aeb8c7;
  font-size: 12px;
  font-weight: 600;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 12px;
  color: #cfd6e3;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 8px;
  transition: background .2s ease, border-color .2s ease, color .2s ease;
}

.nav-link:hover,
.nav-link.active {
  color: #ffffff;
  background: rgba(255, 255, 255, .08);
  border-color: var(--sidebar-line);
}

.nav-link svg {
  width: 19px;
  height: 19px;
}

.agent-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--sidebar-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .06);
}

.agent-card strong,
.agent-card span {
  display: block;
}

.agent-card strong {
  color: #ffffff;
  font-size: 14px;
  font-weight: 750;
}

.agent-card span {
  margin-top: 2px;
  color: #aeb8c7;
  font-size: 12px;
}

.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  color: #ffffff;
  background: #b86b00;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 800;
}

.workspace {
  min-width: 0;
  padding: 22px;
}

.topbar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 0 18px;
  background: linear-gradient(180deg, var(--bg) 80%, rgba(246, 247, 251, 0));
  z-index: 10;
}

.menu-button {
  display: none;
}

.search-box {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 180px;
  max-width: 680px;
  height: 46px;
  padding: 0 14px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(30, 41, 59, .06);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.search-box svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-right: 10px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.date-chip {
  display: inline-flex;
  align-items: center;
  height: 38px;
  padding: 0 12px;
  color: #344054;
  background: rgba(255, 255, 255, .72);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 750;
  line-height: 1;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
}

.button {
  min-height: 40px;
  padding: 0 14px;
}

.button svg {
  width: 17px;
  height: 17px;
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: .55;
  transform: none;
  box-shadow: none;
}

.button:focus-visible,
.icon-button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.tab:focus-visible {
  outline: 3px solid rgba(23, 107, 135, .25);
  outline-offset: 2px;
}

.primary {
  color: #ffffff;
  background: var(--brand);
  border-color: var(--brand);
  box-shadow: 0 12px 24px rgba(23, 107, 135, .2);
}

.primary:hover {
  background: var(--brand-dark);
}

.secondary {
  color: #263241;
  background: var(--surface);
  border-color: var(--line);
}

.secondary:hover,
.ghost:hover {
  border-color: var(--line-strong);
  box-shadow: 0 10px 24px rgba(30, 41, 59, .08);
}

.ghost {
  color: #3c4654;
  background: var(--surface-2);
  border-color: var(--line);
}

.icon-button {
  width: 40px;
  height: 40px;
  color: #344054;
  background: var(--surface);
  border-color: var(--line);
}

.hero-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  margin-bottom: 18px;
  padding: 28px;
  color: #ffffff;
  background:
    linear-gradient(135deg, rgba(17, 24, 39, .94), rgba(23, 107, 135, .9)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='920' height='300' viewBox='0 0 920 300'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.13'%3E%3Cpath d='M0 221c79-43 167-65 265-67 162-2 210 57 354 35 113-17 169-73 301-64'/%3E%3Cpath d='M0 82c104 59 201 77 292 54 119-29 148-108 276-103 114 5 170 72 352 54'/%3E%3Cpath d='M76 300 284 0M326 300 534 0M576 300 784 0'/%3E%3C/g%3E%3Ccircle cx='744' cy='88' r='72' fill='%23ffffff' fill-opacity='.07'/%3E%3C/svg%3E");
  background-size: cover;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.hero-band .eyebrow {
  color: #9de3f1;
}

.hero-band h1 {
  margin: 0;
  font-size: clamp(32px, 4vw, 56px);
  line-height: .98;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 680px;
  margin: 14px 0 0;
  color: #d8e8ee;
  font-size: 16px;
  line-height: 1.6;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 10px;
  min-width: 270px;
}

.hero-metrics div {
  padding: 16px;
  background: rgba(255, 255, 255, .11);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
}

.hero-metrics span,
.hero-metrics strong {
  display: block;
}

.hero-metrics span {
  color: #c8dce3;
  font-size: 12px;
  font-weight: 700;
}

.hero-metrics strong {
  margin-top: 5px;
  color: #ffffff;
  font-size: 28px;
  line-height: 1;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 96px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(30, 41, 59, .06);
}

.metric-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 8px;
}

.metric-icon svg {
  width: 22px;
  height: 22px;
}

.metric-icon.blue {
  color: var(--blue);
  background: var(--blue-soft);
}

.metric-icon.red {
  color: var(--red);
  background: var(--red-soft);
}

.metric-icon.amber {
  color: var(--amber);
  background: var(--amber-soft);
}

.metric-icon.green {
  color: var(--green);
  background: var(--green-soft);
}

.metric-card p,
.metric-card strong {
  margin: 0;
}

.metric-card p {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 30px;
  line-height: 1;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 390px);
  gap: 18px;
  align-items: start;
}

.queue-panel,
.detail-panel,
.admin-panel,
.settings-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(30, 41, 59, .07);
}

.queue-panel {
  min-width: 0;
  overflow: hidden;
}

.admin-panel,
.settings-panel {
  margin-top: 18px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 20px 14px;
}

.section-head h2,
.detail-header h2,
.modal-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 21px;
  line-height: 1.2;
}

.view-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tab {
  min-width: 76px;
  min-height: 34px;
  padding: 0 12px;
  color: #4b5563;
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-weight: 750;
}

.tab.active {
  color: var(--brand-dark);
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(30, 41, 59, .08);
}

.filters-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(145px, 1fr)) auto;
  gap: 10px;
  padding: 0 20px 18px;
}

.filters-row label,
.field {
  display: grid;
  gap: 6px;
}

.filters-row span,
.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

select,
input,
textarea {
  width: 100%;
  min-height: 40px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
}

select,
input {
  padding: 0 11px;
}

input[type="file"] {
  min-height: 42px;
  padding: 8px 11px;
  color: var(--muted);
}

textarea {
  min-height: 116px;
  resize: vertical;
  padding: 11px;
  line-height: 1.5;
}

::placeholder {
  color: #98a2b3;
}

.table-shell {
  position: relative;
  min-height: 500px;
  overflow: auto;
  border-top: 1px solid var(--line);
}

table {
  width: 100%;
  min-width: 700px;
  border-collapse: collapse;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 42px;
  padding: 0 14px;
  color: #667085;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 800;
  text-align: left;
}

td {
  height: 72px;
  padding: 12px 14px;
  border-bottom: 1px solid #edf1f5;
  vertical-align: middle;
}

tbody tr {
  cursor: pointer;
  transition: background .15s ease;
}

tbody tr:hover,
tbody tr.selected {
  background: #f3f8fa;
}

.ticket-title {
  display: grid;
  gap: 4px;
}

.ticket-title strong {
  max-width: 380px;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-title span,
.muted-cell {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  min-height: 27px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.priority-critical,
.status-overdue {
  color: #9f2631;
  background: var(--red-soft);
}

.priority-high {
  color: #995800;
  background: var(--amber-soft);
}

.priority-medium {
  color: #175ec0;
  background: var(--blue-soft);
}

.priority-low {
  color: #126043;
  background: var(--green-soft);
}

.status-open {
  color: #175ec0;
  background: var(--blue-soft);
}

.status-pending {
  color: #995800;
  background: var(--amber-soft);
}

.status-resolved {
  color: #126043;
  background: var(--green-soft);
}

.role-admin {
  color: #175ec0;
  background: var(--blue-soft);
}

.role-agent {
  color: #995800;
  background: var(--amber-soft);
}

.role-employee {
  color: #126043;
  background: var(--green-soft);
}

.empty-state {
  position: absolute;
  inset: 72px 20px 20px;
  display: grid;
  place-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state[hidden] {
  display: none;
}

.empty-state strong {
  color: var(--ink);
  font-size: 18px;
}

.management-grid {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 18px;
  padding: 0 20px 20px;
}

.management-form,
.settings-form {
  display: grid;
  align-content: start;
  gap: 16px;
}

.settings-form {
  max-width: 760px;
  padding: 0 20px 20px;
}

.user-table-shell {
  position: relative;
  min-height: 370px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.users-table {
  min-width: 620px;
}

.users-table td {
  height: 64px;
}

.empty-state.compact {
  inset: 52px 16px 16px;
}

.detail-panel {
  position: sticky;
  top: 82px;
  display: grid;
  gap: 18px;
  padding: 20px;
}

.detail-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.status-dot {
  width: 12px;
  height: 12px;
  margin-top: 8px;
  background: var(--blue);
  border-radius: 50%;
  box-shadow: 0 0 0 5px var(--blue-soft);
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.detail-meta div {
  min-height: 76px;
  padding: 13px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.detail-meta span,
.detail-meta strong {
  display: block;
}

.detail-meta span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.detail-meta strong {
  margin-top: 6px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
}

.detail-section {
  display: grid;
  gap: 10px;
}

.detail-section h3 {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
}

.detail-section p {
  margin: 0;
  color: #475467;
  line-height: 1.55;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
}

.timeline-dot {
  width: 9px;
  height: 9px;
  margin-top: 6px;
  background: var(--brand);
  border-radius: 50%;
}

.timeline-item p {
  margin: 0;
  color: #344054;
  font-size: 13px;
}

.timeline-item span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
  gap: 10px;
}

.attachment-grid.compact {
  grid-template-columns: repeat(auto-fill, minmax(112px, 150px));
  margin-top: 10px;
}

.attachment-card {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}

.attachment-card img,
.attachment-card video {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #eef2f6;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.attachment-card span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ticket-modal {
  width: min(720px, calc(100vw - 32px));
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
}

.ticket-modal::backdrop {
  background: rgba(17, 24, 39, .62);
  backdrop-filter: blur(4px);
}

.modal-card {
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field.wide {
  grid-column: 1 / -1;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  width: min(360px, calc(100vw - 44px));
  min-height: 48px;
  padding: 14px 16px;
  color: #ffffff;
  background: #111827;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px);
  transition: opacity .2s ease, transform .2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.auth-page {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(17, 24, 39, .96), rgba(23, 107, 135, .88)),
    var(--bg);
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 460px);
  gap: 28px;
  align-items: center;
  width: min(1180px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 42px 0;
}

.auth-hero {
  display: grid;
  align-content: space-between;
  min-height: 620px;
  padding: 36px;
  color: #ffffff;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, .02)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='760' height='620' viewBox='0 0 760 620'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.13'%3E%3Cpath d='M68 466h620M112 377h536M154 288h452M198 199h364M242 110h280'/%3E%3Cpath d='M138 520 562 96M286 520 710 96M-10 520 414 96'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 8px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .28);
}

.auth-brand {
  margin-bottom: 0;
}

.auth-copy {
  max-width: 680px;
}

.auth-copy .eyebrow {
  color: #9de3f1;
}

.auth-copy h1 {
  margin: 0;
  max-width: 760px;
  color: #ffffff;
  font-size: clamp(42px, 6vw, 78px);
  line-height: .95;
}

.auth-copy p:not(.eyebrow) {
  max-width: 620px;
  margin: 18px 0 0;
  color: #d8e8ee;
  font-size: 17px;
  line-height: 1.65;
}

.auth-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  max-width: 460px;
}

.auth-stats div {
  padding: 16px;
  background: rgba(255, 255, 255, .11);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 8px;
}

.auth-stats span,
.auth-stats strong {
  display: block;
}

.auth-stats span {
  color: #c8dce3;
  font-size: 12px;
  font-weight: 750;
}

.auth-stats strong {
  margin-top: 6px;
  font-size: 24px;
}

.auth-card {
  padding: 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .24);
}

.auth-card-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.auth-card h2 {
  margin: 0;
  font-size: 28px;
}

.login-form,
.employee-form,
.comment-form {
  display: grid;
  gap: 14px;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
  font-weight: 750;
}

.installer-shell .auth-hero {
  min-height: 680px;
}

.install-result {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
  padding: 13px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.45;
}

.install-result span,
.install-result strong {
  display: block;
}

.install-result.success {
  color: #126043;
  background: var(--green-soft);
}

.install-result.error {
  color: #9f2631;
  background: var(--red-soft);
}

.install-link {
  width: 100%;
}

.portal-page {
  background:
    linear-gradient(180deg, rgba(23, 107, 135, .08), rgba(246, 247, 251, 0) 360px),
    var(--bg);
}

.portal-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 24px;
  background: rgba(246, 247, 251, .88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.portal-brand {
  margin-bottom: 0;
  color: var(--ink);
}

.portal-brand small {
  color: var(--muted);
}

.portal-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.portal-user span {
  color: #344054;
  font-weight: 800;
}

.portal-shell {
  width: min(1240px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 34px;
}

.portal-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 360px);
  gap: 22px;
  align-items: end;
  margin-bottom: 18px;
  padding: 28px;
  color: #ffffff;
  background:
    linear-gradient(135deg, rgba(17, 24, 39, .94), rgba(23, 107, 135, .9)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='920' height='300' viewBox='0 0 920 300'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.13'%3E%3Cpath d='M0 221c79-43 167-65 265-67 162-2 210 57 354 35 113-17 169-73 301-64'/%3E%3Cpath d='M0 82c104 59 201 77 292 54 119-29 148-108 276-103 114 5 170 72 352 54'/%3E%3Cpath d='M76 300 284 0M326 300 534 0M576 300 784 0'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.portal-hero .eyebrow {
  color: #9de3f1;
}

.portal-hero h1 {
  margin: 0;
  font-size: clamp(36px, 5vw, 64px);
  line-height: .96;
}

.portal-hero p:not(.eyebrow) {
  max-width: 660px;
  margin: 14px 0 0;
  color: #d8e8ee;
  font-size: 16px;
  line-height: 1.6;
}

.portal-grid {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  grid-template-areas:
    "form list"
    "detail detail";
  gap: 18px;
}

.portal-form-panel,
.portal-list-panel,
.portal-detail-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(30, 41, 59, .07);
}

.portal-form-panel {
  grid-area: form;
  padding: 20px;
}

.portal-list-panel {
  grid-area: list;
  overflow: hidden;
}

.portal-detail-panel {
  grid-area: detail;
  display: grid;
  gap: 18px;
  padding: 20px;
}

.section-head.compact {
  padding: 0 0 16px;
}

.portal-list-panel .section-head.compact {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
  padding: 20px;
}

.portal-search {
  max-width: none;
  height: 42px;
  box-shadow: none;
}

.ticket-list {
  display: grid;
  max-height: 506px;
  overflow: auto;
  border-top: 1px solid var(--line);
}

.ticket-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 86px;
  padding: 14px 18px;
  color: var(--ink);
  background: var(--surface);
  border: 0;
  border-bottom: 1px solid #edf1f5;
  text-align: left;
}

.ticket-list-item:hover,
.ticket-list-item.active {
  background: #f3f8fa;
}

.ticket-list-item strong,
.ticket-list-item small {
  display: block;
}

.ticket-list-item strong {
  max-width: 520px;
  overflow: hidden;
  font-size: 15px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-list-item small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.ticket-list-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.comment-form {
  padding-top: 2px;
}

.check-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.check-field input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--brand);
}

.empty-inline {
  padding: 22px;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

@media (max-width: 1180px) {
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .management-grid {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
  }
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, 86vw);
    transform: translateX(-104%);
    transition: transform .2s ease;
  }

  body.nav-open .sidebar {
    transform: translateX(0);
  }

  body.nav-open::after {
    position: fixed;
    inset: 0;
    content: "";
    background: rgba(17, 24, 39, .48);
    z-index: 15;
  }

  .menu-button {
    display: inline-flex;
    flex: 0 0 auto;
  }

  .workspace {
    padding: 16px;
  }

  .topbar {
    flex-wrap: wrap;
  }

  .search-box {
    order: 3;
    max-width: none;
    flex-basis: 100%;
  }

  .topbar-actions {
    margin-left: auto;
  }

  .hero-band {
    grid-template-columns: 1fr;
  }

  .hero-metrics {
    min-width: 0;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .view-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
  }

  .tab {
    min-width: 0;
  }

  .filters-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-hero {
    min-height: 520px;
  }

  .portal-hero,
  .portal-grid,
  .portal-list-panel .section-head.compact {
    grid-template-columns: 1fr;
  }

  .portal-grid {
    grid-template-areas:
      "form"
      "list"
      "detail";
  }
}

@media (max-width: 640px) {
  body {
    font-size: 13px;
  }

  .workspace {
    padding: 8px;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .date-chip {
    grid-column: 1 / -1;
    justify-content: center;
  }

  .button {
    width: 100%;
    min-height: 36px;
    padding: 0 10px;
  }

  input,
  select,
  textarea {
    min-height: 36px;
    font-size: 16px;
  }

  textarea {
    min-height: 92px;
  }

  .hero-band {
    padding: 14px;
    margin-bottom: 10px;
  }

  .hero-band h1 {
    font-size: 28px;
  }

  .hero-copy,
  .portal-hero p:not(.eyebrow),
  .auth-copy p:not(.eyebrow) {
    font-size: 13px;
    line-height: 1.45;
  }

  .hero-metrics,
  .metrics-grid,
  .filters-row,
  .detail-meta,
  .detail-actions,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .metrics-grid,
  .portal-grid,
  .content-grid {
    gap: 10px;
  }

  .metric-card {
    min-height: 74px;
    padding: 12px;
  }

  .metric-icon {
    width: 38px;
    height: 38px;
  }

  .metric-card strong {
    font-size: 24px;
  }

  .section-head,
  .filters-row,
  .portal-list-panel .section-head.compact {
    padding: 14px;
  }

  .detail-panel,
  .portal-detail-panel,
  .portal-form-panel,
  .auth-card {
    padding: 14px;
  }

  .detail-meta div {
    min-height: 58px;
    padding: 10px;
  }

  .ticket-list-item {
    min-height: 72px;
    padding: 12px;
  }

  .attachment-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .attachment-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .view-tabs {
    overflow-x: auto;
  }

  .table-shell {
    min-height: 420px;
  }

  .modal-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .auth-shell,
  .portal-shell {
    width: min(100vw - 24px, 100%);
  }

  .auth-hero,
  .auth-card,
  .portal-hero,
  .portal-form-panel,
  .portal-detail-panel {
    padding: 14px;
  }

  .auth-hero {
    min-height: 360px;
  }

  .portal-shell {
    padding: 10px 0 18px;
  }

  .auth-stats,
  .portal-topbar,
  .ticket-list-item {
    grid-template-columns: 1fr;
  }

  .portal-topbar,
  .portal-user {
    align-items: stretch;
  }

  .portal-topbar {
    display: grid;
  }

  .portal-user {
    display: grid;
  }

  .ticket-list-badges {
    justify-content: flex-start;
  }
}
