:root {
  color-scheme: light;
  --bg: #f5f7ff;
  --panel: #ffffff;
  --panel-soft: #f8faff;
  --text: #07133d;
  --muted: #6b75a8;
  --line: #dde3ff;
  --primary: #3135ff;
  --primary-dark: #001b70;
  --accent: #4f6bff;
  --danger: #e8583d;
  --warning: #f4b740;
  --success: #2a9d8f;
  --brand-sky: #e9ecff;
  --shadow: 0 18px 45px rgba(0, 27, 112, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.hidden {
  display: none !important;
}

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

.login-view {
  display: grid;
  grid-template-columns: minmax(0, 68fr) minmax(360px, 32fr);
  align-items: stretch;
  min-height: 100vh;
  padding: 0;
}

.brand-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: clamp(36px, 8vw, 112px);
  color: white;
  background:
    linear-gradient(135deg, rgba(7, 19, 61, 0.96), rgba(49, 53, 255, 0.82)),
    url("data:image/svg+xml,%3Csvg width='640' height='480' viewBox='0 0 640 480' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.16' stroke-width='2'%3E%3Cpath d='M40 360C160 220 248 410 360 260s196-72 260-180'/%3E%3Cpath d='M22 260c92-88 190 38 292-88 98-122 190-92 300-10'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
}

.brand-logo {
  width: 92px;
  height: 92px;
  object-fit: contain;
  margin-bottom: 22px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.98);
  padding: 8px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.16);
  image-rendering: auto;
}

.eyebrow {
  margin: 0 0 8px;
  color: inherit;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.75;
}

.brand-panel h1,
.topbar h1 {
  margin: 0;
}

.brand-panel h1 {
  max-width: 520px;
  font-size: clamp(38px, 4.6vw, 62px);
  line-height: 1.03;
}

.brand-panel p:last-child {
  max-width: 620px;
  margin-top: 20px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 18px;
  line-height: 1.6;
}

.login-card {
  align-self: center;
  justify-self: center;
  display: grid;
  gap: 0;
  width: min(360px, calc(100% - 36px));
  margin: 0;
  padding: 18px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.auth-form {
  display: grid;
  gap: 22px;
}

.login-icon {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 10px;
  image-rendering: auto;
}

.auth-links {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 0;
}

.auth-links-top {
  justify-content: flex-end;
  margin-top: 0;
  margin-bottom: 4px;
}

.auth-links-bottom {
  justify-content: center;
  margin-top: 8px;
  font-weight: 800;
}

.login-card h2 {
  margin: 0 0 4px;
  font-size: clamp(30px, 3vw, 38px);
  line-height: 1;
  font-weight: 900;
}

label {
  display: grid;
  gap: 10px;
  color: var(--text);
  font-size: 18px;
  font-weight: 500;
}

.login-card .auth-form label {
  gap: 0;
  margin-bottom: 0;
}

.login-card .auth-form label input {
  margin-top: 12px;
}

input,
select {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #ffffff;
  color: var(--text);
  padding: 0 12px;
}

input:focus,
select:focus {
  outline: 3px solid rgba(49, 53, 255, 0.16);
  border-color: var(--accent);
}

.login-card button,
.primary-button {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 6px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 800;
}

.login-card .auth-form > button[type="submit"] {
  justify-self: stretch;
  min-height: 52px;
  min-width: 100%;
  border-radius: 8px;
  font-size: 18px;
  margin-top: 4px;
}

.link-button {
  display: inline-flex;
  align-items: center;
  min-height: 34px !important;
  padding: 0 !important;
  background: transparent !important;
  color: var(--primary) !important;
  font-weight: 800;
  text-align: left;
  text-decoration: none;
}

.danger-button {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 6px;
  background: var(--danger);
  color: #ffffff;
  font-weight: 800;
}

.login-card small {
  color: var(--muted);
  line-height: 1.5;
}

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

.shell-view {
  min-height: 100vh;
  padding: 24px;
}

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

.topbar .eyebrow {
  color: var(--primary);
}

.topbar h1 {
  font-size: clamp(24px, 3vw, 34px);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-brand img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 12px;
  background: #ffffff;
  padding: 5px;
  border: 1px solid var(--line);
}

.session {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.ghost-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font-weight: 800;
}

.state-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--muted);
  font-weight: 700;
}

.state-card.error {
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.28);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric-card,
.mini-panel {
  min-height: 96px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

.metric-card span,
.mini-panel span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-card strong,
.mini-panel strong {
  display: block;
  margin-top: 10px;
  font-size: 32px;
  line-height: 1;
}

.mini-panel small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

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

.client-grid {
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.8fr);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
  gap: 18px;
  align-items: start;
}

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

.route-panel {
  margin-bottom: 18px;
}

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

.panel-heading.compact {
  border-bottom: 0;
  padding-bottom: 6px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 20px;
}

.panel-heading p {
  margin: 4px 0 0;
  color: var(--muted);
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) repeat(5, minmax(130px, 0.8fr));
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: var(--brand-sky);
}

.client-cell strong {
  display: block;
}

.client-cell span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.pill.pending {
  background: #fff7e6;
  color: #9c650f;
}

.pill.accepted,
.pill.approved,
.pill.disbursed {
  background: #e9f8f0;
  color: var(--success);
}

.pill.rejected {
  background: #fef3f2;
  color: var(--danger);
}

.pill.demo {
  background: #eff6ff;
  color: var(--accent);
}

.empty-state,
.detail-empty {
  padding: 32px;
  color: var(--muted);
  text-align: center;
}

.detail-panel {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.detail-header {
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.detail-header h2 {
  margin: 8px 0 6px;
  font-size: 24px;
}

.detail-header p {
  margin: 0;
  color: var(--muted);
}

.detail-section {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.detail-section:last-child {
  border-bottom: 0;
}

.detail-section h3 {
  margin: 0 0 14px;
  font-size: 15px;
  text-transform: uppercase;
}

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

.kv {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
}

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

.kv strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.timeline {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline li {
  padding-left: 16px;
  border-left: 3px solid var(--primary);
}

.timeline strong,
.timeline span {
  display: block;
}

.timeline span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.form-stack {
  display: grid;
  gap: 14px;
  padding: 18px 20px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.notice {
  margin: 14px 20px 0;
  padding: 12px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 6px;
  background: #ecfdf5;
  color: var(--primary-dark);
  font-weight: 700;
}

.action-box {
  background: #fbfdff;
}

.role-layout {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.side-nav {
  position: sticky;
  top: 24px;
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.side-nav span {
  padding: 6px 8px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 6px;
  color: var(--primary-dark);
  font-weight: 800;
  text-decoration: none;
}

.nav-link:hover,
.nav-link.active {
  background: var(--brand-sky);
  color: var(--primary);
}

.page-content {
  min-width: 0;
}

.page-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.page-heading h2 {
  margin: 0;
  font-size: 24px;
}

.page-heading p {
  margin: 6px 0 0;
  color: var(--muted);
}

.route-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
  padding: 12px 18px 18px;
}

.route-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  text-align: left;
}

.route-card.selected {
  border-color: var(--primary);
  background: var(--brand-sky);
}

.route-card span {
  color: var(--muted);
  font-size: 13px;
}

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

  .workspace,
  .client-grid,
  .role-layout {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
    max-height: none;
  }

  .route-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .side-nav {
    position: static;
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    overflow-x: auto;
  }

  .side-nav span {
    grid-column: 1 / -1;
  }
}

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

  .brand-panel {
    min-height: auto;
    padding: 34px 24px;
  }

  .brand-logo {
    width: 72px;
    height: 72px;
    border-radius: 16px;
  }

  .brand-panel h1 {
    font-size: clamp(34px, 12vw, 48px);
  }

  .login-card {
    width: min(390px, calc(100% - 32px));
    padding: 28px 0 40px;
  }

  .shell-view {
    padding: 14px;
  }

  .topbar,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .session {
    align-items: flex-start;
    flex-direction: column;
  }

  .metrics-grid,
  .filters,
  .kv-grid,
  .info-grid,
  .route-grid,
  .side-nav {
    grid-template-columns: 1fr;
  }

  .page-heading {
    flex-direction: column;
  }

  .auth-links {
    align-items: flex-start;
    flex-direction: column;
  }
}
