:root {
  --bg: #faf7f2;
  --bg-soft: #f2ede3;
  --panel: #ffffff;
  --panel-alt: #f6f2ea;
  --sidebar: #0b2b28;
  --sidebar-soft: #123a36;
  --text: #201d17;
  --muted: #6b6459;
  --line: #e6ddcd;
  --line-strong: #d8cbb2;
  --brand: #0d5c52;
  --brand-strong: #094039;
  --accent: #b6812c;
  --danger: #a3341f;
  --shadow: 0 4px 14px rgba(32, 29, 23, 0.06);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Public Sans", sans-serif;
  color: var(--text);
  background: var(--bg);
}

.app-shell {
  width: min(1460px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.login-shell {
  min-height: calc(100vh - 36px);
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(380px, 520px);
  justify-content: center;
  gap: 24px;
  align-items: center;
}

.login-aside {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0)),
    linear-gradient(145deg, var(--sidebar), var(--sidebar-soft));
  border-radius: 24px;
  color: #e8f2ef;
  padding: 36px;
  box-shadow: var(--shadow);
}

.login-aside h1,
.card-header h2,
.card-header h3,
.brand-name,
.stat-box strong,
th {
  font-family: "Fraunces", serif;
  margin: 0;
}

.login-aside h1 {
  margin-top: 10px;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
  font-weight: 600;
}

.login-copy {
  margin: 18px 0 0;
  color: #b9d4ce;
  font-size: 1rem;
  line-height: 1.6;
  max-width: 34ch;
}

.login-points {
  display: grid;
  gap: 12px;
  margin-top: 26px;
}

.login-points span {
  display: block;
  border: 1px solid rgba(232, 242, 239, 0.16);
  background: rgba(255, 255, 255, 0.03);
  padding: 14px 16px;
  border-radius: 14px;
  color: #d7e8e3;
  font-size: 0.92rem;
}

.eyebrow {
  margin: 0;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.74rem;
  font-weight: 700;
}

.login-aside .eyebrow {
  color: #6fcabb;
}

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

.login-card {
  padding: 28px;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.card-header.compact {
  display: grid;
  gap: 6px;
}

.card-header h2,
.card-header h3 {
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card-header p,
.status-text,
.error-text,
.subtle-text {
  margin: 0;
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

label {
  display: grid;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #423d33;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 11px 13px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(13, 92, 82, 0.12);
}

button {
  border: 0;
  border-radius: 10px;
  padding: 11px 16px;
  cursor: pointer;
  transition: background 140ms ease, transform 140ms ease, border-color 140ms ease;
}

button:hover {
  transform: translateY(-1px);
}

.primary-btn {
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  color: #fff;
  font-weight: 700;
}

.ghost-btn {
  background: #fff;
  color: #423d33;
  border: 1px solid var(--line);
}

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

.sidebar {
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-soft));
  border-radius: 20px;
  padding: 22px 16px;
  min-height: calc(100vh - 36px);
  position: sticky;
  top: 18px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 22px;
  border-bottom: 1px solid rgba(232, 242, 239, 0.12);
  margin-bottom: 18px;
}

.brand-glyph {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(232, 242, 239, 0.1);
  color: #eafbf6;
  font-family: "Fraunces", serif;
  font-weight: 600;
  flex-shrink: 0;
}

.brand-eyebrow {
  margin: 0;
  color: #7fcdbe;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 0.66rem;
  font-weight: 700;
}

.brand-name {
  margin: 2px 0 0;
  color: #eef6f3;
  font-size: 1.02rem;
}

.side-nav {
  display: grid;
  gap: 4px;
  flex: 1;
  align-content: start;
}

.side-nav-item {
  background: transparent;
  color: #b9d4ce;
  border: 0;
  border-radius: 10px;
  padding: 11px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 0.92rem;
}

.side-nav-item:hover {
  background: rgba(232, 242, 239, 0.06);
  transform: none;
}

.side-nav-item.active {
  background: rgba(232, 242, 239, 0.12);
  color: #ffffff;
}

.sidebar-footer {
  display: grid;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid rgba(232, 242, 239, 0.12);
}

.sidebar-footer .ghost-btn {
  background: transparent;
  border-color: rgba(232, 242, 239, 0.18);
  color: #dcece7;
}

.main-area {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.main-topbar {
  padding: 4px 4px 6px;
}

.main-topbar h2 {
  font-family: "Fraunces", serif;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

.main-topbar p {
  margin: 6px 0 0;
}

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

.view > * {
  min-width: 0;
}

.panel {
  padding: 20px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.stat-box {
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.stat-box span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-box strong {
  display: block;
  margin-top: 8px;
  font-size: 1.45rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* Dashboard KPI grids */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.recon-grid {
  margin-top: 16px;
}

.stat-settled { border-left: 4px solid #0d5c42; }
.stat-shortfall { border-left: 4px solid var(--danger); }
.stat-overpaid { border-left: 4px solid #8a5a12; }
.stat-unmatched { border-left: 4px solid var(--muted); }

.dash-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.dash-meta span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.dash-meta strong {
  display: block;
  margin-top: 6px;
  font-family: "Fraunces", serif;
  font-size: 1.1rem;
  font-weight: 600;
}

/* Records screen toolbar (search left, actions right) */
.records-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

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

.topbar-actions,
.table-actions,
.search-bar {
  display: flex;
  gap: 10px;
  align-items: center;
}

.search-bar {
  flex-wrap: wrap;
  flex: 1 1 320px;
}

.search-bar input {
  flex: 1 1 240px;
}

.table-actions {
  flex-wrap: wrap;
}

a.ghost-btn {
  display: inline-block;
  padding: 11px 16px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
}

.danger-btn {
  background: #fff;
  color: var(--danger);
  border: 1px solid #e6c4bd;
  font-weight: 700;
}

.danger-btn:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.results-layout {
  display: grid;
  gap: 18px;
}

.data-panel {
  padding-bottom: 12px;
}

.card-header.split {
  margin-bottom: 14px;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 250px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--bg-soft);
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: var(--panel-alt);
  color: #423d33;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  z-index: 1;
}

tbody tr:nth-child(even) {
  background: #fdfcfa;
}

tbody tr:hover {
  background: #f5efe2;
}

.highlight-row {
  background: #fbeeea !important;
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-settled {
  background: #e3f1ea;
  color: #0d5c42;
}

.status-shortfall {
  background: #fbe9e4;
  color: var(--danger);
}

.status-overpaid {
  background: #fbf1de;
  color: #8a5a12;
}

.status-pending {
  background: var(--bg-soft);
  color: var(--muted);
}

.reconcile-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.reconcile-item {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-alt);
}

.reconcile-actions {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

/* Row-selection checkbox column (leftmost). */
.select-col,
.select-cell {
  width: 40px;
  text-align: center;
  padding-left: 8px;
  padding-right: 8px;
}

.select-col input,
.select-cell input,
.row-select {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--brand);
}

/* Keep the Actions column pinned to the right so Edit is always
   reachable without horizontal scrolling on the wide tables. */
.actions-cell,
th.actions-col {
  position: sticky;
  right: 0;
  white-space: nowrap;
  z-index: 2;
  box-shadow: -8px 0 12px -8px rgba(32, 29, 23, 0.18);
}

.actions-cell {
  background: #fff;
}

th.actions-col {
  background: var(--panel-alt);
  z-index: 3;
}

tbody tr:nth-child(even) .actions-cell {
  background: #fdfcfa;
}

tbody tr:hover .actions-cell {
  background: #f5efe2;
}

.highlight-row .actions-cell {
  background: #fbeeea;
}

.icon-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: #423d33;
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  margin-right: 6px;
}

.icon-btn:hover {
  transform: none;
  border-color: var(--brand);
}

.icon-btn-danger {
  color: var(--danger);
}

.icon-btn-danger:hover {
  border-color: var(--danger);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 43, 40, 0.42);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}

.modal {
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.modal-fields {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 18px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

@media (max-width: 640px) {
  .modal-fields {
    grid-template-columns: 1fr;
  }
}

.hidden {
  display: none !important;
}

.error-text {
  min-height: 20px;
  color: var(--danger);
}

.status-text {
  min-height: 20px;
  font-size: 0.9rem;
}

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

  .sidebar {
    position: static;
    min-height: 0;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
  }

  .brand-mark {
    border-bottom: 0;
    margin-bottom: 0;
    padding-bottom: 6px;
  }

  .side-nav {
    flex-direction: row;
    flex: none;
  }

  .sidebar-footer {
    border-top: 0;
    flex-direction: row;
    padding-top: 0;
    margin-left: auto;
  }

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

  .table-wrap {
    max-height: none;
  }
}

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

@media (max-width: 640px) {
  .app-shell {
    width: min(100%, calc(100% - 20px));
    padding: 10px 0 20px;
  }

  .panel,
  .login-card,
  .login-aside {
    padding: 16px;
  }

  .sidebar {
    flex-direction: column;
    align-items: stretch;
  }

  .side-nav {
    flex-direction: column;
  }

  .sidebar-footer {
    flex-direction: column;
    margin-left: 0;
  }

  .search-bar,
  .table-actions {
    width: 100%;
  }

  .search-bar button,
  .table-actions button {
    flex: 1 1 auto;
  }
}

@media print {
  body {
    background: #fff;
  }

  .login-shell,
  .sidebar,
  .main-topbar,
  .import-panel,
  .records-toolbar,
  .reconcile-panel,
  .kpi-grid,
  .dash-meta,
  .actions-cell,
  th.actions-col,
  .status-text,
  .modal-overlay {
    display: none !important;
  }

  .app-shell,
  .dashboard,
  .main-area,
  .view,
  .panel {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    background: #fff;
    box-shadow: none;
    border: 0;
  }

  .table-wrap {
    max-height: none;
    overflow: visible;
    border: 0;
  }
}
