:root {
  --ink: #172033;
  --muted: #667085;
  --line: #d9e1ec;
  --panel: #ffffff;
  --bg: #f5f7fb;
  --blue: #074b8f;
  --orange: #f47b20;
  --green: #17855f;
  --red: #c43d3d;
  --violet: #6750a4;
  --shadow: 0 12px 30px rgba(31, 45, 61, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(13, 39, 74, 0.94), rgba(7, 75, 143, 0.88)),
    #f5f8fb;
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 440px);
  gap: 28px;
  width: min(1040px, 100%);
  align-items: stretch;
}

.login-hero {
  display: flex;
  min-height: 560px;
  flex-direction: column;
  justify-content: space-between;
  padding: 42px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
}

.login-logo {
  width: 92px;
  height: 92px;
  object-fit: contain;
  border-radius: 18px;
  background: #fff;
}

.login-kicker {
  display: block;
  color: var(--orange);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-hero h1 {
  max-width: 540px;
  margin: 12px 0 14px;
  font-size: 44px;
  line-height: 1.05;
}

.login-hero p {
  max-width: 520px;
  margin: 0;
  color: #d9e9fb;
  font-size: 17px;
  line-height: 1.55;
}

.login-features {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.login-features span {
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 7px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
  font-size: 13px;
  font-weight: 800;
}

.login-card {
  display: grid;
  align-content: center;
  gap: 16px;
  min-height: 560px;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow);
}

.login-card-logo {
  width: 76px;
  height: 76px;
  object-fit: contain;
  border-radius: 16px;
}

.login-card h2 {
  margin: 0;
  font-size: 28px;
}

.login-card p {
  margin: -6px 0 6px;
  color: var(--muted);
  line-height: 1.45;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-weight: 700;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: auto;
  background: #0d274a;
  color: #fff;
  padding: 22px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
}

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

.brand span {
  color: #bed1e8;
  font-size: 13px;
}

.realtime-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin: -12px 0 22px;
  padding: 6px 9px;
  border-radius: 7px;
  color: #d9e9fb;
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px;
  font-weight: 800;
}

.realtime-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #7ddc91;
}

.realtime-status.offline::before {
  background: #f5b342;
}

.realtime-status.error::before {
  background: #ff6b6b;
}

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

.logout-button {
  width: 100%;
  min-height: 42px;
  margin-top: auto;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  text-align: left;
  font-weight: 800;
}

.logout-button:hover {
  background: rgba(244, 123, 32, 0.18);
}

.provider-group {
  display: grid;
  gap: 6px;
}

.provider-button,
.tab-button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #d9e9fb;
  background: transparent;
  text-align: left;
}

.provider-button {
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.provider-button::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.42);
}

.provider-button.active::before {
  background: var(--orange);
}

.sub-tabs {
  display: grid;
  gap: 6px;
  padding-left: 14px;
}

.sub-tab {
  min-height: 38px;
  padding-left: 14px;
  font-size: 14px;
}

.provider-button.active,
.provider-button:hover,
.tab-button.active,
.tab-button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.main {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 26px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

h1 {
  margin: 0;
  font-size: 25px;
}

#view-subtitle {
  margin: 5px 0 0;
  color: var(--muted);
}

.period-filter {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 10px;
  min-width: min(760px, 100%);
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
}

.content {
  padding: 22px 26px 34px;
}

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

.provider-placeholder {
  max-width: 820px;
}

.provider-placeholder h2 {
  margin: 8px 0 8px;
  font-size: 28px;
}

.provider-placeholder p {
  max-width: 620px;
  color: var(--muted);
  line-height: 1.55;
}

.provider-eyebrow {
  color: var(--orange);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.placeholder-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.placeholder-grid article {
  display: grid;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.placeholder-grid strong {
  color: var(--blue);
  font-size: 24px;
}

.placeholder-grid span {
  color: var(--muted);
  font-weight: 700;
}

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

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

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

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

.metric {
  min-height: 122px;
  padding: 18px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 12px;
  font-size: 31px;
}

.metric small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.panel {
  padding: 18px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 17px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
}

.search-label {
  min-width: 260px;
}

.section-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.debt-actions {
  align-items: end;
}

.debt-actions label {
  min-width: 180px;
}

.detail-toolbar {
  align-items: center;
}

.debt-cards {
  margin-bottom: 14px;
}

.receipt-editor {
  padding: 16px;
  box-shadow: none;
}

.receipt-editor h3 {
  margin: 0 0 14px;
  font-size: 16px;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding-top: 20px;
  color: var(--ink);
  font-weight: 800;
  text-transform: none;
}

.checkbox-field input {
  width: 20px;
  min-height: 20px;
  padding: 0;
}

.receipt-lock-note {
  align-self: end;
  min-height: 38px;
  padding: 10px 12px;
  border: 1px solid #c7d7ea;
  border-radius: 7px;
  color: #244767;
  background: #f0f6fc;
  font-weight: 800;
}

.btn {
  min-height: 38px;
  padding: 9px 13px;
  border-radius: 7px;
  color: #fff;
  background: var(--blue);
  font-weight: 700;
}

.btn.secondary {
  color: var(--blue);
  background: #e8f1fb;
}

.btn.orange {
  background: var(--orange);
}

.btn.danger {
  background: var(--red);
}

.btn.small {
  min-height: 30px;
  padding: 6px 9px;
  font-size: 12px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.pending-table {
  margin-top: 14px;
  border-color: #f8c078;
}

.table-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fff9ef;
}

.table-title h3 {
  margin: 0;
  font-size: 15px;
}

.table-title span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  background: #fff;
}

.table-wrap.compact table {
  min-width: 0;
}

th,
td {
  padding: 10px 11px;
  border-bottom: 1px solid #e8edf3;
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  color: #344054;
  background: #f1f5f9;
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.pill.green {
  color: #0b6044;
  background: #dff5ed;
}

.pill.red {
  color: #9b2c2c;
  background: #ffe5e5;
}

.pill.blue {
  color: #064984;
  background: #dceeff;
}

.pill.orange {
  color: #914a00;
  background: #fff0db;
}

.chart {
  width: 100%;
  height: 260px;
}

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

.config-table input,
.config-table select {
  min-width: 90px;
}

.commission-controls {
  min-width: min(820px, 100%);
}

.commission-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.commission-summary div {
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.commission-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.commission-summary strong {
  display: block;
  margin-top: 8px;
  font-size: 20px;
}

.commission-breakdown {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}

.breakdown-card {
  min-height: 82px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid #8aa4c2;
  border-radius: 8px;
  background: #ffffff;
}

.breakdown-card.install {
  border-left-color: #0b65a3;
}

.breakdown-card.r1,
.breakdown-card.r2,
.breakdown-card.r3 {
  border-left-color: #0b8f69;
}

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

.breakdown-card strong {
  display: block;
  margin-top: 7px;
  font-size: 19px;
}

.breakdown-card small,
.row-note {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
}

.notice {
  margin: 12px 0;
  padding: 11px 12px;
  border: 1px solid #f8c078;
  border-radius: 8px;
  color: #7a4300;
  background: #fff6e8;
  font-weight: 700;
}

.cutoff-note {
  margin: 12px 0;
  padding: 11px 12px;
  border: 1px solid #c7d7ea;
  border-radius: 8px;
  color: #244767;
  background: #f0f6fc;
  font-weight: 700;
}

.table-wrap tfoot td {
  background: #f8fafc;
}

input[readonly] {
  color: var(--muted);
  background: #f8fafc;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.upload-box {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  padding: 13px 15px;
  border-radius: 8px;
  color: #fff;
  background: #172033;
  box-shadow: var(--shadow);
}

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

  .login-hero,
  .login-card {
    min-height: auto;
  }

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 12px;
  }

  .brand {
    margin-bottom: 12px;
  }

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

  .logout-button {
    margin-top: 12px;
    text-align: center;
  }

  .tab-button {
    justify-content: center;
  }

  .topbar {
    display: grid;
  }

  .period-filter,
  .commission-summary,
  .grid.cols-4,
  .grid.cols-3,
  .grid.cols-2,
  .split,
  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .login-screen {
    padding: 14px;
  }

  .login-hero,
  .login-card {
    padding: 24px;
  }

  .login-hero h1 {
    font-size: 32px;
  }

  .content,
  .topbar {
    padding: 16px;
  }

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