:root {
  --bg: #f6f3ec;
  --panel: #ffffff;
  --ink: #202327;
  --muted: #68707a;
  --line: #d9ded6;
  --green: #2c7a61;
  --green-dark: #145843;
  --blue: #2d5f93;
  --rose: #b85252;
  --yellow: #d9a441;
  --shadow: 0 18px 40px rgba(36, 42, 39, 0.12);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.lock-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(130deg, rgba(44, 122, 97, 0.16), transparent 42%),
    linear-gradient(310deg, rgba(217, 164, 65, 0.2), transparent 46%),
    var(--bg);
}

.lock-panel {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green-dark);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
}

h2 {
  font-size: 1.05rem;
}

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

.tiny {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.pin-form,
.data-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

label {
  display: grid;
  gap: 7px;
  color: #3d444b;
  font-size: 0.86rem;
  font-weight: 700;
}

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

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(45, 95, 147, 0.22);
  outline-offset: 2px;
}

.pin-form button,
.primary-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: white;
  font-weight: 800;
  padding: 10px 14px;
}

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

.topbar,
.toolbar,
.panel-head,
.top-actions,
.settings-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar {
  padding: 10px 0 18px;
}

.top-actions {
  justify-content: flex-end;
}

.ghost-button,
.icon-button,
.danger-button,
.import-label {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  min-height: 40px;
  padding: 9px 13px;
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 1.25rem;
}

.danger-button {
  border-color: rgba(184, 82, 82, 0.35);
  color: var(--rose);
}

.import-label {
  display: inline-grid;
  place-items: center;
  position: relative;
}

.import-label input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab {
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  padding: 13px 14px 11px;
  white-space: nowrap;
}

.tab.active {
  border-color: var(--green);
  color: var(--ink);
}

.view {
  display: none;
  padding-top: 22px;
}

.view.active {
  display: block;
}

.toolbar {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.toolbar label {
  width: min(230px, 100%);
}

.today-button {
  align-self: end;
  min-width: 82px;
}

.formula-note {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

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

.metric,
.chart-panel,
.form-panel,
.table-section,
.danger-zone,
.inventory-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 26px rgba(36, 42, 39, 0.06);
}

.metric {
  display: grid;
  gap: 8px;
  min-height: 112px;
  padding: 18px;
}

.metric span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.metric strong {
  font-size: clamp(1.35rem, 2.8vw, 2rem);
}

.metric.highlight {
  background: #e8f1ea;
  border-color: #bdd8c5;
}

.chart-row {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 14px;
  margin-top: 14px;
}

.chart-panel,
.form-panel,
.table-section,
.danger-zone {
  padding: 18px;
}

canvas {
  display: block;
  width: 100%;
  height: 260px;
  margin-top: 14px;
}

.table-section,
.danger-zone {
  margin-top: 14px;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 12px;
}

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

th,
td {
  border-bottom: 1px solid #e7eae6;
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: #56606a;
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

td {
  font-size: 0.92rem;
}

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

.data-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
}

.data-form .wide {
  grid-column: span 2;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-actions button {
  flex: 1;
}

.row-action {
  border: 0;
  background: transparent;
  font-weight: 800;
  padding: 4px;
}

.row-action.edit {
  color: var(--blue);
}

.row-action.delete {
  color: var(--rose);
}

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

.inventory-card {
  padding: 16px;
}

.inventory-card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.inventory-card p {
  margin: 6px 0;
  color: #3f4850;
  line-height: 1.42;
}

.chip {
  display: inline-block;
  margin-bottom: 10px;
  border-radius: 999px;
  background: #edf3f8;
  color: var(--blue);
  font-size: 0.76rem;
  font-weight: 800;
  padding: 4px 9px;
}

.type-chip {
  display: inline-block;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 800;
  padding: 4px 9px;
}

.type-chip.deposit {
  background: #e8f1ea;
  color: var(--green-dark);
}

.type-chip.withdrawal {
  background: #f8ecec;
  color: var(--rose);
}

@media (max-width: 850px) {
  .app-screen {
    padding: 16px;
  }

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

  .summary-grid,
  .chart-row,
  .inventory-list,
  .data-form {
    grid-template-columns: 1fr;
  }

  .data-form .wide {
    grid-column: auto;
  }

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