:root {
  --brand-blue: #0a58f6;
  --brand-blue-soft: #e7efff;
  --brand-dark: #111111;
  --page: #f6f8fb;
  --cream: #e7edf7;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text-muted: rgba(17, 17, 17, 0.64);
  --line: rgba(17, 17, 17, 0.1);
  --amber: #b58a46;
  --green: #2aa96b;
  --red: #d14545;
  --violet: #6f5bc7;
  --radius: 8px;
  --shadow: 0 16px 46px rgba(17, 17, 17, 0.08);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background: var(--page);
  color: var(--brand-dark);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.login-screen {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(340px, 1.05fr);
  min-height: 100vh;
}

.login-brand {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 36px;
  padding: 48px;
  background: linear-gradient(140deg, var(--page), var(--cream));
  border-right: 1px solid var(--line);
}

.brand-logo {
  width: min(280px, 72vw);
  height: auto;
}

.brand-copy {
  max-width: 520px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(10, 88, 246, 0.1);
  color: var(--brand-blue);
  font-size: 0.82rem;
  font-weight: 700;
}

.version-badge {
  display: inline-flex;
  width: fit-content;
  margin-top: 18px;
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--brand-dark);
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 0.86rem;
  font-weight: 900;
  box-shadow: 0 8px 24px rgba(17, 17, 17, 0.06);
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1 {
  margin-top: 18px;
  font-size: clamp(2.1rem, 4vw, 4.3rem);
  line-height: 0.96;
  max-width: 11ch;
}

.lead {
  margin-top: 18px;
  color: var(--text-muted);
  font-size: 1.02rem;
  line-height: 1.62;
  max-width: 54ch;
}

.feature-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  font-size: 0.9rem;
  font-weight: 700;
}

.login-panel {
  display: grid;
  place-items: center;
  padding: 32px;
  background: var(--surface);
}

.auth-card,
.card,
.panel,
.modal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-card {
  width: min(460px, 100%);
  padding: 28px;
}

.app-store-notice {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid rgba(10, 88, 246, 0.18);
  border-radius: var(--radius);
  background: rgba(10, 88, 246, 0.08);
}

.app-store-notice strong {
  color: var(--brand-blue);
}

.app-store-notice p,
.beta-note {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.app-store-button {
  margin-top: 4px;
  justify-content: center;
  text-align: center;
  text-decoration: none;
}

.beta-note {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.stack {
  display: grid;
  gap: 16px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 12px 13px;
  color: var(--brand-dark);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
}

textarea {
  min-height: 104px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(10, 88, 246, 0.55);
  box-shadow: 0 0 0 4px rgba(10, 88, 246, 0.12);
}

.btn {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 10px 14px;
  background: var(--surface);
  color: var(--brand-dark);
  font-weight: 800;
}

.btn.primary {
  background: var(--brand-blue);
  color: #ffffff;
}

.btn.secondary {
  background: var(--brand-blue-soft);
  color: var(--brand-blue);
}

.btn.ghost {
  border-color: var(--line);
}

.btn.danger {
  background: rgba(209, 69, 69, 0.1);
  color: var(--red);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 22px 16px;
  overflow: hidden;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.sidebar .brand-logo {
  width: 100%;
  max-width: 220px;
  justify-self: center;
  align-self: center;
}

.sidebar-top {
  display: grid;
  gap: 24px;
  min-width: 0;
}

.nav-list {
  display: grid;
  gap: 6px;
  min-width: 0;
  width: 100%;
}

.nav-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  width: 100%;
  max-width: 100%;
  padding: 10px 12px;
  overflow: hidden;
  color: var(--text-muted);
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  text-align: left;
  font-weight: 800;
}

.nav-button span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-button.active {
  color: var(--brand-blue);
  background: var(--brand-blue-soft);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.main {
  min-width: 0;
  width: 100%;
  max-width: 1780px;
  padding: 28px 32px;
}

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

.mobile-bar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 20;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(245, 243, 238, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.search {
  width: min(420px, 100%);
}

.grid {
  display: grid;
  gap: 16px;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.two-col {
  grid-template-columns: minmax(520px, 1.18fr) minmax(360px, 0.82fr);
  align-items: start;
  gap: 20px;
}

.three-col {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card,
.panel {
  padding: 16px;
  box-shadow: 0 8px 28px rgba(17, 17, 17, 0.05);
}

.stat-card {
  display: grid;
  gap: 8px;
  min-height: 112px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stat-value {
  font-size: 2rem;
  line-height: 1;
  color: var(--brand-blue);
  font-weight: 900;
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: 0.86rem;
}

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

.ticket-row,
.conversation-row,
.customer-row {
  display: grid;
  gap: 10px;
  width: 100%;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
  text-align: left;
  box-shadow: 0 8px 22px rgba(17, 17, 17, 0.04);
}

.ticket-row.selected,
.conversation-row.selected,
.customer-row.selected {
  border-color: rgba(10, 88, 246, 0.45);
  background: var(--brand-blue-soft);
}

.row-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status,
.urgency {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 900;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status.success {
  color: var(--green);
  background: rgba(42, 169, 107, 0.12);
  border: 1px solid rgba(42, 169, 107, 0.2);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 14px;
}

.status.received { color: var(--amber); background: rgba(181, 138, 70, 0.13); }
.status.in-progress { color: var(--brand-blue); background: rgba(10, 88, 246, 0.12); }
.status.scheduled { color: var(--violet); background: rgba(111, 91, 199, 0.13); }
.status.active { color: var(--brand-blue); background: rgba(10, 88, 246, 0.12); }
.status.suspicious { color: var(--red); background: rgba(209, 69, 69, 0.12); }
.status.not-suspicious { color: var(--green); background: rgba(42, 169, 107, 0.12); }
.status.resolved { color: #6c747d; background: rgba(108, 116, 125, 0.12); }
.status.cancelled { color: var(--red); background: rgba(209, 69, 69, 0.12); }
.urgency.high { color: var(--red); background: rgba(209, 69, 69, 0.12); }
.urgency.normal { color: var(--amber); background: rgba(181, 138, 70, 0.13); }
.urgency.low { color: var(--green); background: rgba(42, 169, 107, 0.12); }

.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.filter {
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 12px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 800;
}

.filter.active {
  color: var(--brand-blue);
  border-color: rgba(10, 88, 246, 0.32);
  background: rgba(10, 88, 246, 0.09);
}

.detail {
  position: sticky;
  top: 22px;
  display: grid;
  gap: 14px;
}

.detail-stack {
  display: grid;
  gap: 14px;
}

.hero-panel {
  background: linear-gradient(135deg, #ffffff, #eef4ff);
}

.account-grid {
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
  align-items: start;
}

.two-info-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.info-block,
.info-row,
.compact-row,
.message-preview,
.note-box,
.option-row,
.attachment-link {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.info-block {
  display: grid;
  gap: 5px;
  min-height: 78px;
  padding: 12px;
}

.info-list {
  display: grid;
  gap: 8px;
}

.info-row,
.compact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 12px;
}

.info-row span,
.compact-row span {
  min-width: 0;
  color: var(--text-muted);
}

.info-row strong,
.compact-row strong {
  min-width: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.note-box,
.message-preview {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.option-row,
.attachment-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 12px;
  color: inherit;
  text-align: left;
  text-decoration: none;
}

button.option-row {
  cursor: pointer;
}

.attachment-link {
  color: var(--brand-blue);
  background: rgba(10, 88, 246, 0.08);
  border-color: rgba(10, 88, 246, 0.18);
}

.link-list {
  display: grid;
  gap: 10px;
}

.link-list a {
  color: var(--brand-blue);
  font-weight: 800;
  text-decoration: none;
}

.inline-form {
  display: grid;
  gap: 12px;
}

.chat-layout {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.chat-list {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 16px;
  min-height: 0;
  overflow: auto;
  background: var(--surface-2);
  border-right: 1px solid var(--line);
}

.chat-pane {
  display: grid;
  grid-template-rows: auto minmax(260px, 1fr) auto;
  min-width: 0;
  min-height: 0;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.messages {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 18px;
  min-height: 0;
  overflow: auto;
}

.bubble {
  max-width: min(620px, 84%);
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.bubble.me {
  justify-self: end;
  color: #ffffff;
  background: var(--brand-blue);
  border-color: var(--brand-blue);
}

.composer {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(180px, 260px) auto;
  gap: 10px;
  padding: 14px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.screen-messages .app-layout {
  height: 100vh;
  min-height: 0;
}

.screen-messages .main {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.screen-messages .topbar {
  flex: 0 0 auto;
}

.screen-messages .chat-layout {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
}

.empty {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 26px;
  color: var(--text-muted);
  text-align: center;
  border: 1px dashed rgba(17, 17, 17, 0.18);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.55);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(17, 17, 17, 0.32);
}

.modal-card {
  width: min(620px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 20px;
}

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

.hidden {
  display: none !important;
}

@media (max-width: 1280px) {
  .app-layout {
    grid-template-columns: 248px minmax(0, 1fr);
  }

  .sidebar .brand-logo {
    max-width: 196px;
  }

  .main {
    padding: 24px;
  }

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

  .two-col {
    grid-template-columns: 1fr;
  }

  .detail {
    position: static;
  }
}

@media (max-width: 980px) {
  .login-screen {
    grid-template-columns: 1fr;
  }

  .login-brand {
    min-height: 42vh;
    padding: 28px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 58px auto 0 0;
    z-index: 30;
    width: min(320px, 88vw);
    padding: 18px 14px;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow);
  }

  .sidebar .brand-logo {
    max-width: 190px;
  }

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

  .mobile-bar {
    display: flex;
  }

  .main {
    padding: 16px;
    max-width: none;
  }

  .screen-messages .main {
    height: calc(100vh - 58px);
  }

  .stats-grid,
  .two-col,
  .three-col,
  .account-grid,
  .two-info-col,
  .chat-layout {
    grid-template-columns: 1fr;
  }

  .detail {
    position: static;
  }

  .chat-list {
    max-height: 34vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .search {
    width: 100%;
  }

  .row-head,
  .chat-header {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

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

  .info-row,
  .compact-row,
  .option-row,
  .attachment-link {
    align-items: flex-start;
    flex-direction: column;
  }

  .info-row strong,
  .compact-row strong {
    text-align: left;
  }

  .bubble {
    max-width: 100%;
  }
}
