:root {
  --bg: #f4f2ec;
  --surface: #ffffff;
  --surface-soft: #ebe8df;
  --text: #1f2322;
  --muted: #6d736f;
  --line: #ddd8cc;
  --primary: #147568;
  --primary-dark: #0d5c52;
  --income: #117a54;
  --expense: #b24747;
  --warning: #af721c;
  --shadow: 0 16px 42px rgba(31, 35, 34, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

body.auth-open .app {
  display: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.auth-screen {
  display: none;
  min-height: 100vh;
  place-items: center;
  padding: 22px;
}

body.auth-open .auth-screen {
  display: grid;
}

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

.auth-message {
  min-height: 22px;
  margin-bottom: 0;
  color: var(--expense);
  font-weight: 750;
}

.app-version {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: center;
}

.topbar,
.brand,
.day-switcher,
.online-actions,
.panel-heading,
.form-row,
.cash-inputs,
.method-row,
.difference-box {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.brand {
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-weight: 900;
}

.brand strong,
.brand small,
label span,
.summary-card span,
.summary-card small {
  display: block;
}

.brand strong {
  font-size: 1.1rem;
}

.brand small,
label span,
.summary-card span,
.summary-card small,
.eyebrow,
th {
  color: var(--muted);
}

.day-switcher {
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 8px;
  box-shadow: var(--shadow);
}

.online-actions {
  gap: 8px;
  margin-left: auto;
}

.online-actions select {
  min-width: 180px;
}

label span {
  margin-bottom: 5px;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

input:focus,
select:focus {
  border-color: var(--primary);
}

.icon-button,
.primary-button,
.secondary-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-weight: 850;
}

.icon-button {
  width: 42px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text);
  font-size: 1.3rem;
}

.primary-button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: white;
  padding: 0 16px;
}

.primary-button:hover {
  background: var(--primary-dark);
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 0 14px;
}

.full {
  width: 100%;
}

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

.summary-card,
.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary-card {
  min-height: 122px;
  padding: 17px;
}

.summary-card strong {
  display: block;
  margin: 12px 0 8px;
  font-size: clamp(1.45rem, 2.2vw, 2.25rem);
  line-height: 1;
}

.income strong,
.income-text {
  color: var(--income);
}

.expense strong,
.expense-text {
  color: var(--expense);
}

.result strong {
  color: var(--primary);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(310px, 0.7fr);
  gap: 12px;
  margin-bottom: 12px;
}

.panel {
  padding: 18px;
}

.panel-heading {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.eyebrow,
h1,
h2,
p {
  margin-top: 0;
}

.eyebrow {
  margin-bottom: 4px;
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin-bottom: 0;
  line-height: 1.12;
}

h1 {
  font-size: clamp(1.7rem, 3vw, 2.4rem);
}

h2 {
  font-size: 1.12rem;
}

.entry-form {
  display: grid;
  gap: 13px;
}

.form-row,
.cash-inputs {
  gap: 12px;
}

.form-row label,
.cash-inputs label {
  flex: 1;
}

.status-pill {
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 6px 11px;
  font-size: 0.8rem;
  font-weight: 850;
}

.version-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 850;
}

.status-pill.closed {
  background: #dcefe8;
  color: var(--income);
}

.close-panel {
  display: grid;
  align-content: start;
  gap: 12px;
}

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

.count-box {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

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

.count-heading span {
  color: var(--primary);
  font-weight: 900;
}

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

.cash-row {
  display: grid;
  grid-template-columns: minmax(58px, 0.8fr) minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 8px;
}

.cash-row strong {
  font-size: 0.88rem;
}

.cash-row input {
  min-height: 34px;
  padding: 0 8px;
}

.adjustment-field {
  display: block;
  margin-top: 10px;
}

.difference-box {
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 16px;
}

.difference-box span {
  color: var(--muted);
  font-weight: 800;
}

.difference-box strong {
  font-size: 1.5rem;
}

.difference-box.bad strong {
  color: var(--expense);
}

.difference-box.good strong {
  color: var(--income);
}

.lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(310px, 0.65fr);
  gap: 12px;
  min-width: 0;
}

.filter {
  width: 170px;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 12px;
  text-align: left;
}

th {
  font-size: 0.74rem;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.delete-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 900;
}

.method-list {
  display: grid;
  gap: 12px;
}

.method-row {
  gap: 12px;
}

.method-icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--primary);
  font-weight: 900;
}

.method-bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.method-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.method-main {
  flex: 1;
}

.method-main strong,
.method-main small {
  display: block;
}

.method-main small {
  color: var(--muted);
}

@media (max-width: 960px) {
  .topbar,
  .workspace,
  .lower-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .summary-grid,
  .workspace,
  .lower-grid {
    display: grid;
  }

  .day-switcher {
    width: 100%;
  }

  .online-actions {
    width: 100%;
    margin-left: 0;
  }

  .online-actions select {
    min-width: 0;
  }

  .day-switcher label {
    flex: 1;
  }
}

@media (max-width: 560px) {
  .app {
    padding: 14px;
  }

  .panel,
  .summary-card {
    padding: 14px;
  }

  .panel-heading,
  .form-row,
  .cash-inputs {
    align-items: stretch;
    flex-direction: column;
  }

  .cash-count-layout,
  .denomination-grid {
    grid-template-columns: 1fr;
  }

  .filter {
    width: 100%;
  }

  .summary-card {
    min-height: 104px;
  }
}
