:root {
  color-scheme: light;
  --bg: #f7f4ef;
  --surface: #ffffff;
  --ink: #18212f;
  --muted: #6b7280;
  --line: #d8dee8;
  --accent: #1f7a8c;
  --accent-dark: #145366;
  --green: #5d7c45;
  --red: #aa3d3d;
  --yellow: #f3cc6b;
  --shadow: 0 14px 34px rgba(24, 33, 47, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(31, 122, 140, 0.12), transparent 260px),
    var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(100%, 680px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px max(24px, env(safe-area-inset-bottom));
}

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

.login-panel {
  width: min(100%, 420px);
  border: 1px solid rgba(216, 222, 232, 0.9);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 20px;
}

.login-form {
  margin-top: 20px;
}

.login-error {
  margin: 0;
  border: 1px solid #efcaca;
  border-radius: 8px;
  background: #fff1f1;
  color: var(--red);
  padding: 10px 12px;
  font-weight: 700;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 2px 18px;
}

.eyebrow,
.field span,
.status {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.status[data-type="error"] {
  border: 1px solid #efcaca;
  border-radius: 8px;
  background: #fff1f1;
  color: var(--red);
  padding: 10px 12px;
  font-weight: 700;
}

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

h1 {
  font-size: 2.1rem;
  line-height: 1;
}

.logout-link {
  display: inline-block;
  margin-top: 8px;
  color: var(--accent-dark);
  font-size: 0.86rem;
  font-weight: 800;
  text-decoration: none;
}

h2 {
  font-size: 1rem;
}

.month-total {
  min-width: 134px;
  padding: 10px 12px;
  border: 1px solid rgba(31, 122, 140, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  text-align: right;
}

.month-total span,
.month-total strong {
  display: block;
}

.month-total span {
  color: var(--muted);
  font-size: 0.78rem;
}

.month-total strong {
  margin-top: 3px;
  color: var(--accent-dark);
  font-size: 1.02rem;
}

.quick-panel,
.view {
  border: 1px solid rgba(216, 222, 232, 0.9);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.quick-panel {
  padding: 16px;
}

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

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

.field {
  display: grid;
  gap: 7px;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
}

.password-field {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.password-field input {
  border: 0;
}

.password-toggle {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.password-toggle.active {
  color: var(--accent-dark);
}

.password-toggle svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(31, 122, 140, 0.22);
  outline-offset: 2px;
}

.money-input {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.money-input input {
  border: 0;
  font-size: 1.55rem;
  font-weight: 700;
}

.money-input b {
  padding-right: 12px;
  color: var(--muted);
}

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

.category-button,
.quick-expense {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
  color: var(--ink);
  text-align: left;
  padding: 9px 10px;
}

.quick-expense {
  display: grid;
  gap: 2px;
  background: #fff8e6;
}

.quick-expense span {
  color: var(--muted);
  font-size: 0.78rem;
}

.category-button.active {
  border-color: var(--accent);
  background: #e8f4f6;
  color: var(--accent-dark);
  font-weight: 700;
}

.primary-action,
.secondary-action,
.text-button,
.icon-button,
.tab {
  border: 0;
  cursor: pointer;
}

.primary-action {
  min-height: 52px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.secondary-action {
  min-height: 48px;
  border-radius: 8px;
  background: #eaf2f8;
  color: var(--accent-dark);
  font-weight: 800;
}

.secondary-action.subtle {
  background: #edf1f5;
  color: var(--muted);
}

.text-button {
  background: transparent;
  color: var(--accent-dark);
  font-weight: 700;
}

.text-button.danger {
  color: var(--red);
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #edf1f5;
  color: var(--muted);
  font-weight: 900;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 14px 0;
  padding: 6px;
  border: 1px solid rgba(216, 222, 232, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
}

.tab {
  min-height: 42px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.tab.active {
  background: var(--ink);
  color: #fff;
}

.view {
  display: none;
  padding: 14px;
}

.view.active {
  display: block;
}

.expense-list,
.summary-grid,
.export-actions {
  display: grid;
  gap: 9px;
}

.history-filters {
  display: grid;
  grid-template-columns: 0.8fr 1fr;
  gap: 8px;
}

.history-total {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  margin-bottom: 10px;
  border: 1px solid rgba(93, 124, 69, 0.42);
  border-radius: 8px;
  background: #eef4e9;
  padding: 11px;
}

.history-total span {
  color: var(--muted);
  font-size: 0.83rem;
}

.history-total strong {
  color: var(--green);
}

.expense-item,
.summary-item,
.empty-state,
.import-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 11px;
}

.expense-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.expense-main strong,
.summary-item strong {
  display: block;
}

.expense-main span,
.summary-item span {
  color: var(--muted);
  font-size: 0.83rem;
}

.expense-amount {
  text-align: right;
  font-weight: 900;
}

.expense-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 8px;
}

.delete-expense,
.edit-expense {
  min-width: 34px;
  height: 34px;
  border: 0;
  border-radius: 17px;
  padding: 0 10px;
  font-weight: 900;
}

.delete-expense {
  background: #f7e7e7;
  color: var(--red);
}

.edit-expense {
  background: #edf1f5;
  color: var(--accent-dark);
  font-size: 0.78rem;
}

.summary-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
}

.summary-item.total {
  border-color: rgba(93, 124, 69, 0.42);
  background: #eef4e9;
}

.empty-state {
  display: grid;
  gap: 4px;
  text-align: center;
}

.import-box {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

@media (min-width: 560px) {
  .category-grid,
  .frequent-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .export-actions {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 380px) {
  .tab {
    font-size: 0.82rem;
  }
}
