:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9dee7;
  --accent: #006d77;
  --accent-2: #c2410c;
  --ok: #087f5b;
  --warn: #b45309;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, Segoe UI, Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef2f6;
}

.auth-screen[hidden] {
  display: none;
}

.auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 12px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-logo {
  width: 76px;
  height: 92px;
  object-fit: contain;
}

.auth-card h1,
.auth-card p {
  margin: 0;
}

.auth-card input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
}

.auth-error {
  min-height: 20px;
  color: #b42318;
}

body.auth-mode .sidebar,
body.auth-mode .shell {
  display: none;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 260px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 16px;
  background: #0f1f24;
  color: #f8fafc;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
}

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

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

.brand small {
  color: #a9b8bd;
  margin-top: 2px;
}

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

.nav-item {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  background: transparent;
  color: #dbe7eb;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  background: #19343b;
  color: #ffffff;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 12px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.check-row {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.check-card {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.check-card input {
  width: 18px;
  height: 18px;
}

.check-card small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.sidebar-note {
  margin-top: auto;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px;
  color: #c8d6da;
  font-size: 13px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #2dd4bf;
}

.shell {
  margin-left: 260px;
  min-height: 100vh;
  padding: 24px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 17px;
}

.topbar p,
.muted {
  margin-top: 5px;
  color: var(--muted);
}

.top-actions,
.toolbar,
.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-head {
  justify-content: space-between;
  margin-bottom: 14px;
}

.icon-btn,
.ghost-btn,
.primary-btn {
  min-height: 38px;
  border-radius: 6px;
  border: 1px solid var(--line);
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.icon-btn {
  width: 38px;
  padding: 0;
  font-size: 20px;
}

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

.ghost-btn:hover,
.icon-btn:hover {
  border-color: var(--accent);
}

.load-state,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: #e8eef2;
  color: #334155;
  font-size: 13px;
}

.badge.ok {
  background: #dff7ed;
  color: var(--ok);
}

.badge.warn {
  background: #fff4db;
  color: var(--warn);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

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

.metric {
  padding: 16px;
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.panel {
  padding: 16px;
  min-width: 0;
}

.two-col,
.payroll-grid,
.billing-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.billing-summary-panel,
.billing-grid {
  margin-bottom: 16px;
}

.split {
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.toolbar {
  margin-bottom: 14px;
}

.search,
.select,
.form-grid input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

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

.search:focus,
.select:focus,
.form-grid input:focus {
  border-color: var(--accent);
}

.list-panel {
  max-height: calc(100vh - 140px);
  overflow: auto;
}

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

.row-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fff;
  cursor: pointer;
}

.row-card:hover,
.row-card.active {
  border-color: var(--accent);
  background: #f0fbfa;
}

.row-card strong {
  display: block;
  margin-bottom: 4px;
}

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

.detail-panel {
  min-height: 500px;
}

.empty {
  display: grid;
  min-height: 220px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.small-empty {
  min-height: 72px;
}

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

.fact {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

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

.fact strong {
  display: block;
  margin-top: 5px;
}

.data-table {
  max-height: calc(100vh - 210px);
  overflow: auto;
}

.data-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px 8px;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: #475467;
  z-index: 1;
}

.compact {
  max-height: 560px;
}

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

.mini-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.validation-list {
  display: grid;
  gap: 7px;
}

.validation-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

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

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

.payment-form button {
  grid-column: auto;
}

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

.tiny-btn {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
}

.tiny-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.summary-line {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
}

.summary-line strong {
  font-size: 18px;
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 31, 36, 0.58);
}

.confirm-overlay[hidden] {
  display: none;
}

.confirm-box {
  width: min(520px, 100%);
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
  padding: 18px;
}

.confirm-text {
  display: grid;
  gap: 8px;
  margin: 14px 0 18px;
  color: #344054;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 1100px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }

  .two-col,
  .payroll-grid,
  .billing-grid,
  .split {
    grid-template-columns: 1fr;
  }

  .list-panel {
    max-height: 420px;
  }
}

@media (max-width: 760px) {
  .sidebar {
    position: static;
    width: auto;
    min-height: auto;
  }

  .shell {
    margin-left: 0;
    padding: 16px;
  }

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

  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

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