:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-strong: #16213e;
  --text: #182230;
  --muted: #667085;
  --line: #d7dfec;
  --accent: #0e9384;
  --accent-dark: #107569;
  --danger: #d92d20;
  --warn: #dc6803;
  --ok: #079455;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(14, 147, 132, 0.12), rgba(99, 102, 241, 0.10) 42%, rgba(251, 191, 36, 0.10)),
    var(--bg);
  color: var(--text);
}

.login-page {
  min-height: 100vh;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(440px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(16, 24, 40, 0.16);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}

.login-mascot {
  width: 96px;
  aspect-ratio: 2 / 3;
  object-fit: contain;
  filter: drop-shadow(0 12px 18px rgba(16, 24, 40, 0.20));
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-error {
  display: none;
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 700;
}

.login-failed .login-error {
  display: block;
}

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

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

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

.brand-block {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.brand-mascot {
  width: clamp(92px, 12vw, 150px);
  aspect-ratio: 2 / 3;
  object-fit: contain;
  filter: drop-shadow(0 18px 24px rgba(16, 24, 40, 0.20));
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 4px;
  color: #0f766e;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1;
}

h2 {
  font-size: 1.05rem;
}

h3 {
  font-size: 0.95rem;
  margin: 0;
}

.actions,
.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

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

button,
.file-button {
  border: 1px solid transparent;
  border-radius: 8px;
  background: linear-gradient(135deg, #16213e, #344054);
  color: #fff;
  min-height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 700;
}

button:hover,
.file-button:hover {
  background: #2b3645;
}

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

button.secondary:hover {
  background: #f8fafc;
}

button.danger {
  background: #fff;
  color: var(--danger);
  border-color: #f2b8b5;
}

button.danger:hover {
  background: #fff4f2;
}

.file-button input {
  display: none;
}

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

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

.metrics article,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 35px rgba(16, 24, 40, 0.08);
}

.metrics article {
  position: relative;
  overflow: hidden;
  padding: 16px;
}

.metrics article::before {
  content: "";
  display: block;
  width: 44px;
  height: 5px;
  border-radius: 999px;
  margin-bottom: 13px;
  background: #0e9384;
}

.metrics article.focus {
  border-color: #c7d7fe;
  box-shadow: 0 18px 42px rgba(79, 70, 229, 0.18);
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.metrics strong {
  display: block;
  font-size: clamp(1.25rem, 2vw, 1.85rem);
  line-height: 1.1;
}

.metric-help {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.35;
  margin: 8px 0 0;
}

.metrics strong.negative {
  color: var(--danger);
}

.metric-green {
  background: #ecfdf3;
}

.metric-green::before {
  background: #12b76a;
}

.metric-blue {
  background: #eff8ff;
}

.metric-blue::before {
  background: #2e90fa;
}

.metric-cyan {
  background: #ecfdff;
}

.metric-cyan::before {
  background: #06aed4;
}

.metric-purple {
  background: #f4f3ff;
}

.metric-purple::before {
  background: #7a5af8;
}

.metric-amber {
  background: #fffaeb;
}

.metric-amber::before {
  background: #f79009;
}

.metric-orange {
  background: #fff6ed;
}

.metric-orange::before {
  background: #fb6514;
}

.metric-red {
  background: #fff1f3;
}

.metric-red::before {
  background: #e31b54;
}

.metric-indigo {
  background: #eef4ff;
}

.metric-indigo::before {
  background: #444ce7;
}

.metric-pink {
  background: #fdf2fa;
}

.metric-pink::before {
  background: #dd2590;
}

.metric-violet {
  background: #f5f3ff;
}

.metric-violet::before {
  background: #875bf7;
}

.metric-slate {
  background: #f8fafc;
}

.metric-slate::before {
  background: #475467;
}

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

.overview-group {
  display: grid;
  gap: 10px;
  border-radius: 8px;
  padding: 12px;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.72);
}

.overview-group h2 {
  border-radius: 8px;
  color: #fff;
  display: inline-flex;
  width: fit-content;
  padding: 7px 12px;
}

.overview-group.combined .metrics article {
  border-color: #c7d7fe;
}

.overview-bp {
  border-color: #2e90fa;
  background: linear-gradient(135deg, rgba(46, 144, 250, 0.16), rgba(239, 248, 255, 0.86));
}

.overview-bp h2 {
  background: #175cd3;
}

.overview-bp .metrics article {
  border: 2px solid #2e90fa;
}

.overview-morrisons {
  border-color: #12b76a;
  background: linear-gradient(135deg, rgba(18, 183, 106, 0.16), rgba(236, 253, 243, 0.88));
}

.overview-morrisons h2 {
  background: #067647;
}

.overview-morrisons .metrics article {
  border: 2px solid #12b76a;
}

.overview-group.combined h2 {
  background: #444ce7;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.panel {
  padding: 18px;
}

form {
  display: grid;
  gap: 14px;
}

.logout-form {
  display: flex;
  gap: 0;
}

.form-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-size: 0.82rem;
  font-weight: 700;
}

.field-help {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.35;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  min-height: 42px;
  padding: 9px 11px;
}

input[readonly] {
  background: #f8fafc;
  color: #475467;
  font-weight: 800;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  border-color: var(--accent);
}

#saveEntry {
  background: var(--accent);
}

#saveEntry:hover {
  background: var(--accent-dark);
}

.records-panel {
  min-width: 0;
}

.filter-panel {
  margin-bottom: 18px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  gap: 12px;
}

.filter-label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  margin: 12px 0 0;
}

.view-toggle {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

.view-toggle button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.breakdown-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  display: grid;
  gap: 12px;
  padding: 14px;
}

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

.breakdown-rows {
  display: grid;
  gap: 10px;
}

.salary-row {
  align-items: end;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(100px, 0.8fr) auto;
  gap: 10px;
}

.remove-salary-row {
  min-height: 42px;
}

.records-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.filters input {
  width: min(260px, 45vw);
}

.filters select {
  width: 210px;
}

.entry-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.summary-table-wrap {
  overflow-x: auto;
}

.summary-table {
  border-collapse: collapse;
  min-width: 980px;
  width: 100%;
}

.summary-table th,
.summary-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  white-space: nowrap;
}

.summary-table th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.summary-table td {
  font-size: 0.9rem;
}

.negative-cell {
  color: var(--danger);
  font-weight: 800;
}

.entry-card {
  border: 1px solid var(--line);
  border-left: 6px solid #7a5af8;
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  display: grid;
  gap: 12px;
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.06);
}

.entry-card.branch-bp {
  border-left-color: #2e90fa;
  border-top-color: #2e90fa;
  background: linear-gradient(135deg, #ffffff 0%, #eff8ff 100%);
}

.entry-card.branch-morrisons {
  border-left-color: #12b76a;
  border-top-color: #12b76a;
  background: linear-gradient(135deg, #ffffff 0%, #ecfdf3 100%);
}

.entry-card.editing {
  border-color: #7a5af8;
  box-shadow: 0 0 0 3px rgba(122, 90, 248, 0.18), 0 10px 24px rgba(16, 24, 40, 0.06);
}

.entry-card.cash_payment {
  border-left-color: #12b76a;
}

.entry-card.safe_drop_actual,
.entry-card.safe_drop_validated {
  border-left-color: #06aed4;
}

.entry-card.cash_and_carry,
.entry-card.salaries_cash {
  border-left-color: #f79009;
}

.entry-card.director_cash_taken {
  border-left-color: #e31b54;
}

.entry-card.bank_deposit {
  border-left-color: #7a5af8;
}

.entry-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.entry-amount {
  font-size: 1.35rem;
  line-height: 1.1;
  color: #101828;
  white-space: nowrap;
}

.entry-card-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.entry-card-body div {
  min-width: 0;
}

.entry-card-body span {
  color: var(--muted);
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.entry-card-body strong {
  color: #1d2939;
  display: block;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.entry-card-body [data-field="branch"] {
  border-radius: 8px;
  display: inline-flex;
  padding: 4px 9px;
  width: fit-content;
  font-weight: 900;
}

.branch-bp .entry-card-body [data-field="branch"] {
  background: #175cd3;
  color: #fff;
}

.branch-morrisons .entry-card-body [data-field="branch"] {
  background: #067647;
  color: #fff;
}

.entry-note {
  grid-column: 1 / -1;
}

.status {
  border-radius: 8px;
  display: inline-flex;
  max-width: 100%;
  justify-content: center;
  padding: 4px 9px;
  font-weight: 800;
  font-size: 0.78rem;
  background: #eef4ff;
  color: #3538cd;
}

.status.cash_payment {
  background: #dcfae6;
  color: var(--ok);
}

.status.safe_drop_actual,
.status.safe_drop_validated {
  background: #dff7fb;
  color: #0e7090;
}

.status.cash_and_carry,
.status.salaries_cash,
.status.director_cash_taken {
  background: #fff1d6;
  color: var(--warn);
}

.status.bank_deposit {
  background: #f4ebff;
  color: #6941c6;
}

.entry-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.delete-row,
.edit-row {
  justify-self: end;
  min-height: 34px;
  padding: 0 10px;
}

.delete-row {
  background: #fff;
  color: var(--danger);
  border-color: #f2b8b5;
}

.delete-row:hover {
  background: #fff4f2;
}

.empty {
  margin: 26px 0 12px;
  color: var(--muted);
  text-align: center;
}

.hidden {
  display: none;
}

@media (max-width: 980px) {
  .topbar,
  .records-header {
    align-items: flex-start;
    flex-direction: column;
  }

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

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

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

@media (max-width: 560px) {
  .shell {
    padding: 16px;
  }

  .metrics,
  .grid,
  .filter-grid {
    grid-template-columns: 1fr;
  }

  .actions,
  .filters {
    width: 100%;
  }

  .actions button,
  .actions .file-button,
  .filters input,
  .filters select {
    width: 100%;
  }

  .entry-list {
    grid-template-columns: 1fr;
  }

  .entry-card-body {
    grid-template-columns: 1fr;
  }

  .form-heading,
  .entry-actions,
  .breakdown-header,
  .salary-row {
    align-items: stretch;
    flex-direction: column;
  }

  .salary-row {
    display: flex;
  }

  .brand-block {
    align-items: flex-start;
    justify-content: space-between;
    width: 100%;
  }

  .brand-mascot {
    width: 86px;
  }
}
