@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@500;700;800&family=Space+Grotesk:wght@600;700&display=swap");

:root {
  color-scheme: light;
  --bg: #e9efef;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-strong: #e7f3f1;
  --ink: #0f1c22;
  --muted: #5f7379;
  --line: #c9d8d7;
  --accent: #0b7a78;
  --accent-strong: #075d5d;
  --income: #087a4f;
  --expense: #bc2f2f;
  --shadow: 0 18px 40px rgba(10, 35, 43, 0.1);
  --shadow-strong: 0 24px 70px rgba(8, 38, 48, 0.14);
  font-family: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: radial-gradient(circle at 12% 12%, rgba(11, 122, 120, 0.18), rgba(233, 239, 239, 0) 32%),
    radial-gradient(circle at 88% 10%, rgba(7, 93, 93, 0.14), rgba(233, 239, 239, 0) 38%),
    linear-gradient(180deg, #eef3f3 0%, var(--bg) 80%);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 26px 18px 46px;
}

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

.auth-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.93), rgba(250, 255, 255, 0.78));
  box-shadow: var(--shadow-strong);
  backdrop-filter: blur(10px);
  padding: 22px;
}

.auth-panel h1 {
  font-size: clamp(1.8rem, 7vw, 2.4rem);
  margin-bottom: 18px;
}

.login-error {
  color: var(--expense);
  margin: 12px 0 0;
  font-size: 0.9rem;
  font-weight: 700;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.app-header > div:first-child {
  min-width: 0;
  flex: 1 1 auto;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  font-family: "Space Grotesk", "Manrope", sans-serif;
  margin-bottom: 0;
  font-size: clamp(2rem, 6vw, 3.5rem);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

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

.summary-panel > div,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(7px);
}

.summary-panel > div {
  min-width: 0;
  padding: 18px;
}

.summary-panel span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

.summary-panel strong {
  display: block;
  overflow-wrap: anywhere;
  font-family: "Space Grotesk", "Manrope", sans-serif;
  font-size: clamp(1.5rem, 4vw, 2.35rem);
  line-height: 1.05;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.workspace-grid > .panel:first-child {
  order: 2;
}

.workspace-grid > .panel:nth-child(2) {
  order: 1;
}

.panel {
  padding: 18px;
}

.panel-heading,
.history-heading,
.dialog-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.form-stack {
  display: grid;
  gap: 14px;
}

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

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  padding: 0 12px;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(11, 122, 120, 0.18);
  transform: translateY(-1px);
}

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

.money-input:focus-within {
  border-color: var(--accent);
  outline: 3px solid rgba(21, 94, 117, 0.18);
}

.money-input input {
  border: 0;
  border-radius: 0;
  outline: 0;
}

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

.file-input {
  padding: 10px 12px;
}

.primary-button,
.secondary-button,
.text-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  padding: 0 16px;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), #09918e);
  color: #fff;
  box-shadow: 0 10px 26px rgba(11, 122, 120, 0.25);
}

.primary-button:hover {
  background: linear-gradient(135deg, var(--accent-strong), #0b7a78);
}

.secondary-button {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #eef7f6, #e5f1f0);
  color: var(--accent);
}

.secondary-button:hover {
  border-color: rgba(21, 94, 117, 0.38);
  background: #e3f1ef;
}

.text-button {
  min-height: 38px;
  padding: 0 12px;
  background: linear-gradient(180deg, #edf5f4, #e3efed);
  color: var(--accent);
}

.icon-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  background: linear-gradient(180deg, #f6fbfb, #ecf4f3);
  color: var(--accent);
  border: 1px solid var(--line);
  transition: transform 120ms ease, border-color 120ms ease;
}

.icon-button:hover {
  transform: translateY(-1px);
  border-color: rgba(11, 122, 120, 0.42);
}

.receipt-preview {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.receipt-preview img {
  width: 74px;
  height: 74px;
  border-radius: 6px;
  object-fit: cover;
}

.receipt-preview p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.movement-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.movement-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  min-height: 70px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
}

.movement-main {
  min-width: 0;
}

.movement-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-bottom: 4px;
  font-weight: 800;
}

.movement-title span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.movement-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

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

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

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

.pill {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 3px 8px;
  background: rgba(11, 122, 120, 0.12);
  color: #0b6c6b;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 38px 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state svg {
  width: 38px;
  height: 38px;
}

.empty-state p {
  margin: 0;
}

.receipt-dialog,
.camera-dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  border: 0;
  border-radius: 8px;
  padding: 14px;
}

.receipt-dialog::backdrop,
.camera-dialog::backdrop {
  background: rgba(23, 33, 36, 0.6);
}

.receipt-dialog img {
  display: block;
  width: 100%;
  max-height: calc(100vh - 110px);
  object-fit: contain;
  border-radius: 8px;
  background: #f5f5f5;
}

.camera-dialog video {
  display: block;
  width: 100%;
  max-height: calc(100vh - 170px);
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 8px;
  background: #172124;
}

.camera-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  gap: 10px;
  margin-top: 12px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #0f1c22;
  color: #fff;
  box-shadow: var(--shadow);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

.hidden {
  display: none !important;
}

@media (max-width: 760px) {
  body {
    overflow-x: hidden;
  }

  .app-shell {
    width: 100%;
    padding: 18px 8px 30px;
  }

  .app-header {
    gap: 10px;
    margin-bottom: 12px;
  }

  .app-header h1 {
    font-size: 2.05rem;
    line-height: 0.9;
    max-width: 11ch;
  }

  .header-actions {
    gap: 6px;
    flex: 0 0 auto;
  }

  .header-actions .icon-button {
    width: 34px;
    height: 34px;
  }

  .header-actions .text-button {
    min-height: 34px;
    padding: 0 10px;
    font-size: 0.78rem;
  }

  main {
    display: flex;
    flex-direction: column;
  }

  .workspace-grid {
    order: 1;
  }

  .history-panel {
    order: 2;
  }

  .summary-panel {
    gap: 6px;
    order: 3;
  }

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

  .summary-panel > div {
    padding: 8px 10px;
  }

  .summary-panel span {
    margin-bottom: 4px;
    font-size: 0.64rem;
  }

  .summary-panel strong {
    font-size: 1.05rem;
    line-height: 1.02;
  }

  .panel {
    min-width: 0;
    padding: 12px;
  }

  .history-heading {
    flex-wrap: wrap;
    gap: 8px;
  }

  .history-heading h2 {
    margin-right: auto;
  }

  .history-heading .text-button {
    min-height: 32px;
    padding: 0 10px;
    font-size: 0.74rem;
  }

  .movement-item {
    grid-template-columns: minmax(0, 1fr);
    padding: 10px;
    gap: 8px;
    overflow: hidden;
  }

  .row-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .row-actions .icon-button {
    width: 36px;
    height: 36px;
  }

  .receipt-preview {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .receipt-preview .icon-button {
    grid-column: 1 / -1;
    width: 100%;
  }

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