:root {
  color-scheme: light;
  --paper: #fff8ec;
  --cream: #f5ead8;
  --sand: #e8d9bf;
  --gold: #f1b800;
  --gold-dark: #b88200;
  --wood: #7b5a35;
  --ink: #171714;
  --soft-ink: #5f574c;
  --line: rgba(48, 38, 24, 0.14);
  --danger: #a94f3f;
  --green: #4d6b52;
  --shadow: 0 18px 44px rgba(70, 52, 28, 0.12);
  --radius: 16px;
  --font-body: "Avenir Next", Avenir, "Trebuchet MS", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-display: var(--font-body);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--cream);
  font-family: var(--font-body);
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: end center;
  padding: calc(24px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom));
  background: url("/assets/vault-lock.png") center / cover no-repeat;
}

.status-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  color: var(--ink);
  background: var(--cream);
}

.status-screen h1 {
  font-size: clamp(1.55rem, 8vw, 2.4rem);
  font-weight: 560;
  text-align: center;
}

.login-panel {
  width: min(420px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 18px;
  padding: 24px;
  color: var(--paper);
  background: rgba(43, 31, 20, 0.46);
  box-shadow: 0 24px 80px rgba(36, 25, 15, 0.32);
  backdrop-filter: blur(22px);
}

.login-panel .muted,
.login-panel label {
  color: rgba(255, 248, 236, 0.78);
}

.login-panel input,
.login-panel select,
.login-panel textarea {
  border-color: rgba(255, 248, 236, 0.24);
  color: var(--paper);
  background: rgba(255, 255, 255, 0.12);
}

.pin-screen {
  min-height: 100vh;
  color: var(--paper);
  background: url("/assets/vault-lock.png") center / cover no-repeat;
}

.pin-stage {
  display: grid;
  min-height: 100vh;
  align-content: center;
  justify-items: center;
  gap: 18px;
  padding: calc(18px + env(safe-area-inset-top)) 18px calc(18px + env(safe-area-inset-bottom));
}

.pin-stage .notice {
  align-self: center;
  justify-self: center;
  max-width: min(360px, 92vw);
  margin: 10px 0 0;
  color: var(--paper);
  background: rgba(84, 38, 24, 0.56);
  backdrop-filter: blur(12px);
}

.pin-message {
  min-height: 48px;
  text-align: center;
}

.pin-message span {
  display: inline-block;
  border: 1px solid rgba(255, 248, 236, 0.18);
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--paper);
  background: rgba(39, 27, 16, 0.28);
  font-size: 0.92rem;
  font-weight: 520;
  backdrop-filter: blur(12px);
}

.pin-form {
  display: grid;
  justify-items: center;
  gap: 18px;
  margin: 0;
  padding: 0;
  background: transparent;
}

.pin-hidden-input {
  position: absolute;
  width: 1px;
  min-height: 1px;
  margin: -1px;
  border: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}

.pin-dots {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: center;
  min-height: 30px;
}

.pin-dots span {
  width: 14px;
  height: 14px;
  border: 1px solid rgba(255, 248, 236, 0.72);
  border-radius: 999px;
  background: rgba(255, 248, 236, 0.2);
  box-shadow: 0 3px 14px rgba(31, 22, 13, 0.22);
}

.pin-dots span.filled {
  background: var(--paper);
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  gap: 14px 30px;
  justify-content: center;
}

.pin-key {
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  border: 1px solid rgba(255, 248, 236, 0.18);
  border-radius: 50%;
  color: var(--paper);
  background: rgba(255, 248, 236, 0.16);
  box-shadow: 0 8px 26px rgba(28, 19, 11, 0.2);
  font-size: 2rem;
  font-weight: 420;
  backdrop-filter: blur(14px);
}

.pin-key:active {
  transform: translateY(1px) scale(0.98);
  background: rgba(255, 248, 236, 0.26);
}

.pin-key-delete {
  font-size: 1.45rem;
}

.brand-row {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 22px;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(48, 38, 24, 0.12);
  border-radius: 14px;
  color: var(--ink);
  background: var(--paper);
  font-weight: 700;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

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

h1 {
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 5vw, 2.55rem);
  font-weight: 650;
  letter-spacing: 0;
}

h2 {
  font-family: var(--font-display);
  font-size: 1.28rem;
  font-weight: 650;
}

h3 {
  font-size: 1rem;
}

.muted {
  margin: 6px 0 0;
  color: var(--soft-ink);
  line-height: 1.4;
}

.notice {
  margin: 0 0 16px;
  border: 1px solid rgba(241, 184, 0, 0.28);
  border-radius: 14px;
  padding: 11px 12px;
  color: #6f4d00;
  background: rgba(241, 184, 0, 0.13);
}

.text-button {
  margin-top: 14px;
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.app-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--cream);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  padding: 22px;
  background: rgba(255, 248, 236, 0.78);
  backdrop-filter: blur(18px);
}

.workspace-title {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
}

.workspace-title h2 {
  font-size: 1.25rem;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: flex-start;
  border: 1px solid transparent;
  border-radius: 13px;
  padding: 10px 12px;
  color: var(--soft-ink);
  background: rgba(255, 255, 255, 0.44);
  text-align: left;
}

.nav button.active {
  border-color: rgba(184, 130, 0, 0.24);
  color: var(--ink);
  background: var(--gold);
  box-shadow: 0 12px 26px rgba(184, 130, 0, 0.22);
}

.sidebar-footer {
  position: absolute;
  right: 22px;
  bottom: 22px;
  left: 22px;
  display: grid;
  gap: 10px;
}

.user-pill {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
}

.avatar {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: var(--paper);
  background: var(--wood);
  font-size: 0.82rem;
  font-weight: 700;
}

.main {
  min-width: 0;
  padding: 26px;
}

.topbar {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.topbar h1 {
  max-width: 760px;
}

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

.panel,
.metric-card,
.bucket-card,
.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 248, 236, 0.74);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.section-grid {
  display: grid;
  gap: 16px;
}

.quick-layout,
.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 430px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.quick-panel {
  position: sticky;
  top: 24px;
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: 18px;
  padding: 18px;
  background: rgba(255, 248, 236, 0.92);
  box-shadow: var(--shadow);
}

.quick-form {
  display: grid;
  gap: 13px;
}

.amount-field input {
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 10px 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  font-size: clamp(2.35rem, 10vw, 3.45rem);
  font-weight: 560;
  letter-spacing: 0;
  box-shadow: none;
}

.amount-field input::placeholder {
  color: rgba(95, 87, 76, 0.42);
}

.quick-more {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.quick-more summary {
  cursor: pointer;
  color: var(--soft-ink);
  font-weight: 650;
}

.quick-more .form-grid {
  margin-top: 12px;
}

.quick-save {
  min-height: 56px;
  border: 0;
  border-radius: 15px;
  color: var(--ink);
  background: var(--gold);
  font-size: 1.05rem;
  font-weight: 650;
  box-shadow: 0 14px 30px rgba(184, 130, 0, 0.2);
}

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

.filters {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.field {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

label,
.field-label {
  color: var(--soft-ink);
  font-size: 0.76rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 13px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
  font-size: 16px;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

input[type="date"],
input[type="month"] {
  max-inline-size: 100%;
  min-inline-size: 0;
  appearance: none;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(241, 184, 0, 0.24);
  border-color: var(--gold-dark);
}

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

.segmented button,
.btn {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 9px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.52);
}

.segmented button.active,
.btn.primary {
  border-color: transparent;
  color: var(--ink);
  background: var(--gold);
  font-weight: 650;
}

.btn.ghost {
  background: transparent;
}

.btn.danger {
  border-color: rgba(169, 79, 63, 0.28);
  color: var(--danger);
  background: rgba(169, 79, 63, 0.08);
}

.row-delete {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.86rem;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.dashboard-flow {
  display: grid;
  gap: 16px;
}

.analytics-hero {
  display: flex;
  gap: 18px;
  align-items: end;
  justify-content: space-between;
  border-radius: 18px;
  padding: 20px;
  color: var(--paper);
  background: #171714;
  box-shadow: var(--shadow);
}

.analytics-hero h2 {
  margin-top: 8px;
  font-family: var(--font-body);
  font-size: clamp(2.3rem, 8vw, 4.1rem);
  font-weight: 650;
}

.analytics-hero .muted,
.analytics-hero label {
  color: rgba(255, 248, 236, 0.72);
}

.analytics-hero input {
  border-color: rgba(255, 248, 236, 0.18);
  color: var(--paper);
  background: rgba(255, 248, 236, 0.1);
}

.eyebrow {
  margin: 0;
  color: rgba(255, 248, 236, 0.72);
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.compact-field {
  min-width: 180px;
}

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

.analytics-card,
.chart-card,
.history-card {
  display: grid;
  align-content: start;
  gap: 14px;
}

.history-card {
  grid-column: span 2;
}

.analytics-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  color: var(--ink);
  background: var(--gold);
  font-weight: 700;
}

.stat-pair {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.stat-pair span {
  color: var(--soft-ink);
}

.stat-pair strong {
  color: var(--ink);
  font-size: 1.05rem;
}

.donut {
  display: grid;
  width: 132px;
  height: 132px;
  place-items: center;
  border: 16px solid var(--gold);
  border-radius: 50%;
  background: var(--paper);
}

.donut span {
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 700;
}

.entry-list,
.mobile-entry-list {
  display: grid;
  gap: 8px;
}

.entry-item,
.mobile-entry-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.46);
}

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

.entry-item strong,
.mobile-entry-card strong {
  display: block;
  color: var(--ink);
}

.entry-amount,
.mobile-entry-amount {
  white-space: nowrap;
  color: var(--danger);
  font-weight: 700;
}

.entry-amount.income,
.mobile-entry-amount.income {
  color: var(--green);
}

.mobile-entry-main {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.mobile-entry-card .tag-row {
  margin-top: 8px;
}

.mobile-entry-card .row-delete {
  margin-top: 10px;
}

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

.mobile-entry-list {
  display: none;
}

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

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

th {
  color: var(--soft-ink);
  font-size: 0.76rem;
  font-weight: 650;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.amount {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--soft-ink);
  background: rgba(123, 90, 53, 0.09);
  font-size: 0.78rem;
  line-height: 1;
  white-space: nowrap;
}

.tag.income {
  color: var(--green);
}

.tag.expense {
  color: var(--danger);
}

.tag.transfer {
  color: var(--gold-dark);
}

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

.bucket-card {
  padding: 16px;
}

.bucket-top {
  display: flex;
  gap: 12px;
  align-items: start;
  justify-content: space-between;
}

.progress {
  height: 10px;
  margin: 14px 0 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #ead8bb;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--gold);
}

.empty-state {
  padding: 28px 16px;
  color: var(--soft-ink);
  text-align: center;
}

.hidden {
  display: none !important;
}

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

  .split-grid,
  .quick-layout,
  .bucket-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 780px) {
  .app-layout {
    display: block;
    min-height: 100vh;
    padding-top: env(safe-area-inset-top);
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px 10px 8px;
  }

  .workspace-title,
  .sidebar-footer,
  .toolbar-actions {
    display: none;
  }

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

  .nav button {
    min-height: 42px;
    justify-content: center;
    border-radius: 12px;
    padding: 8px 4px;
    font-size: clamp(0.68rem, 2.6vw, 0.82rem);
    text-align: center;
  }

  .main {
    padding: 16px 14px calc(28px + env(safe-area-inset-bottom));
  }

  .topbar {
    display: block;
    margin-bottom: 16px;
  }

  .topbar h1 {
    font-size: clamp(1.6rem, 7vw, 2.2rem);
  }

  .topbar .muted {
    font-size: 1rem;
  }

  .panel,
  .quick-panel,
  .table-wrap,
  .bucket-card,
  .metric-card {
    border-radius: 16px;
  }

  .quick-panel {
    position: static;
    padding: 16px;
  }

  .quick-layout {
    gap: 14px;
  }

  .amount-field input {
    min-height: 76px;
    font-size: clamp(2.4rem, 13vw, 3.4rem);
  }

  .form-grid,
  .filters,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .filters {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  .filters .field,
  .filters input,
  .filters select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .analytics-hero {
    display: grid;
    padding: 18px;
  }

  .analytics-hero h2 {
    font-size: clamp(2.2rem, 12vw, 3.4rem);
  }

  .history-card {
    grid-column: auto;
  }

  .table-wrap {
    overflow: visible;
  }

  .table-wrap table {
    display: none;
  }

  .mobile-entry-list {
    display: grid;
  }
}

@media (max-width: 420px) {
  .main {
    padding-right: 12px;
    padding-left: 12px;
  }

  .panel,
  .quick-panel {
    padding: 14px;
  }

  h2 {
    font-size: 1.22rem;
  }

  .pin-pad {
    grid-template-columns: repeat(3, 64px);
    gap: 12px 24px;
  }

  .pin-key {
    width: 64px;
    height: 64px;
    font-size: 1.8rem;
  }

  .pin-form {
    padding-bottom: 0;
  }
}
