:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #607080;
  --line: #d9e0e6;
  --panel: #ffffff;
  --page: #f4f7f8;
  --blue: #1769aa;
  --green: #24745c;
  --amber: #a96512;
  --red: #b03a48;
  --violet: #6651a6;
  --shadow: 0 14px 40px rgba(20, 33, 43, 0.08);
}

[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background: var(--page);
  color: var(--ink);
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.72;
}

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

.sidebar {
  background: #13202b;
  color: #eef5f7;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.brand-logo {
  display: block;
  width: 190px;
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

.mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #36a87d, #2475b8);
  font-weight: 800;
}

.brand strong {
  display: block;
  font-size: 16px;
}

.brand span {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: #aebdc8;
}

.login-logo {
  display: block;
  width: min(300px, 78vw);
  height: auto;
}

.page-logo {
  display: block;
  width: 220px;
  max-width: 80vw;
  height: auto;
  margin-bottom: 10px;
}

.sr-message:empty {
  display: none;
}

.tenant-picker label,
.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.field-message {
  min-height: 16px;
  margin: 6px 0 0;
  color: var(--red);
  font-size: 12px;
}

.field-message:empty {
  display: none;
}

.tenant-picker label {
  color: #aebdc8;
}

.tenant-picker select,
.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
}

.tenant-picker select {
  background: #1b2d3a;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.18);
}

.nav {
  display: grid;
  gap: 5px;
}

.nav button {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  min-height: 42px;
  padding: 9px 10px;
  border-radius: 7px;
  color: #d7e1e8;
  background: transparent;
  text-align: left;
}

.nav button:hover,
.nav button.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav .count {
  font-size: 12px;
  color: #9db0be;
}

.sidebar-note {
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
  line-height: 1.45;
  color: #c9d6dd;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  background: rgba(244, 247, 248, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.title h1 {
  margin: 0;
  font-size: 23px;
  line-height: 1.15;
}

.title p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn {
  min-height: 38px;
  padding: 9px 12px;
  border-radius: 7px;
  background: #e7edf1;
  color: var(--ink);
}

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

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
}

.content {
  padding: 22px 24px 36px;
}

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

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

.kpi {
  padding: 16px;
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.kpi strong {
  display: block;
  margin-top: 8px;
  font-size: 27px;
}

.kpi small {
  display: block;
  margin-top: 7px;
  color: var(--green);
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 16px;
}

.panel {
  overflow: hidden;
}

.panel-head {
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h2 {
  margin: 0;
  font-size: 16px;
}

.panel-body {
  padding: 16px;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 14px;
}

.table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  background: #e8eef3;
  color: #334554;
}

.badge.green { background: #e4f3ed; color: var(--green); }
.badge.amber { background: #fff0db; color: var(--amber); }
.badge.red { background: #fae6e8; color: var(--red); }
.badge.blue { background: #e4f0fa; color: var(--blue); }
.badge.violet { background: #ece8f8; color: var(--violet); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
}

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

.authorization-stack > .card,
.history-section {
  min-width: 0;
}

.history-section .cards {
  margin-top: 10px;
}

.card {
  padding: 15px;
  box-shadow: none;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.selected-card {
  border-color: #b8d8f4;
  background: #f7fbff;
}

.section-subhead {
  margin: 18px 0 4px;
  font-size: 16px;
}

.section-subhead span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  margin-left: 8px;
}

.meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.timestamp-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0 12px;
}

.timestamp-grid p {
  border: 1px solid var(--line);
  border-radius: 7px;
  margin: 0;
  padding: 9px 10px;
  background: #fbfcfd;
}

.timestamp-grid span {
  color: var(--muted);
  display: block;
  font-size: 11px;
  margin-bottom: 4px;
}

.timestamp-grid strong {
  display: block;
  font-size: 13px;
}

.workflow-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafb;
}

.phone-login [data-login-mode="qr"],
.phone-approval [data-login-mode="qr"] {
  display: none;
}

.phone-login .segmented,
.phone-approval .segmented {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.segmented button {
  border-radius: 6px;
  padding: 9px 10px;
  background: transparent;
  color: var(--muted);
}

.segmented button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 6px rgba(20, 33, 43, 0.1);
}

.section-title {
  margin: 0;
}

.login-methods {
  display: grid;
  gap: 12px;
}

.login-method-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.login-method-primary {
  border-color: #9dc8ec;
  background: #f7fbff;
}

.login-method-card h3 {
  margin: 0 0 4px;
  padding-right: 34px;
}

.login-action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  align-items: end;
}

.login-action-row .btn {
  min-height: 46px;
  white-space: normal;
  line-height: 1.2;
}

.compact-field {
  margin: 0;
}

.step-number {
  position: absolute;
  top: 14px;
  right: 14px;
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e7f1fb;
  color: var(--primary);
  font-weight: 700;
}

.qr-box {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.qr-box img {
  width: 220px;
  height: 220px;
  image-rendering: crisp-edges;
}

.qr-result {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.qr-result img {
  width: 220px;
  height: 220px;
  image-rendering: crisp-edges;
}

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

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

.timeline-item {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 12px;
  align-items: start;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.timeline-item strong {
  font-size: 13px;
}

.timeline-list {
  display: grid;
  gap: 0;
}

.timeline-event {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 12px;
  padding: 0 0 14px;
  position: relative;
}

.timeline-event:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 18px;
  bottom: 0;
  width: 2px;
  background: var(--line);
}

.timeline-marker {
  width: 12px;
  height: 12px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px #e7f1fb;
  z-index: 1;
}

.timeline-time {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.customer-auth-summary {
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 1px solid #b9d7f2;
  border-radius: 8px;
  background: #f3f8fd;
}

.customer-auth-summary strong {
  display: block;
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1.05;
}

.customer-auth-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.decoded-grid.compact {
  max-height: none;
}

.estimate-line-row {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.estimate-line-row h3 {
  margin: 0;
  font-size: 15px;
}

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

.search-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.search-row input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 11px;
}

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

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

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 24, 32, 0.42);
  display: grid;
  justify-items: end;
  z-index: 10;
}

.drawer {
  width: min(520px, 100%);
  height: 100%;
  background: #fff;
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
}

.drawer header,
.drawer footer {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.drawer footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.drawer h2 {
  margin: 0;
  font-size: 18px;
}

.drawer main {
  padding: 16px;
  overflow: auto;
}

.empty {
  padding: 26px;
  text-align: center;
  color: var(--muted);
}

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

.status-line {
  height: 8px;
  border-radius: 99px;
  background: #edf1f4;
  overflow: hidden;
  margin-top: 10px;
}

.status-line span {
  display: block;
  height: 100%;
  background: var(--green);
}

.decoded-box {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.decoded-box h3 {
  margin: 0;
  font-size: 14px;
}

.decoded-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin-top: 10px;
  max-height: 380px;
  overflow: auto;
}

.decoded-item {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  background: #fbfcfd;
}

.decoded-item span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 4px;
}

.decoded-item strong {
  display: block;
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

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

  .sidebar {
    position: static;
  }

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

  .grid,
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

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

  .content {
    padding: 16px;
  }

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

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

  .table {
    display: block;
    overflow-x: auto;
  }

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

  .timeline-event .split-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}
