:root {
  color-scheme: dark;
  --bg: #071521;
  --surface: #0d2232;
  --surface-2: #123149;
  --line: #21445d;
  --text: #f5fbff;
  --muted: #9eb4c3;
  --green: #51e0a4;
  --green-dark: #0c714d;
  --yellow: #ffc766;
  --red: #ff7b7b;
  --shadow: 0 20px 60px rgba(0, 0, 0, .24);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at top, #12324a 0, var(--bg) 42rem); color: var(--text); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .78rem; }
.eyebrow { margin: 0 0 .35rem; color: var(--green); font-size: .72rem; font-weight: 800; letter-spacing: .14em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: .4rem; font-size: clamp(1.65rem, 7vw, 2.45rem); line-height: 1.06; }
h2 { margin-bottom: 0; font-size: 1.25rem; }

.auth-view { min-height: 100vh; display: grid; place-content: center; gap: 1rem; padding: 1.25rem; }
.brand-mark { display: grid; place-items: center; width: 3.5rem; height: 3.5rem; margin-inline: auto; border-radius: 1.1rem; color: #052014; background: var(--green); font-weight: 950; box-shadow: var(--shadow); }
.auth-card, .panel { border: 1px solid var(--line); background: rgba(13, 34, 50, .96); box-shadow: var(--shadow); }
.auth-card { width: min(100%, 29rem); padding: 1.4rem; border-radius: 1.4rem; }
.stack { display: grid; gap: 1rem; margin-top: 1.25rem; }
label { display: grid; gap: .45rem; color: #cce0ec; font-size: .86rem; font-weight: 750; }
input, select { width: 100%; min-height: 3rem; border: 1px solid var(--line); border-radius: .8rem; padding: .75rem .85rem; color: var(--text); background: #081a27; outline: none; }
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(81, 224, 164, .13); }
.primary, .secondary, .icon-button, .text-button { border: 0; border-radius: .8rem; min-height: 2.8rem; padding: .7rem 1rem; font-weight: 850; }
.primary { color: #042216; background: var(--green); }
.primary:hover { background: #70e9b7; }
.secondary { color: var(--text); background: var(--surface-2); }
.icon-button { color: var(--text); background: transparent; border: 1px solid var(--line); }
.text-button { min-height: auto; padding: .25rem; color: var(--green); background: transparent; }
.message { min-height: 1.3rem; margin: .9rem 0 0; color: var(--yellow); font-size: .88rem; }
.message.error { color: var(--red); }
.negative { color: var(--red) !important; }

.app-view { width: min(100%, 72rem); margin-inline: auto; padding: 1rem 1rem 5rem; }
.topbar, .identity-row, .panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.topbar { padding: 1rem 0 1.5rem; }
.identity-row { margin-bottom: 1rem; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: 1rem; background: rgba(8, 26, 39, .7); }
.identity-row strong, .identity-row span { display: block; }
.month-picker { min-width: 9.5rem; }
.month-picker input { min-height: 2.6rem; padding: .45rem .6rem; }
.banner { margin-bottom: 1rem; padding: .9rem 1rem; border-radius: .9rem; line-height: 1.45; }
.banner.warning { color: #352000; background: var(--yellow); }

.summary-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; }
.metric { min-height: 6.2rem; padding: 1rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); }
.metric span, .metric small { display: block; color: var(--muted); font-size: .78rem; }
.metric strong { display: block; margin-top: .35rem; font-size: 1.25rem; }
.hero-metric { grid-column: 1 / -1; min-height: 8rem; background: linear-gradient(135deg, #116643, #0d3e35); border-color: #2f9b72; }
.hero-metric strong { color: #fff; font-size: clamp(2rem, 9vw, 3.4rem); }

.panel { margin-top: 1rem; padding: 1rem; border-radius: 1.1rem; }
.panel-heading { margin-bottom: 1rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.wide { grid-column: 1 / -1; }
.money-input { display: flex; align-items: center; border: 1px solid var(--line); border-radius: .8rem; background: #081a27; }
.money-input:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(81, 224, 164, .13); }
.money-input span { padding-left: .8rem; color: var(--muted); }
.money-input input { border: 0; box-shadow: none; }
.money-input input:focus { box-shadow: none; }

.settings-panel summary { display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; }
.settings-panel summary::-webkit-details-marker { display: none; }
.settings-panel summary strong, .settings-panel summary span { display: block; }
.settings-panel[open] summary { margin-bottom: 1rem; }

.entry-list { display: grid; gap: .7rem; }
.entry-card { display: grid; grid-template-columns: 1fr auto; gap: .7rem; padding: .9rem; border: 1px solid var(--line); border-radius: .9rem; background: #091c2a; }
.entry-card strong, .entry-card span { display: block; }
.entry-card .available { color: var(--green); font-size: 1.08rem; }
.entry-card .negative { color: var(--red); }
.entry-card .entry-meta { margin-top: .25rem; color: var(--muted); font-size: .78rem; }
.entry-actions { display: flex; align-items: center; gap: .35rem; }
.entry-actions button { border: 0; border-radius: .55rem; padding: .5rem; color: var(--text); background: var(--surface-2); }
.empty { padding: 2rem 1rem; color: var(--muted); text-align: center; }

@media (min-width: 760px) {
  .app-view { padding: 1.5rem 2rem 5rem; }
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
  .hero-metric { grid-column: span 2; grid-row: span 2; }
  .form-grid { grid-template-columns: repeat(3, 1fr); }
  .wide { grid-column: 1 / -1; }
  .panel { padding: 1.3rem; }
}

@media (max-width: 420px) {
  .form-grid { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .identity-row { align-items: stretch; flex-direction: column; }
  .identity-row strong { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .month-picker { min-width: 0; width: 100%; }
}
