:root {
  color-scheme: light;
  --bg: #edf5ff;
  --surface: #ffffff;
  --surface-2: #eff6ff;
  --ink: #14213d;
  --muted: #64748b;
  --line: #d9e6f5;
  --brand: #0b4bb3;
  --brand-dark: #073584;
  --brand-soft: #dbeafe;
  --income: #70bf2b;
  --income-soft: #dcfce7;
  --accent: #ffffff;
  --danger: #c83d4d;
  --warning: #f5b642;
  --cyan: #18bde8;
  --violet: #8056d8;
  --pink: #ef5b8c;
  --teal: #12a69a;
  --shadow: 0 18px 45px rgba(11, 75, 179, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(11, 75, 179, 0.12) 0 220px, transparent 220px),
    linear-gradient(135deg, #eaf3ff 0%, #f8fbff 46%, #edf8f1 100%);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

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

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

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
  border: 1px solid rgba(11, 75, 179, 0.2);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), transparent 34%),
    linear-gradient(135deg, #123bb8 0%, #0068d9 54%, #09b4d7 100%);
  box-shadow: 0 18px 45px rgba(8, 51, 148, 0.28);
  padding: 22px;
  color: #ffffff;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

.topbar .eyebrow {
  color: rgba(255, 255, 255, 0.78);
}

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

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

h2 {
  font-size: 1.05rem;
}

.month-picker {
  display: grid;
  gap: 6px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.9rem;
}

.topbar input {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(24, 189, 232, 0.18);
}

textarea {
  min-height: 86px;
  padding-top: 10px;
  resize: vertical;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(11, 75, 179, 0.18) 0 46%, transparent 46%),
    linear-gradient(135deg, #eaf3ff 0%, #ffffff 52%, #f1fbf7 100%);
  padding: 20px;
}

.auth-panel {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  border: 1px solid rgba(11, 75, 179, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 28px 70px rgba(8, 51, 148, 0.18);
  padding: 26px;
}

.auth-panel h1 {
  font-size: 2.25rem;
  color: var(--brand);
}

.auth-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--brand-dark);
  cursor: pointer;
  font-weight: 700;
  padding: 4px 0;
  text-align: left;
}

.link-button:hover {
  text-decoration: underline;
}

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

.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 20px;
}

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

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

.compact-summary .metric {
  min-height: 76px;
  padding: 14px 16px;
}

.compact-summary .metric strong {
  font-size: 1.1rem;
}

.tabs {
  display: flex;
  gap: 10px;
  margin: 0 0 16px;
  overflow-x: auto;
  padding: 2px 2px 8px;
}

.tab-button {
  --tab-color: var(--brand);
  min-height: 40px;
  border: 1px solid color-mix(in srgb, var(--tab-color) 32%, #ffffff);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.72)),
    color-mix(in srgb, var(--tab-color) 16%, #ffffff);
  color: color-mix(in srgb, var(--tab-color) 76%, #14213d);
  cursor: pointer;
  font-weight: 700;
  padding: 0 14px;
  white-space: nowrap;
  box-shadow: 0 8px 18px color-mix(in srgb, var(--tab-color) 14%, transparent);
}

.tab-button::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 7px;
  border-radius: 999px;
  background: var(--tab-color);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--tab-color) 18%, transparent);
}

.tab-button[data-tab="movements"] {
  --tab-color: #0877e8;
}

.tab-button[data-tab="budgets"] {
  --tab-color: #70bf2b;
}

.tab-button[data-tab="debts"] {
  --tab-color: #ef5753;
}

.tab-button[data-tab="cards"] {
  --tab-color: #8056d8;
}

.tab-button[data-tab="annual"] {
  --tab-color: #f5b642;
}

.tab-button[data-tab="data"] {
  --tab-color: #12a69a;
}

.tab-button.active {
  border-color: var(--tab-color);
  background:
    linear-gradient(135deg, var(--tab-color) 0%, color-mix(in srgb, var(--tab-color) 72%, #0b4bb3) 100%);
  color: #fff;
  box-shadow: 0 12px 26px color-mix(in srgb, var(--tab-color) 34%, transparent);
  transform: translateY(-1px);
}

.tab-button.active::before {
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.18);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

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

.compact-tools {
  grid-template-columns: repeat(2, minmax(280px, 420px));
  justify-content: start;
}

.metric {
  min-height: 96px;
  border: 1px solid rgba(217, 230, 245, 0.9);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.88)),
    linear-gradient(135deg, rgba(24, 189, 232, 0.1), rgba(112, 191, 43, 0.08));
  padding: 18px;
  box-shadow: var(--shadow);
  border-left: 6px solid var(--cyan);
}

.metric:nth-child(2) {
  border-left-color: var(--income);
}

.metric:nth-child(3) {
  border-left-color: var(--danger);
}

.metric:nth-child(4) {
  border-left-color: var(--warning);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  margin-bottom: 10px;
}

.metric strong {
  display: block;
  font-size: 1.45rem;
  line-height: 1.15;
}

.metric strong.positive,
.amount-col.positive {
  color: var(--income);
}

.metric strong.negative,
.amount-col.negative {
  color: var(--danger);
}

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

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.list-panel {
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
}

.form-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.mini-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 16px;
}

.extra-fields {
  display: grid;
  gap: 12px;
}

.extra-fields summary {
  min-height: 38px;
  display: grid;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--brand-dark);
  cursor: pointer;
  font-weight: 700;
  padding: 0 12px;
}

.extra-fields[open] {
  gap: 14px;
}

.scan-box {
  display: grid;
  gap: 10px;
  border: 1px dashed rgba(8, 119, 232, 0.38);
  border-radius: 8px;
  background: #eef7ff;
  padding: 14px;
}

.scan-box h3 {
  margin: 0 0 4px;
  font-size: 0.98rem;
}

.scan-box p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.scan-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.scan-button {
  min-height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--brand-dark);
  cursor: pointer;
  font-weight: 700;
}

.scan-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.scan-status {
  min-height: 20px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.scan-status strong {
  color: var(--brand-dark);
}

.receipt-items-panel {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(11, 75, 179, 0.18);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px;
}

.receipt-items-panel.hidden {
  display: none;
}

.receipt-items-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.receipt-items-head strong {
  color: var(--ink);
}

.receipt-items-head span {
  color: var(--muted);
  font-size: 0.82rem;
}

.receipt-items-list {
  display: grid;
  gap: 6px;
  max-height: 240px;
  overflow: auto;
}

.receipt-item-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--surface);
}

.receipt-item-row input {
  margin: 0;
}

.receipt-item-name {
  min-width: 0;
  font-size: 0.86rem;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.receipt-item-price {
  color: var(--brand-dark);
  font-size: 0.86rem;
  font-weight: 800;
  white-space: nowrap;
}

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

.article-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.article-card strong {
  display: block;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.article-total {
  color: var(--danger);
  font-weight: 900;
  white-space: nowrap;
}

.form-status {
  min-height: 20px;
  color: var(--danger);
  font-size: 0.86rem;
  line-height: 1.35;
}

.form-status.success {
  color: var(--brand-dark);
}

.receipt-preview {
  display: none;
  width: 100%;
  max-height: 180px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.receipt-preview.visible {
  display: block;
}

.receipt-thumb {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
}

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

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
}

.primary-button,
.secondary-button,
.icon-button,
.delete-button,
.edit-button,
.scan-button {
  border: 0;
  cursor: pointer;
  transition: transform 0.14s ease, background 0.14s ease;
}

.primary-button {
  min-height: 44px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand) 0%, #08aeea 100%);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 12px 24px rgba(11, 75, 179, 0.22);
}

.primary-button:hover {
  background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand) 100%);
  transform: translateY(-1px);
}

.secondary-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 14px;
  font-weight: 700;
}

.icon-button,
.delete-button,
.edit-button {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
}

.icon-button {
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 1.3rem;
  font-weight: 700;
}

.delete-button {
  background: #ffe8e8;
  color: var(--danger);
  font-weight: 700;
}

.edit-button {
  background: var(--surface-2);
  color: var(--brand-dark);
  font-weight: 700;
}

.list-panel {
  overflow: hidden;
}

.list-heading {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.list-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

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

.actions select,
.action-input {
  width: 150px;
}

.action-input {
  min-height: 38px;
}

.stack-list {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.stack-item {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffafa;
  padding: 10px;
}

.stack-item strong {
  color: var(--ink);
}

.progress-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.progress-fill {
  height: 100%;
  width: var(--progress, 0%);
  background: var(--income);
}

.progress-fill.warning {
  background: var(--brand);
}

.hidden {
  display: none !important;
}

.chart-wrap {
  padding: 18px 18px 4px;
}

canvas {
  display: block;
  width: 100%;
  max-height: 220px;
}

.table-wrap {
  position: relative;
  overflow-x: auto;
}

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

th,
td {
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.amount-col {
  text-align: right;
}

.delete-col {
  width: 104px;
}

td.amount-col {
  font-weight: 700;
}

.category-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: var(--surface-2);
  padding: 0 10px;
  font-size: 0.86rem;
  font-weight: 700;
}

.meta-pill,
.type-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.86rem;
  font-weight: 700;
}

.meta-pill {
  background: #f6f1f1;
  color: var(--muted);
}

.type-pill.expense {
  background: var(--surface-2);
  color: var(--brand-dark);
}

.type-pill.income {
  background: var(--income-soft);
  color: var(--income);
}

.empty-state {
  display: none;
  padding: 28px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
}

.empty-state.visible {
  display: block;
}

.movement-list-wrap {
  overflow-x: visible;
  padding: 12px 14px 18px;
}

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

.movement-card {
  --movement-color: var(--cyan);
  display: grid;
  grid-template-columns: 76px 48px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(217, 230, 245, 0.88);
  border-left: 6px solid var(--movement-color);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(20, 33, 61, 0.08);
  padding: 12px;
}

.movement-card.income {
  border-left-color: var(--income);
}

.movement-date {
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.25;
}

.movement-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--movement-color);
  color: #ffffff;
  font-weight: 800;
  box-shadow: 0 10px 20px color-mix(in srgb, var(--movement-color) 28%, transparent);
}

.movement-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.movement-title-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 0.95rem;
}

.movement-amount {
  white-space: nowrap;
  font-weight: 800;
}

.movement-amount.positive {
  color: var(--income);
}

.movement-amount.negative {
  color: var(--danger);
}

.movement-bar {
  width: min(360px, 100%);
  min-height: 28px;
  display: flex;
  align-items: center;
  margin: 6px 0 8px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, var(--movement-color) 0%, color-mix(in srgb, var(--movement-color) 72%, #ffffff) 100%);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0 12px;
}

.movement-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.movement-side {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.movement-actions {
  display: flex;
  gap: 6px;
}

.movement-c1 {
  --movement-color: #ef5753;
}

.movement-c2 {
  --movement-color: #ffbe55;
}

.movement-c3 {
  --movement-color: #ffe35a;
  --ink-on-movement: #14213d;
}

.movement-c4 {
  --movement-color: #82c64d;
}

.movement-c5 {
  --movement-color: #12a69a;
}

.movement-c6 {
  --movement-color: #63b7ee;
}

.movement-c7 {
  --movement-color: #8056d8;
}

.movement-c8 {
  --movement-color: #ef5b8c;
}

.movement-c3 .movement-icon,
.movement-c3 .movement-bar {
  color: var(--ink-on-movement);
}

@media (max-width: 860px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .compact-tools {
    grid-template-columns: 1fr;
  }

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

  .movement-card {
    grid-template-columns: 58px 42px minmax(0, 1fr);
  }

  .movement-side {
    grid-column: 3;
    justify-items: start;
  }

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

  .article-total {
    justify-self: start;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 18px 0;
  }

  .topbar,
  .list-heading {
    align-items: stretch;
    flex-direction: column;
  }

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

  .auth-actions {
    grid-template-columns: 1fr;
  }

  .scan-actions {
    grid-template-columns: 1fr;
  }

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

  .actions select,
  .action-input {
    width: 100%;
  }

  .movement-list-wrap {
    padding: 10px;
  }

  .movement-card {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .movement-icon {
    width: 38px;
    height: 38px;
  }

  .movement-title-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .movement-side {
    grid-column: auto;
    justify-items: start;
  }
}
