:root {
  color-scheme: light;
  --blue: #2563eb;
  --blue-700: #1d4ed8;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --surface: #ffffff;
  --soft: #f8fafc;
  --green: #10b981;
  --yellow: #f59e0b;
  --pink: #ec4899;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --blue: #60a5fa;
  --blue-700: #3b82f6;
  --ink: #e5edf7;
  --muted: #9aa8bb;
  --line: #263448;
  --surface: #111827;
  --soft: #0b1120;
  --green: #34d399;
  --yellow: #fbbf24;
  --pink: #f472b6;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--soft);
  color: var(--ink);
}
:root[data-theme="dark"] .topbar,
:root[data-theme="dark"] .nav,
:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .stat,
:root[data-theme="dark"] .ticket-detail,
:root[data-theme="dark"] .item,
:root[data-theme="dark"] .modal {
  background: var(--surface);
}
:root[data-theme="dark"] .search,
:root[data-theme="dark"] .icon-btn,
:root[data-theme="dark"] .user-card select,
:root[data-theme="dark"] .filters select,
:root[data-theme="dark"] .filters input,
:root[data-theme="dark"] .form input,
:root[data-theme="dark"] .form select,
:root[data-theme="dark"] .form textarea {
  background: #0f172a;
  color: var(--ink);
  border-color: var(--line);
}
:root[data-theme="dark"] .ticket-row:hover,
:root[data-theme="dark"] .nav button.active {
  background: #172033;
}
button, input, select, textarea { font: inherit; }
.app { min-height: 100vh; }
.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 28px;
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  min-width: 150px;
}
.logo {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--blue);
  color: white;
  font-weight: 900;
}
.search {
  flex: 1;
  max-width: 460px;
  border: 1px solid transparent;
  background: #eef2f7;
  border-radius: 999px;
  padding: 11px 18px;
  outline: none;
}
.primary {
  border: 0;
  background: var(--blue);
  color: white;
  border-radius: 7px;
  padding: 11px 16px;
  cursor: pointer;
  font-weight: 700;
}
.primary:hover { background: var(--blue-700); }
.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  cursor: pointer;
}
.avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #dbeafe;
  color: var(--blue-700);
  font-weight: 800;
}
.session-pill {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 999px;
  padding: 4px 7px 4px 4px;
}
.session-pill:hover { background: #eef2ff; }
:root[data-theme="dark"] .session-pill:hover { background: #172033; }
.session-pill span {
  max-width: 140px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav {
  height: 48px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 28px;
  overflow-x: auto;
  background: white;
  border-bottom: 1px solid var(--line);
}
.nav button {
  border: 0;
  background: transparent;
  color: #475569;
  padding: 10px 12px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 650;
}
.nav button.active {
  color: var(--ink);
  background: #eef2ff;
}
.main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 24px 56px;
}
.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
  margin-bottom: 30px;
}
.stat, .panel, .ticket-detail {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .08);
}
.stat {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 26px;
}
.stat-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 24px;
}
.stat strong { display: block; font-size: 34px; line-height: 1; margin-top: 6px; }
.muted { color: var(--muted); }
.panel { overflow: hidden; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2, .section-title { margin: 0; font-size: 20px; }
.link {
  border: 0;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
  font-weight: 700;
}
.ticket-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  padding: 20px 24px;
  border-left: 4px solid transparent;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.ticket-row:hover { background: #f8fbff; border-left-color: var(--blue); }
.ticket-title { font-size: 18px; font-weight: 800; margin: 8px 0 4px; }
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
}
.open { background: #fce7f3; color: #be185d; }
.progress { background: #fef3c7; color: #b45309; }
.done { background: #dcfce7; color: #047857; }
.high { background: #fee2e2; color: #b91c1c; }
.mid { background: #e0f2fe; color: #0369a1; }
.low { background: #e2e8f0; color: #475569; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}
.item {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.item h3 { margin: 0 0 8px; }
.user-card {
  display: grid;
  gap: 10px;
}
.user-card label {
  display: grid;
  gap: 6px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}
.user-card select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  padding: 10px 12px;
}
.role-help {
  min-height: 42px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}
.account-menu {
  position: fixed;
  z-index: 30;
  min-width: 180px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 16px 42px rgba(15, 23, 42, .18);
}
.account-menu button {
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  font-weight: 750;
}
.account-menu button:hover {
  background: #eef2ff;
}
:root[data-theme="dark"] .account-menu button:hover {
  background: #172033;
}
.account-settings {
  display: grid;
  gap: 14px;
}
.settings-list {
  display: grid;
  gap: 10px;
}
.settings-list div {
  display: grid;
  gap: 4px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.settings-list span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.settings-list strong {
  overflow-wrap: anywhere;
}
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.filters select, .filters input, .form input, .form select, .form textarea {
  border: 1px solid var(--line);
  background: white;
  border-radius: 7px;
  padding: 10px 12px;
}
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
}
.ticket-detail { padding: 24px; }
.form {
  display: grid;
  gap: 12px;
}
.form textarea { min-height: 110px; resize: vertical; }
.drawer {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .35);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}
.modal {
  width: min(560px, 100%);
  background: white;
  border-radius: 8px;
  padding: 22px;
  border: 1px solid var(--line);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.empty {
  padding: 36px;
  text-align: center;
  color: var(--muted);
}
@media (max-width: 820px) {
  .topbar { padding: 0 14px; gap: 10px; }
  .brand span { display: none; }
  .stats, .split { grid-template-columns: 1fr; }
  .main { padding: 20px 14px 40px; }
  .search { max-width: none; min-width: 120px; }
}

.portal-page {
  min-height: 100vh;
  display: grid;
  align-content: center;
  gap: 36px;
  padding: 44px 18px 28px;
  background:
    radial-gradient(circle at 12% 12%, rgba(37, 99, 235, .12), transparent 34%),
    linear-gradient(135deg, #eef7ff 0%, #f8fafc 48%, #eef5fb 100%);
}
.portal-card {
  width: min(980px, 100%);
  min-height: 560px;
  display: grid;
  grid-template-columns: 1.2fr .95fr;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 26px 70px rgba(15, 23, 42, .18);
}
.portal-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 56px;
  color: white;
  background: linear-gradient(145deg, #1677c9 0%, #07518f 100%);
}
.portal-logo {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin-bottom: 24px;
  background: white;
  color: #1268b3;
  font-size: 26px;
  font-weight: 900;
}
.portal-company {
  margin-bottom: 18px;
  letter-spacing: 4px;
  font-size: 13px;
  font-weight: 900;
}
.portal-brand h1 {
  margin: 0 0 18px;
  font-size: 38px;
  line-height: 1.12;
  letter-spacing: 0;
}
.portal-brand p {
  max-width: 360px;
  margin: 0;
  color: rgba(255, 255, 255, .88);
  font-size: 17px;
  line-height: 1.55;
}
.portal-panel {
  display: flex;
  align-items: center;
  padding: 48px;
}
.portal-form {
  width: 100%;
  display: grid;
  gap: 14px;
}
.portal-form h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}
.portal-form p {
  margin: 0 0 8px;
  line-height: 1.45;
}
.portal-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 750;
  color: #1f2937;
}
.portal-form input,
.portal-form textarea {
  width: 100%;
  border: 1px solid #a8b2c1;
  border-radius: 4px;
  padding: 11px 12px;
  outline: none;
  background: white;
}
.portal-form textarea {
  min-height: 76px;
  resize: vertical;
}
.portal-form input:focus,
.portal-form textarea:focus {
  border-color: #1477c9;
  box-shadow: 0 0 0 3px rgba(20, 119, 201, .16);
}
.portal-primary,
.portal-button-link,
.microsoft-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 4px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
}
.portal-primary,
.portal-button-link {
  border: 0;
  background: #1677c9;
  color: white;
}
.portal-primary:hover,
.portal-button-link:hover {
  background: #075ea6;
}
.microsoft-button {
  width: 100%;
  border: 1px solid #9ca3af;
  background: white;
  color: #242424;
}
.ms-mark {
  width: 18px;
  height: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
}
.ms-mark i:nth-child(1) { background: #f25022; }
.ms-mark i:nth-child(2) { background: #7fba00; }
.ms-mark i:nth-child(3) { background: #00a4ef; }
.ms-mark i:nth-child(4) { background: #ffb900; }
.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  color: #6b7280;
  font-size: 12px;
}
.divider::before,
.divider::after {
  content: "";
  height: 1px;
  background: #e5e7eb;
}
.portal-small {
  color: #5f6b7a;
  font-size: 12px;
}
.portal-error {
  border: 1px solid #fecaca;
  border-radius: 6px;
  background: #fef2f2;
  color: #991b1b;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.4;
}
.portal-form a {
  color: #5b3f8f;
  font-size: 13px;
}
.portal-footer {
  text-align: center;
  color: #6b7280;
  font-size: 13px;
}
@media (max-width: 860px) {
  .portal-page {
    align-content: start;
    padding-top: 18px;
  }
  .portal-card {
    grid-template-columns: 1fr;
  }
  .portal-brand {
    padding: 34px;
  }
  .portal-brand h1 {
    font-size: 32px;
  }
  .portal-panel {
    padding: 30px;
  }
}
