:root {
  --bg: #eef3f2;
  --surface: #ffffff;
  --surface-soft: #f6f9f8;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e4e1;
  --brand: #123d35;
  --brand-2: #0f766e;
  --danger: #b42318;
  --ok: #087f5b;
  --shadow: 0 8px 24px rgba(23, 32, 51, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Tahoma, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

body.locked .sidebar,
body.locked .shell {
  filter: blur(2px);
  pointer-events: none;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 16, 20, 0.74);
}

body.locked .login-screen {
  display: flex;
}

.login-card {
  width: min(390px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
}

.login-card img {
  width: 92px;
  height: 92px;
  object-fit: cover;
  border-radius: 8px;
  justify-self: center;
  background: #111;
}

.login-card strong,
.login-card span {
  text-align: center;
}

.login-card strong {
  font-size: 24px;
  color: var(--brand);
}

.login-card span,
.login-card p {
  margin: 0;
  color: var(--muted);
}

button,
input,
select,
textarea {
  font: inherit;
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.sidebar {
  background: linear-gradient(180deg, #101418 0%, #123d35 100%);
  color: #fff;
  min-height: 100vh;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.brand-logo {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: #111;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
}

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

.brand strong {
  font-size: 18px;
  line-height: 1.2;
}

.brand span {
  color: rgba(255, 255, 255, 0.76);
  font-size: 12px;
  margin-top: 5px;
  line-height: 1.35;
}

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

.nav-item {
  width: 100%;
  border: 0;
  color: rgba(255, 255, 255, 0.84);
  background: transparent;
  padding: 10px 12px;
  text-align: right;
  cursor: pointer;
  border-radius: 6px;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.side-note {
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}

.side-note strong,
.side-note span {
  display: block;
}

.side-note span {
  color: rgba(255, 255, 255, 0.72);
  margin-top: 6px;
  line-height: 1.6;
}

.shell {
  min-width: 0;
  padding: 18px;
}

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

.topbar h1 {
  margin: 0;
  color: var(--brand);
  font-size: 24px;
}

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

.top-actions,
.form-actions,
.inline-search {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-chip {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--brand);
  background: var(--surface);
  white-space: nowrap;
}

button {
  min-height: 38px;
  border-radius: 6px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  cursor: pointer;
  background: var(--surface);
  color: var(--ink);
}

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

.ghost {
  background: var(--surface);
  color: var(--brand);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

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

.kpi {
  padding: 16px;
}

.kpi span {
  color: var(--muted);
  display: block;
  margin-bottom: 8px;
}

.kpi strong {
  font-size: 26px;
  color: var(--brand);
}

.grid.two {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 14px;
}

.panel {
  padding: 14px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin: 0;
  font-size: 18px;
  color: var(--brand);
}

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

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

.table-wrap.tall {
  max-height: calc(100vh - 190px);
}

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

th,
td {
  padding: 10px 9px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: top;
  white-space: nowrap;
}

th {
  background: var(--surface-soft);
  color: var(--brand);
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
}

td {
  color: var(--ink);
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--brand);
  font-weight: 700;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.wide {
  grid-column: span 4;
}

.form-actions {
  grid-column: span 4;
  justify-content: flex-start;
}

.multi-items {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 8px;
  padding: 12px;
}

.multi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.multi-head strong,
.multi-head span {
  display: block;
}

.multi-head strong {
  color: var(--brand);
  margin-bottom: 4px;
}

.multi-head span {
  color: var(--muted);
  font-weight: 400;
}

#saveStatus {
  color: var(--muted);
}

.search,
.inline-search input {
  min-width: 260px;
}

.inline-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.table-action {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--brand);
  border-radius: 7px;
  padding: 6px 10px;
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.table-action:hover {
  border-color: var(--brand);
}

.statement-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

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

.statement-summary div {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 8px;
  padding: 12px;
}

.statement-summary span {
  color: var(--muted);
  display: block;
  margin-bottom: 6px;
}

.statement-summary strong {
  color: var(--brand);
  font-size: 20px;
}

.subhead {
  margin: 0 0 10px;
  color: var(--brand);
  font-size: 15px;
}

.num {
  direction: ltr;
  text-align: left;
}

.credit {
  color: var(--ok);
  font-weight: 700;
}

.debit {
  color: var(--danger);
  font-weight: 700;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 18px;
}

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

  .sidebar {
    min-height: auto;
    position: static;
  }

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

  .grid.two,
  .kpi-grid,
  .statement-summary {
    grid-template-columns: 1fr;
  }

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

  .wide,
  .form-actions {
    grid-column: span 1;
  }

  .topbar,
  .panel-head,
  .multi-head {
    align-items: stretch;
    flex-direction: column;
  }
}
