:root {
  --navy-950: #07111f;
  --navy-900: #0b1728;
  --navy-800: #12243b;
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --blue-100: #dbeafe;
  --slate-900: #0f172a;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --white: #ffffff;
  --red-700: #b91c1c;
  --red-100: #fee2e2;
  --green-700: #15803d;
  --green-100: #dcfce7;
  --amber-700: #b45309;
  --amber-100: #fef3c7;
  --violet-100: #ede9fe;
  --cyan-100: #cffafe;
  --pink-100: #fce7f3;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
  --radius: 14px;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--slate-900);
  background: var(--slate-50);
  line-height: 1.5;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
textarea { resize: vertical; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--white);
}

.brand__mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 11px;
  color: var(--navy-950);
  background: linear-gradient(145deg, #93c5fd, #60a5fa);
  font-weight: 900;
  box-shadow: 0 8px 22px rgba(59, 130, 246, 0.28);
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 1.12rem; letter-spacing: .02em; }
.brand small { margin-top: 1px; color: #93a4bb; font-size: .72rem; }
.brand--large { color: var(--slate-900); }
.brand--large .brand__mark { width: 48px; height: 48px; }
.brand--large small { color: var(--slate-500); }

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 24px 18px;
  background: linear-gradient(180deg, var(--navy-950), var(--navy-900));
  color: #cbd5e1;
  z-index: 20;
}

.main-nav { margin-top: 42px; }
.main-nav__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border-radius: 10px;
  text-decoration: none;
  color: #aebdd0;
  font-weight: 650;
}
.main-nav__item--active { color: var(--white); background: rgba(59, 130, 246, .16); }
.main-nav__item span { color: #7db0ff; font-size: 1.15rem; }

.sidebar__footer {
  margin-top: auto;
  padding: 15px 4px 2px;
  border-top: 1px solid rgba(255,255,255,.08);
  color: #8292a7;
  font-size: .75rem;
}
.environment-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #22c55e; }

.workspace { min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 82px;
  padding: 14px clamp(20px, 4vw, 52px);
  border-bottom: 1px solid var(--slate-200);
  background: rgba(255,255,255,.92);
}
.topbar h1 { margin: 1px 0 0; font-size: 1.35rem; line-height: 1.2; }
.topbar__context { margin: 0; color: var(--slate-500); font-size: .73rem; text-transform: uppercase; letter-spacing: .11em; font-weight: 800; }
.menu-button { display: none; border: 0; background: transparent; font-size: 1.4rem; }

.user-menu { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.avatar { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 50%; color: #1e40af; background: var(--blue-100); font-weight: 850; }
.user-menu__name { color: var(--slate-700); font-weight: 700; }
.text-button { padding: 6px 8px; border: 0; color: var(--slate-500); background: transparent; }
.text-button:hover { color: var(--red-700); }

.content { width: min(1440px, 100%); margin: 0 auto; padding: clamp(24px, 4vw, 48px); }

.welcome-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.welcome-row h2 { margin: 3px 0 5px; font-size: clamp(1.55rem, 3vw, 2.15rem); line-height: 1.2; }
.welcome-row p:last-child { margin: 0; color: var(--slate-600); }
.eyebrow { margin: 0; color: var(--blue-600); font-size: .72rem; font-weight: 850; letter-spacing: .13em; text-transform: uppercase; }
.version-chip { flex: 0 0 auto; padding: 7px 11px; border: 1px solid #bfdbfe; border-radius: 999px; color: #1d4ed8; background: #eff6ff; font-size: .78rem; font-weight: 800; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.metric-card { position: relative; overflow: hidden; padding: 20px; border: 1px solid var(--slate-200); border-radius: var(--radius); background: var(--white); box-shadow: 0 10px 30px rgba(15,23,42,.04); }
.metric-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--blue-500); }
.metric-card--amber::before { background: #f59e0b; }
.metric-card--green::before { background: #22c55e; }
.metric-card--red::before { background: #ef4444; }
.metric-card__label { display: block; color: var(--slate-600); font-size: .84rem; font-weight: 750; }
.metric-card strong { display: block; margin: 8px 0 2px; font-size: 2rem; line-height: 1; }
.metric-card small { color: var(--slate-500); }

.panel { border: 1px solid var(--slate-200); border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow); }
.panel__header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 21px 24px; border-bottom: 1px solid var(--slate-200); }
.panel__header h2 { margin: 4px 0 0; font-size: 1.12rem; }
.muted { color: var(--slate-500); font-size: .86rem; }

.empty-state { padding: 56px 24px 64px; text-align: center; }
.empty-state__icon { display: grid; width: 48px; height: 48px; margin: 0 auto 14px; place-items: center; border: 1px dashed #93c5fd; border-radius: 14px; color: var(--blue-600); background: #eff6ff; font-size: 1.6rem; }
.empty-state h3 { margin: 0 0 6px; }
.empty-state p { max-width: 600px; margin: 0 auto; color: var(--slate-500); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--slate-200); text-align: left; vertical-align: middle; white-space: nowrap; }
th { color: var(--slate-500); background: var(--slate-50); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fbff; }

.badge { display: inline-flex; padding: 4px 8px; border-radius: 999px; color: var(--slate-700); background: var(--slate-100); font-size: .74rem; font-weight: 750; }
.badge--priority-high { color: var(--red-700); background: var(--red-100); }
.badge--priority-normal, .badge--status-new { color: #1d4ed8; background: var(--blue-100); }
.badge--status-assigned { color: #6d28d9; background: var(--violet-100); }
.badge--status-in_progress { color: var(--amber-700); background: var(--amber-100); }
.badge--status-waiting_customer { color: #be185d; background: var(--pink-100); }
.badge--status-waiting_supplier { color: #0e7490; background: var(--cyan-100); }
.badge--status-resolved { color: var(--green-700); background: var(--green-100); }
.badge--status-closed { color: #334155; background: #e2e8f0; }
.badge--status-cancelled { color: #57534e; background: #e7e5e4; }
.badge--active { color: var(--green-700); background: var(--green-100); }
.badge--inactive { color: var(--slate-600); background: var(--slate-200); }

.alert { margin-bottom: 20px; padding: 12px 14px; border: 1px solid; border-radius: 10px; }
.alert--error { color: #991b1b; border-color: #fecaca; background: #fef2f2; }
.alert--success { color: #166534; border-color: #bbf7d0; background: #f0fdf4; }
.alert--warning { color: #854d0e; border-color: #fde68a; background: #fffbeb; }
.alert--action { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.alert--action a { flex: 0 0 auto; color: #1d4ed8; font-weight: 800; }

.guest-body { display: grid; place-items: center; padding: 28px; background: radial-gradient(circle at 15% 10%, #dbeafe 0, transparent 28%), var(--slate-100); }
.guest-shell { display: grid; grid-template-columns: minmax(340px, 520px) minmax(320px, 480px); width: min(1000px, 100%); min-height: 620px; overflow: hidden; border: 1px solid rgba(148,163,184,.35); border-radius: 24px; background: var(--white); box-shadow: 0 28px 80px rgba(15,23,42,.16); }
.login-panel { display: flex; flex-direction: column; justify-content: center; padding: clamp(34px, 6vw, 68px); }
.login-panel .brand { margin-bottom: 64px; }
.login-copy h1 { margin: 5px 0 6px; font-size: 2rem; }
.login-copy > p:last-child { margin: 0 0 26px; color: var(--slate-500); }
.guest-aside { display: flex; flex-direction: column; justify-content: center; padding: 56px; color: var(--white); background: linear-gradient(145deg, #0b1728, #12335c); }
.guest-aside .eyebrow { color: #93c5fd; }
.guest-aside h2 { max-width: 360px; margin: 12px 0; font-size: clamp(2rem, 4vw, 3.5rem); line-height: 1.04; letter-spacing: -.04em; }
.guest-aside > p:not(.eyebrow) { color: #bdc9d8; }
.security-note { display: flex; align-items: flex-start; gap: 12px; margin-top: 48px; padding-top: 24px; border-top: 1px solid rgba(255,255,255,.14); }
.security-note > span { display: grid; width: 28px; height: 28px; flex: 0 0 auto; place-items: center; border-radius: 50%; color: #052e16; background: #86efac; font-weight: 900; }
.security-note p { margin: 0; color: #bdc9d8; font-size: .86rem; }
.security-note strong { color: var(--white); }

.form-stack { display: grid; gap: 18px; }
.field { display: grid; gap: 7px; color: var(--slate-700); font-size: .86rem; font-weight: 750; }
.field input, .field select, .field textarea { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--slate-300); border-radius: 9px; color: var(--slate-900); background: var(--white); outline: none; }
.field textarea { min-height: 92px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(59,130,246,.16); }
.button { min-height: 46px; padding: 10px 16px; border: 0; border-radius: 9px; font-weight: 800; }
.button--primary { color: var(--white); background: var(--blue-600); box-shadow: 0 10px 24px rgba(37,99,235,.2); }
.button--primary:hover { background: #1d4ed8; }
.button--secondary { color: var(--slate-700); border: 1px solid var(--slate-300); background: var(--white); }
.button--secondary:hover { border-color: #93c5fd; background: #eff6ff; }
.button--danger { color: var(--red-700); border: 1px solid #fecaca; background: #fff7f7; }
.button--danger:hover { border-color: #fca5a5; background: var(--red-100); }
.button--small { min-height: 36px; padding: 7px 11px; font-size: .82rem; }
.button:disabled { cursor: not-allowed; opacity: .55; }
.button--wide { width: 100%; margin-top: 5px; }
.button-link { display: inline-grid; place-items: center; text-decoration: none; }
.form-hint { color: var(--slate-500); font-size: .76rem; font-weight: 500; }
.setup-notice { margin: 0; padding: 14px; border-radius: 10px; color: var(--slate-700); background: var(--slate-100); }
code { padding: .1em .35em; border-radius: 5px; background: var(--slate-100); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .9em; }
.guest-link { margin: 22px 0 0; color: var(--blue-600); text-align: center; font-size: .86rem; font-weight: 750; }
.guest-link a:hover { color: #1d4ed8; }
.security-code-input { text-align: center; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 1.15rem; font-weight: 850; letter-spacing: .12em; }
.security-steps { display: grid; gap: 9px; margin: 0 0 20px; padding-left: 22px; color: var(--slate-600); font-size: .82rem; }
.totp-enrollment { display: grid; grid-template-columns: 190px minmax(0, 1fr); align-items: center; gap: 20px; margin-bottom: 22px; padding: 16px; border: 1px solid var(--slate-200); border-radius: 13px; background: var(--slate-50); }
.qr-box { display: grid; width: 190px; height: 190px; place-items: center; overflow: hidden; border-radius: 8px; background: var(--white); }
.qr-box svg { display: block; width: 100%; height: 100%; }
.field-label { display: block; margin-bottom: 7px; color: var(--slate-600); font-size: .72rem; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
.totp-secret { display: block; padding: 10px; overflow-wrap: anywhere; color: var(--slate-900); background: var(--white); font-size: .88rem; letter-spacing: .08em; }

.security-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.security-card { padding: 24px; }
.security-card h3 { margin: 5px 0 8px; font-size: 1.15rem; }
.security-card > p:not(.eyebrow) { margin: 0; color: var(--slate-600); }
.security-card--danger { grid-column: 1 / -1; border-color: #fecaca; }
.compact-form { margin-top: 22px; }
.inline-warning { margin-top: 15px; padding: 11px 12px; border: 1px solid #fde68a; border-radius: 9px; color: #854d0e; background: #fffbeb; font-size: .82rem; font-weight: 700; }
.recovery-panel { padding: clamp(20px, 4vw, 32px); }
.recovery-codes { width: 100%; min-height: 290px; padding: 22px; border: 1px solid var(--slate-300); border-radius: 12px; color: var(--slate-900); background: var(--slate-50); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 1.15rem; font-weight: 800; letter-spacing: .09em; line-height: 1.75; text-align: center; resize: none; }
.recovery-panel .button { display: inline-grid; place-items: center; text-decoration: none; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.page-header h2 { margin: 4px 0 6px; font-size: clamp(1.55rem, 3vw, 2rem); }
.page-header p:last-child { margin: 0; color: var(--slate-600); }
.form-panel { padding: clamp(20px, 4vw, 32px); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.field--wide { grid-column: 1 / -1; }
.form-section { margin: 28px 0 0; padding: 20px; border: 1px solid var(--slate-200); border-radius: 12px; }
.form-section legend { padding: 0 8px; font-weight: 850; }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.choice-card { display: flex; align-items: flex-start; gap: 10px; padding: 14px; border: 1px solid var(--slate-200); border-radius: 10px; background: var(--slate-50); }
.choice-card input, .toggle-row input { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 2px; accent-color: var(--blue-600); }
.choice-card span, .choice-card strong, .choice-card small, .toggle-row span, .toggle-row strong, .toggle-row small { display: block; }
.choice-card small, .toggle-row small { margin-top: 3px; color: var(--slate-500); font-size: .78rem; }
.toggle-row { display: flex; align-items: flex-start; gap: 11px; margin-top: 22px; padding: 15px; border-radius: 10px; background: var(--slate-100); }
.toggle-stack { display: grid; gap: 10px; margin-top: 22px; }
.toggle-stack .toggle-row { margin-top: 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--slate-200); }
.table-actions { text-align: right; }
.table-actions a { color: var(--blue-600); font-weight: 800; text-decoration: none; }
.table-actions a:hover { text-decoration: underline; }
.split-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: 22px; }
.compact-empty { padding: 28px 22px; color: var(--slate-500); text-align: center; }
.record-list { display: grid; }
.record-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 15px 20px; border-bottom: 1px solid var(--slate-200); text-decoration: none; }
.record-row:last-child { border-bottom: 0; }
.record-row:hover { background: var(--slate-50); }
.record-row strong, .record-row small { display: block; }
.record-row small { margin-top: 2px; color: var(--slate-500); }
.record-badges { display: flex; gap: 6px; }

.header-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
.empty-state__action { display: inline-grid; margin-top: 20px; }
.filter-panel { margin-bottom: 22px; padding: 20px; }
.filter-grid { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 14px; }
.filter-search { grid-column: span 2; }
.filter-actions { display: flex; align-items: center; justify-content: flex-end; gap: 16px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--slate-200); }
.filter-actions a { color: var(--slate-500); font-size: .86rem; font-weight: 750; }
.ticket-link { color: #1d4ed8; font-weight: 850; text-decoration: none; }
.ticket-link:hover { text-decoration: underline; }
.pagination { display: flex; justify-content: center; flex-wrap: wrap; gap: 7px; margin-top: 22px; }
.pagination a { display: grid; min-width: 38px; height: 38px; padding: 0 9px; place-items: center; border: 1px solid var(--slate-300); border-radius: 8px; background: var(--white); text-decoration: none; font-weight: 750; }
.pagination a:hover { border-color: #93c5fd; background: #eff6ff; }
.pagination .is-current { color: var(--white); border-color: var(--blue-600); background: var(--blue-600); }
.ticket-heading { align-items: center; }
.ticket-heading h2 { overflow-wrap: anywhere; }
.heading-badges { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.ticket-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(290px, .85fr); gap: 22px; align-items: start; }
.ticket-main { display: grid; gap: 22px; min-width: 0; }
.ticket-side { display: grid; gap: 22px; }
.detail-panel .prose { padding: 24px; }
.prose { overflow-wrap: anywhere; line-height: 1.7; }
.info-card, .status-card { padding: 22px; }
.info-card h3, .status-card h3 { margin: 0 0 18px; font-size: 1rem; }
.detail-list { display: grid; gap: 0; margin: 0; }
.detail-list > div { padding: 11px 0; border-top: 1px solid var(--slate-200); }
.detail-list > div:first-child { padding-top: 0; border-top: 0; }
.detail-list dt { color: var(--slate-500); font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.detail-list dd { margin: 3px 0 0; color: var(--slate-900); font-weight: 700; overflow-wrap: anywhere; }
.detail-list dd small { display: block; margin-top: 3px; color: var(--slate-500); font-size: .78rem; font-weight: 500; }
.timeline { padding: 6px 24px 18px; }
.timeline-row { position: relative; display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 13px; padding: 18px 0; border-bottom: 1px solid var(--slate-200); }
.timeline-row:last-child { border-bottom: 0; }
.timeline-dot { width: 10px; height: 10px; margin-top: 6px; border: 2px solid var(--white); border-radius: 50%; background: var(--blue-500); box-shadow: 0 0 0 2px #bfdbfe; }
.timeline-row strong, .timeline-row small { display: block; }
.timeline-row small { margin-top: 3px; color: var(--slate-500); }
.timeline-row p { margin: 9px 0 0; color: var(--slate-700); overflow-wrap: anywhere; }
[hidden] { display: none !important; }
.work-total { color: var(--slate-500); font-size: .82rem; white-space: nowrap; }
.work-total strong { color: var(--slate-900); }
.message-form { padding: 24px; border-bottom: 1px solid var(--slate-200); background: #fbfdff; }
.message-form__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.message-form .form-actions { margin-top: 20px; padding-top: 18px; }
.customer-visibility-note { margin-top: 16px; padding: 12px 14px; border: 1px solid #bae6fd; border-radius: 9px; color: #075985; background: #f0f9ff; font-size: .84rem; }
.inline-notice { padding: 17px 24px; border-bottom: 1px solid var(--slate-200); color: var(--slate-600); background: var(--slate-50); }
.message-list { display: grid; gap: 14px; padding: 20px 24px 24px; }
.message-card { overflow: hidden; border: 1px solid var(--slate-200); border-left: 4px solid #94a3b8; border-radius: 11px; background: var(--white); }
.message-card--work { border-left-color: #f59e0b; }
.message-card--response, .message-card--resolution { border-left-color: #0ea5e9; }
.message-card__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 14px 16px; border-bottom: 1px solid var(--slate-200); background: var(--slate-50); }
.message-card__header strong, .message-card__header span { display: block; }
.message-card__header > div:first-child > span { margin-top: 2px; color: var(--slate-500); font-size: .78rem; }
.message-card__badges { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
.message-card__body { padding: 17px 16px; color: var(--slate-800, #1e293b); overflow-wrap: anywhere; line-height: 1.65; }
.badge--work { color: #92400e; background: #fef3c7; }
.badge--customer { color: #075985; background: #e0f2fe; }
.badge--internal { color: #475569; background: #e2e8f0; }
.attachment-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin: 0; padding: 0 16px 16px; list-style: none; }
.attachment-list a { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 10px 12px; border: 1px solid var(--slate-200); border-radius: 9px; color: #1d4ed8; background: var(--white); text-decoration: none; }
.attachment-list a:hover { border-color: #93c5fd; background: #eff6ff; }
.attachment-list a > span:first-child { flex: 0 0 auto; font-size: 1.1rem; }
.attachment-list a > span:last-child { min-width: 0; }
.attachment-list strong, .attachment-list small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-list small { margin-top: 2px; color: var(--slate-500); font-size: .72rem; font-weight: 500; }

.customer-access-card { padding: 22px; }
.customer-access-card h3 { margin: 3px 0 18px; font-size: 1rem; }
.credentials-box { margin: 0 0 18px; padding: 15px; border: 1px solid #86efac; border-radius: 11px; background: #f0fdf4; }
.credentials-box > strong { color: #166534; }
.credentials-box > p { margin: 5px 0 14px; color: var(--slate-600); font-size: .8rem; }
.credential-row { display: grid; gap: 5px; margin-top: 10px; color: var(--slate-600); font-size: .72rem; font-weight: 800; text-transform: uppercase; }
.credential-copy { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.credential-copy input { min-width: 0; height: 38px; padding: 7px 9px; border: 1px solid #bbf7d0; border-radius: 7px; color: var(--slate-900); background: var(--white); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .75rem; text-transform: none; }
.credential-copy .credential-pin { font-size: 1rem; font-weight: 900; letter-spacing: .12em; }
.credential-mail-state { display: block; margin-top: 12px; color: #166534; font-size: .75rem; font-weight: 700; text-transform: none; }
.access-state { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; padding: 11px 12px; border-radius: 9px; font-size: .84rem; font-weight: 800; }
.access-state > span { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; }
.access-state--active { color: var(--green-700); background: var(--green-100); }
.access-state--active > span { background: #22c55e; }
.access-state--inactive { color: var(--slate-600); background: var(--slate-100); }
.access-state--inactive > span { background: #94a3b8; }
.customer-access-details { margin: 0 0 15px; }
.access-action { margin-top: 9px; }
.customer-access-hint { display: block; margin-top: 15px; line-height: 1.5; }

.portal-body { display: flex; min-height: 100vh; flex-direction: column; background: radial-gradient(circle at 90% 0, #dbeafe 0, transparent 27%), var(--slate-50); }
.portal-topbar { padding: 17px clamp(20px, 5vw, 64px); border-bottom: 1px solid var(--slate-200); background: rgba(255,255,255,.9); }
.portal-brand { display: inline-flex; align-items: center; gap: 11px; color: var(--slate-900); text-decoration: none; }
.portal-brand strong, .portal-brand small { display: block; }
.portal-brand small { color: var(--slate-500); font-size: .72rem; }
.portal-container { width: min(1180px, calc(100% - 40px)); flex: 1; margin: 0 auto; padding: 38px 0 56px; }
.portal-footer { padding: 20px; color: var(--slate-500); text-align: center; font-size: .76rem; }
.portal-auth-card { width: min(480px, 100%); margin: clamp(30px, 8vh, 90px) auto; padding: clamp(28px, 5vw, 46px); border: 1px solid var(--slate-200); border-radius: 20px; background: var(--white); box-shadow: var(--shadow); text-align: center; }
.portal-auth-card__icon, .portal-result-card__check { display: grid; width: 54px; height: 54px; margin: 0 auto 20px; place-items: center; border-radius: 50%; color: #1d4ed8; background: var(--blue-100); font-size: 1.5rem; font-weight: 900; }
.portal-result-card__check { color: var(--green-700); background: var(--green-100); }
.portal-auth-card h1 { margin: 5px 0 10px; font-size: clamp(1.6rem, 4vw, 2.1rem); }
.portal-lead { margin: 0 0 24px; color: var(--slate-600); }
.portal-auth-card .alert, .portal-auth-card .inline-notice { margin: 18px 0; text-align: left; }
.portal-auth-card .inline-notice { border: 0; border-radius: 9px; }
.portal-pin-form { display: grid; gap: 12px; margin-top: 25px; text-align: left; }
.portal-pin-field input { height: 58px; text-align: center; font-size: 1.35rem; font-weight: 900; letter-spacing: .3em; }
.portal-ticket-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 34px; margin-bottom: 24px; padding: clamp(24px, 4vw, 34px); border-radius: 18px; color: var(--white); background: linear-gradient(140deg, var(--navy-950), #143b6b); box-shadow: var(--shadow); }
.portal-ticket-header .eyebrow { color: #93c5fd; }
.portal-ticket-header h1 { max-width: 720px; margin: 5px 0 8px; overflow-wrap: anywhere; font-size: clamp(1.6rem, 4vw, 2.4rem); line-height: 1.18; }
.portal-summary { display: grid; min-width: 245px; gap: 9px; margin: 0; }
.portal-summary > div { padding-bottom: 9px; border-bottom: 1px solid rgba(255,255,255,.13); }
.portal-summary > div:last-child { padding-bottom: 0; border-bottom: 0; }
.portal-summary dt { color: #9fb0c7; font-size: .68rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.portal-summary dd { margin: 2px 0 0; font-weight: 700; }
.portal-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, .8fr); gap: 22px; align-items: start; }
.portal-main-column, .portal-side-column { display: grid; gap: 22px; min-width: 0; }
.portal-confirm-card, .portal-reply-card { padding: 22px; }
.portal-confirm-card { border-color: #86efac; background: #f7fff9; }
.portal-confirm-card h2, .portal-reply-card h2 { margin: 3px 0 10px; font-size: 1.2rem; }
.portal-confirm-card p:not(.eyebrow) { color: var(--slate-600); font-size: .86rem; }
.portal-confirm-card form { margin-top: 17px; }
.portal-reply-card .form-stack { margin-top: 16px; }
.message-card--customer-reply { border-left-color: #8b5cf6; }
.portal-message-list .message-card__header { padding-right: 16px; }

.mail-config-card { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 22px; padding: 20px 24px; }
.mail-config-card h3 { margin: 3px 0 0; }
.mail-config-list { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px 25px; margin: 0; }
.mail-config-list div { min-width: 90px; }
.mail-config-list dt { color: var(--slate-500); font-size: .68rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.mail-config-list dd { margin: 3px 0 0; font-weight: 750; }
.table-subline { display: block; margin-top: 2px; color: var(--slate-500); font-size: .75rem; font-weight: 500; }
.mail-subject { display: block; max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-error { display: block; max-width: 420px; margin-top: 3px; overflow: hidden; color: var(--red-700); font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
.badge--mail-pending { color: var(--amber-700); background: var(--amber-100); }
.badge--mail-processing { color: #075985; background: #e0f2fe; }
.badge--mail-sent { color: var(--green-700); background: var(--green-100); }
.badge--mail-failed { color: var(--red-700); background: var(--red-100); }
.badge--mail-cancelled { color: var(--slate-600); background: var(--slate-200); }

@media (max-width: 980px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filter-search { grid-column: span 2; }
  .ticket-layout { grid-template-columns: 1fr; }
  .portal-grid { grid-template-columns: 1fr; }
  .portal-side-column { grid-row: 1; }
  .guest-shell { grid-template-columns: 1fr; min-height: 0; }
  .guest-aside { display: none; }
  .login-panel .brand { margin-bottom: 44px; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: -270px; transition: left .2s ease; box-shadow: 12px 0 30px rgba(15,23,42,.25); }
  .sidebar--open { left: 0; }
  .menu-button { display: inline-grid; place-items: center; }
  .user-menu__name { display: none; }
  .topbar { padding-inline: 16px; }
  .content { padding: 24px 16px; }
  .welcome-row { display: block; }
  .version-chip { display: inline-block; margin-top: 14px; }
  .page-header { display: block; }
  .page-header > .button { margin-top: 16px; }
  .page-header .header-actions { justify-content: flex-start; margin-top: 16px; }
  .form-grid, .choice-grid, .split-grid { grid-template-columns: 1fr; }
  .message-form__grid { grid-template-columns: 1fr; }
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-search { grid-column: 1 / -1; }
  .record-row { align-items: flex-start; }
  .security-grid { grid-template-columns: 1fr; }
  .security-card--danger { grid-column: auto; }
}

@media (max-width: 520px) {
  .metric-grid { grid-template-columns: 1fr; }
  .guest-body { padding: 0; background: var(--white); }
  .guest-shell { width: 100%; min-height: 100vh; border: 0; border-radius: 0; box-shadow: none; }
  .login-panel { padding: 30px 22px; }
  .panel__header { align-items: flex-start; }
  .filter-grid { grid-template-columns: 1fr; }
  .filter-search { grid-column: auto; }
  .filter-actions { align-items: stretch; flex-direction: column-reverse; }
  .filter-actions .button { width: 100%; }
  .alert--action { align-items: flex-start; flex-direction: column; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .button { width: 100%; }
  .record-row { display: grid; }
  .message-card__header { display: grid; }
  .message-card__badges { justify-content: flex-start; }
  .attachment-list { grid-template-columns: 1fr; }
  .portal-container { width: min(100% - 28px, 1180px); padding-top: 24px; }
  .portal-ticket-header { display: grid; }
  .portal-summary { min-width: 0; }
  .credential-copy { grid-template-columns: 1fr; }
  .mail-config-card { align-items: flex-start; flex-direction: column; }
  .mail-config-list { justify-content: flex-start; }
  .totp-enrollment { grid-template-columns: 1fr; }
  .qr-box { width: min(230px, 100%); height: auto; aspect-ratio: 1; margin-inline: auto; }
}

@media print {
  .sidebar, .topbar, .page-header, .alert, .form-actions { display: none !important; }
  .app-shell, .workspace, .content { display: block; width: 100%; padding: 0; margin: 0; }
  .panel { border: 0; box-shadow: none; }
  .recovery-codes { border: 0; background: #fff; color: #000; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
