:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #64748b;
  --line: #d9e2ec;
  --brand: #174a7c;
  --brand-2: #0f766e;
  --warn: #b45309;
  --bad: #b91c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}

a {
  color: var(--brand);
  text-decoration: none;
}

.topbar {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 24px;
  justify-content: space-between;
  min-height: 58px;
  padding: 0 24px;
}

.topbar strong {
  color: var(--brand);
  font-size: 18px;
  margin-right: 10px;
}

.topbar span {
  color: var(--muted);
}

.topbar nav {
  align-items: center;
  display: flex;
  gap: 14px;
  white-space: nowrap;
}

.logout-form {
  margin: 0;
}

.logout-button {
  background: none;
  border: 0;
  color: var(--brand);
  cursor: pointer;
  display: inline;
  min-height: auto;
  padding: 0;
}

.page {
  padding: 24px;
}

.page-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 18px;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 16px;
  margin-bottom: 12px;
}

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

.note {
  margin-bottom: 18px;
}

.muted {
  color: var(--muted);
}

.filters,
.form-grid {
  display: flex;
  gap: 10px;
}

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

input,
select,
button,
.button {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  min-height: 36px;
  padding: 7px 10px;
}

input[type="file"] {
  background: #ffffff;
  width: 100%;
}

.record-form small {
  color: var(--muted);
}

.record-form .errorlist {
  color: var(--bad);
  margin: 2px 0 0;
}

.location-kpis {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  padding: 7px 10px;
}

.button.secondary {
  background: #ffffff;
  border-color: var(--line);
  color: var(--brand);
}

.subnav {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  overflow-x: auto;
}

.subnav a {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  white-space: nowrap;
}

.clock-panel {
  background: linear-gradient(135deg, #174a7c, #0f766e);
  border-radius: 12px;
  color: #ffffff;
  margin-bottom: 18px;
  padding: 20px;
}

.clock-panel form {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(220px, 1fr) auto;
}

.clock-panel label {
  font-weight: 700;
  grid-column: 1 / -1;
}

.clock-panel select {
  min-height: 50px;
}

.clock-actions {
  display: flex;
  gap: 10px;
}

.clock-actions button {
  font-size: 18px;
  font-weight: 700;
  justify-content: center;
  min-height: 50px;
  min-width: 100px;
}

.clock-in { background: #15803d; border-color: #15803d; }
.clock-out { background: #c2410c; border-color: #c2410c; }

.panel-head,
.form-actions {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.search-filters {
  margin-bottom: 18px;
}

.search-filters input[type="search"] {
  min-width: 240px;
}

.form-panel { max-width: 760px; }
.record-form p { display: grid; gap: 6px; margin: 0 0 14px; }
.record-form input:not([type="checkbox"]), .record-form select { width: 100%; }
.record-form ul.errorlist { color: var(--bad); margin: 0; padding-left: 18px; }

.status {
  border-radius: 999px;
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  white-space: nowrap;
}

.status-ready, .status-present { background: #dcfce7; color: #166534; }
.status-hold, .status-absent, .status-unpaid_leave { background: #fee2e2; color: #991b1b; }
.status-weekly_off, .status-paid_leave { background: #dbeafe; color: #1e40af; }
td small { color: var(--muted); display: block; margin-top: 4px; }
.wide-table { min-width: 1500px; }

button,
.button {
  background: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.kpis {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 18px;
}

.kpis div,
.panel,
.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.kpis div {
  padding: 14px;
}

.kpis span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 8px;
}

.kpis strong {
  font-size: 20px;
}

.grid {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

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

.panel {
  overflow-x: auto;
  padding: 16px;
}

.panel.narrow {
  max-width: 640px;
}

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

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

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

.badge {
  border-radius: 999px;
  display: inline-block;
  font-size: 12px;
  padding: 3px 8px;
}

.badge.high {
  background: #d1fae5;
  color: #065f46;
}

.badge.moderate {
  background: #e0f2fe;
  color: #075985;
}

.badge.low {
  background: #fee2e2;
  color: #991b1b;
}

.messages {
  margin-bottom: 16px;
}

.message {
  border-radius: 6px;
  margin-bottom: 8px;
  padding: 10px 12px;
}

.message.success {
  background: #d1fae5;
  color: #065f46;
}

.message.error {
  background: #fee2e2;
  color: #991b1b;
}

.owner-primary-kpis {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}

.owner-primary-kpis .kpi-highlight {
  background: linear-gradient(135deg, #174a7c, #0f766e);
  color: #ffffff;
}

.owner-primary-kpis .kpi-highlight span,
.owner-primary-kpis .kpi-highlight small {
  color: #dbeafe;
}

.owner-primary-kpis small,
.channel-grid small {
  color: var(--muted);
  display: block;
  margin-top: 6px;
}

.owner-section {
  margin-bottom: 18px;
}

.channel-grid,
.cash-summary,
.denomination-grid,
.form-grid-two {
  display: grid;
  gap: 12px;
}

.channel-grid {
  grid-template-columns: repeat(5, minmax(130px, 1fr));
}

.channel-grid > div,
.cash-summary > div {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.channel-grid span,
.cash-summary span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 7px;
}

.channel-grid strong,
.cash-summary strong {
  font-size: 19px;
}

.cash-summary {
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 14px;
}

.amount-short { color: #b91c1c; }
.amount-excess { color: #b45309; }
.amount-balanced { color: #15803d; }

.empty-action {
  align-items: flex-start;
  background: #f8fafc;
  border: 1px dashed var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
}

.empty-action p,
.owner-note { margin: 0; }

.owner-performance-grid { align-items: start; }
.owner-performance-grid .total-row td { border-top: 2px solid #c9d7e8; }
.owner-performance-grid .result-row td { background: #f5f9fd; font-size: 1.05rem; }
.funding-panel { overflow: hidden; }

.funding-total {
  align-items: center;
  background: linear-gradient(135deg, #0f4c81, #176e78);
  border-radius: 10px;
  color: #fff;
  display: flex;
  justify-content: space-between;
  margin: 12px 0;
  padding: 16px 18px;
}

.funding-total span { opacity: .9; }
.funding-total strong,
.funding-heading-total { font-size: 1.6rem; }

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

.funding-buckets > div {
  background: #f5f8fc;
  border: 1px solid #d9e3ef;
  border-left: 4px solid #7a94b2;
  border-radius: 8px;
  padding: 11px 12px;
}

.funding-buckets .overdue { border-left-color: #c7352d; }
.funding-buckets .urgent { border-left-color: #e88a19; }
.funding-buckets .upcoming { border-left-color: #d2ad15; }
.funding-buckets span,
.funding-buckets strong { display: block; }
.funding-buckets span { color: var(--muted); font-size: .82rem; }
.funding-buckets strong { font-size: 1.1rem; margin-top: 3px; }

.due-alert {
  border-radius: 999px;
  display: inline-block;
  font-size: .78rem;
  font-weight: 700;
  padding: 4px 8px;
  white-space: nowrap;
}

.due-overdue { background: #fde2e0; color: #a51f19; }
.due-urgent { background: #fff0d8; color: #9b5706; }
.due-upcoming { background: #fff8cf; color: #725d00; }
.amount-missing { color: #a51f19; font-weight: 700; }

.alert-note {
  background: #fff8e5;
  border: 1px solid #f0d37b;
  border-radius: 8px;
  color: #6c5600;
  margin: 12px 0;
  padding: 10px 12px;
}

.compact-table td,
.compact-table th { padding: 9px 8px; }
.utility-funding-panel { margin-bottom: 22px; }
.owner-month-result small { color: var(--muted); display: block; font-size: .78rem; font-weight: 400; margin-top: 4px; }
.finance-report-title { border-bottom: 2px solid var(--brand); margin-bottom: 16px; padding-bottom: 10px; }
.finance-report-title h1 { margin-bottom: 4px; }
.finance-signoff { display: grid; gap: 30px; grid-template-columns: repeat(3, 1fr); margin-top: 52px; }

@media print {
  .topbar,
  .print-hide,
  .messages { display: none !important; }
  .page { padding: 0; }
  .panel.finance-print-report { border: 0; box-shadow: none; padding: 0; }
  .funding-total { background: #fff; border: 2px solid #174a7c; color: #111827; }
  .finance-print-report table { font-size: 11px; }
}

.table-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.table-actions form { margin: 0; }
.button.danger { background: #b91c1c; border-color: #b91c1c; }

.denomination-grid {
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  margin-bottom: 18px;
}

.form-grid-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 18px;
}

.denomination-grid p,
.form-grid-two p { margin: 0; }

.cash-form-panel { max-width: 900px; }

.cash-review-layout {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(300px, 34vw) minmax(760px, 1fr);
}

.scan-preview {
  position: sticky;
  top: 12px;
}

.scan-preview img,
.scan-preview iframe {
  background: #f8fafc;
  border: 1px solid var(--line);
  display: block;
  margin-bottom: 12px;
  max-height: 72vh;
  object-fit: contain;
  width: 100%;
}

.scan-preview iframe { height: 72vh; }
.hourly-review-table input[type="number"] { min-width: 62px; width: 70px; }
.hourly-review-table input[type="text"] { min-width: 130px; }
.wide-cash-table { min-width: 1060px; }
.closing-grid { grid-template-columns: repeat(6, minmax(100px, 1fr)); }
.signature-check { border-left: 5px solid var(--brand-2); }
.upload-confirmation { margin: 40px auto; }
.upload-confirmation h1 { margin-top: 14px; }
.upload-confirmation .form-actions { justify-content: flex-start; margin-top: 20px; }

.upload-drop-panel {
  border: 2px dashed #94a3b8;
  margin-bottom: 18px;
  max-width: 760px;
  padding: 24px;
}

.simple-upload-form input[type="file"] {
  min-height: 54px;
  padding: 14px;
}

.simple-upload-form button {
  font-size: 16px;
  font-weight: 700;
  justify-content: center;
  min-height: 46px;
  width: 100%;
}

.auto-extract-note { margin-bottom: 18px; }

.pagination {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 16px;
}

.login-body {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

.login-panel {
  padding: 28px;
  width: min(420px, calc(100vw - 32px));
}

.login-panel h1 {
  color: var(--brand);
}

.login-panel form p {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.login-panel button {
  justify-content: center;
  width: 100%;
}

@media (max-width: 1000px) {
  .topbar,
  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar nav,
  .filters {
    flex-wrap: wrap;
  }

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

  .owner-primary-kpis,
  .channel-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .funding-buckets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cash-review-layout { grid-template-columns: 1fr; }
  .scan-preview { position: static; }
  .closing-grid { grid-template-columns: repeat(3, minmax(100px, 1fr)); }
}

@media (max-width: 640px) {
  .page {
    padding: 16px;
  }

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

  .clock-panel form { grid-template-columns: 1fr; }
  .clock-actions button { flex: 1; min-width: 0; }
  .filters { align-items: stretch; flex-direction: column; }
  .search-filters input[type="search"] { min-width: 0; width: 100%; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .owner-primary-kpis,
  .channel-grid,
  .funding-buckets,
  .cash-summary,
  .denomination-grid,
  .form-grid-two { grid-template-columns: 1fr; }
  .closing-grid { grid-template-columns: 1fr 1fr; }
}
