:root {
  --bg: #111315;
  --surface: #181b1f;
  --surface-2: #20252b;
  --surface-3: #29313a;
  --text: #f7f4ef;
  --text-soft: #c8c2ba;
  --muted: #8f969e;
  --line: rgba(255, 255, 255, 0.11);
  --accent: #10b981;
  --accent-2: #38bdf8;
  --accent-3: #f59e0b;
  --danger: #fb7185;
  --danger-bg: rgba(190, 18, 60, 0.18);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

body {
  background:
    linear-gradient(140deg, rgba(16, 185, 129, 0.12), transparent 28rem),
    linear-gradient(320deg, rgba(56, 189, 248, 0.1), transparent 24rem),
    #111315;
}

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

button {
  min-height: 42px;
  border: 1px solid rgba(16, 185, 129, 0.42);
  border-radius: 8px;
  padding: 0 16px;
  color: #061b14;
  background: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.ghost-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
  padding: 12px 13px;
  outline: none;
}

select option {
  background: #20252b;
  color: var(--text);
}

textarea {
  resize: vertical;
  line-height: 1.6;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(16, 185, 129, 0.75);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.13);
}

label {
  display: grid;
  gap: 8px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 650;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.login-panel {
  width: min(100%, 430px);
  display: grid;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  background: rgba(24, 27, 31, 0.9);
}

.login-panel h1,
.topbar h1 {
  font-size: clamp(28px, 6vw, 46px);
  line-height: 1.05;
}

.login-panel p {
  color: var(--muted);
  line-height: 1.7;
}

.error,
.warning-list {
  border-radius: 8px;
  padding: 12px 14px;
  line-height: 1.55;
}

.error {
  color: #fecdd3;
  background: var(--danger-bg);
  border: 1px solid rgba(251, 113, 133, 0.34);
}

.warning-list {
  display: grid;
  gap: 6px;
  color: #fde68a;
  background: rgba(245, 158, 11, 0.13);
  border: 1px solid rgba(245, 158, 11, 0.28);
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 0 22px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.primary-menu {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
  padding: 12px;
  background: rgba(24, 27, 31, 0.88);
}

.month-menu {
  display: flex;
  width: min(100%, 300px);
  align-items: center;
  grid-template-columns: none;
  gap: 12px;
}

.month-menu span {
  color: var(--text);
  font-size: 15px;
}

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

.metric-card,
.input-panel,
.list-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24, 27, 31, 0.88);
}

.metric-card {
  display: grid;
  gap: 9px;
  padding: 18px;
}

.metric-card span,
.entry-meta,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  font-size: clamp(24px, 5vw, 36px);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 14px;
  align-items: start;
}

.input-panel,
.list-panel {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.section-heading,
.draft-head,
.draft-actions,
.entry-head,
.entry-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-heading h2,
.draft-head h3 {
  margin-top: 4px;
  font-size: 22px;
}

.month-input {
  max-width: 180px;
}

.parse-form,
.draft-form {
  display: grid;
  gap: 16px;
}

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

.items-editor {
  display: grid;
  gap: 10px;
}

.item-row {
  display: grid;
  grid-template-columns: 90px minmax(88px, 0.75fr) 86px minmax(120px, 1fr) minmax(120px, 1fr) 42px;
  gap: 8px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.icon-button {
  min-width: 42px;
  padding: 0;
  color: #ffe4e6;
  background: rgba(251, 113, 133, 0.12);
  border-color: rgba(251, 113, 133, 0.38);
}

.category-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.category-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.035);
  font-size: 13px;
}

.entries-list {
  display: grid;
  gap: 10px;
}

.entry-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.035);
}

.entry-title {
  display: grid;
  gap: 4px;
}

.entry-title strong {
  font-size: 17px;
}

.entry-amount {
  font-size: 22px;
  font-weight: 800;
}

.entry-amount.out {
  color: #fca5a5;
}

.entry-amount.in {
  color: #86efac;
}

.entry-items {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.entry-item {
  color: var(--text-soft);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  padding: 6px 9px;
  font-size: 13px;
}

.delete-button {
  min-height: 34px;
  color: #ffe4e6;
  background: rgba(251, 113, 133, 0.12);
  border-color: rgba(251, 113, 133, 0.34);
}

.empty {
  padding: 24px 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: min(92vw, 520px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--text);
  background: rgba(32, 37, 43, 0.96);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.36);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 10, 12, 0.72);
}

.settings-dialog {
  width: min(100%, 620px);
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: rgba(24, 27, 31, 0.98);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
}

.dialog-head,
.settings-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-head h2 {
  margin-top: 4px;
  font-size: 24px;
}

.checkbox-label {
  display: flex;
  width: fit-content;
  align-items: center;
  grid-template-columns: none;
  gap: 10px;
}

.checkbox-label input {
  width: 18px;
  height: 18px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 860px) {
  .app-shell {
    padding: 18px;
  }

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

  .primary-menu,
  .month-menu {
    align-items: stretch;
    flex-direction: column;
  }

  .month-menu {
    width: 100%;
  }

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

  .icon-button {
    width: 100%;
  }
}

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

  .topbar,
  .section-heading,
  .draft-head,
  .draft-actions,
  .dialog-head,
  .settings-actions,
  .entry-head,
  .entry-foot {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions button {
    width: 100%;
  }

  .month-input {
    max-width: none;
  }
}
