/* Standalone private calculator — no dependency on main site */

:root {
  --bg-deep: #0b1220;
  --bg-card: #111b2e;
  --bg-elevated: #152238;
  --accent: #f5a623;
  --accent-soft: rgba(245, 166, 35, 0.14);
  --text: #e8edf7;
  --text-muted: #94a3b8;
  --border: rgba(148, 163, 184, 0.14);
  --radius: 14px;
  --radius-lg: 20px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --max: 640px;
  --touch: 48px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg-deep);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(5.25rem + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 768px) {
  body {
    padding-bottom: 2rem;
  }
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(11, 18, 32, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 0;
}

.app-header-inner {
  width: min(var(--max), 100% - 1.5rem);
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.app-header .tag {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.app-header h1 {
  margin: 0;
  font-size: clamp(1.15rem, 4vw, 1.35rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-switch {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.page-switch a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.page-switch a:hover,
.page-switch a:focus-visible {
  text-decoration: underline;
}

.page-switch span[aria-current="page"] {
  color: var(--text);
  font-weight: 700;
}

.rpm-field {
  margin-bottom: 1rem;
}

.field-hint {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.checkbox-expense {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-deep);
}

.checkbox-expense-label {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  cursor: pointer;
  margin: 0;
}

.checkbox-expense-label input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.15rem;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.checkbox-expense-text {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

.checkbox-title {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}

.checkbox-meta {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.45;
}

.wrap {
  width: min(var(--max), 100% - 1.5rem);
  margin-inline: auto;
  padding: 1rem 0 2rem;
}

@media (min-width: 768px) {
  :root {
    --max: 720px;
  }
}

/* Jump nav — thumb-friendly */
.jump-nav {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
  margin: 0 0 1.25rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.jump-nav::-webkit-scrollbar {
  display: none;
}

.jump-nav a {
  flex: 0 0 auto;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.78rem;
  white-space: nowrap;
  text-decoration: none;
  min-height: var(--touch);
  display: inline-flex;
  align-items: center;
}

.jump-nav a:hover,
.jump-nav a:focus-visible {
  color: var(--text);
  border-color: rgba(245, 166, 35, 0.35);
}

section.block {
  scroll-margin-top: 4.5rem;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.section-num {
  flex-shrink: 0;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  font-size: 0.8rem;
  display: grid;
  place-items: center;
}

.section-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  flex: 1;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.15rem 1.1rem;
  margin-bottom: 1rem;
}

.card > .sub {
  margin: 0 0 1rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.card > .sub:last-child {
  margin-bottom: 0;
}

.split-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 520px) {
  .split-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
}

.field-input {
  width: 100%;
  min-height: var(--touch);
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-deep);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
}

.field-input:focus {
  border-color: var(--accent);
  outline: none;
}

input.field-input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input.field-input[type="number"]::-webkit-outer-spin-button,
input.field-input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Entry rows (mobile-first) */
.entry-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.entry-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

@media (min-width: 480px) {
  .entry-row {
    flex-direction: row;
    align-items: stretch;
    gap: 0.65rem;
  }

  .entry-row .field-input {
    flex: 1;
    min-width: 0;
  }

  .entry-row .btn-remove {
    flex: 0 0 auto;
    align-self: stretch;
    min-width: 5.5rem;
  }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  min-height: var(--touch);
  padding: 0.55rem 1.1rem;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: transform 0.15s var(--ease), box-shadow 0.2s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #ea580c);
  color: #0b1220;
  box-shadow: 0 6px 24px rgba(245, 166, 35, 0.28);
  width: 100%;
}

@media (min-width: 480px) {
  .btn-primary.btn-inline {
    width: auto;
    min-width: 10rem;
  }
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  width: 100%;
}

@media (min-width: 480px) {
  .btn-ghost {
    width: auto;
  }
}

.btn-remove {
  font-family: inherit;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.25);
  color: #fca5a5;
  font-size: 0.85rem;
  padding: 0.5rem 0.85rem;
  min-height: var(--touch);
}

.btn-remove:hover {
  background: rgba(248, 113, 113, 0.18);
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

@media (min-width: 480px) {
  .toolbar {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

/* Stable grid */
.stable-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 560px) {
  .stable-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.stable-grid .field:last-child {
  grid-column: 1 / -1;
}

/* Totals */
.totals-card {
  background: linear-gradient(160deg, var(--bg-elevated), var(--bg-card));
  border: 1px solid rgba(245, 166, 35, 0.22);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.15rem;
  margin-bottom: 1rem;
}

.totals-card h2 {
  margin: 0 0 0.85rem;
  font-size: 1.1rem;
  font-weight: 800;
}

.summary-rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
}

.summary-row:last-of-type:not(.profit) {
  border-bottom: none;
}

.summary-row .amt {
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.summary-row.highlight .amt {
  color: var(--accent);
  font-size: 1.02rem;
}

.summary-row.profit {
  margin-top: 0.35rem;
  padding-top: 0.75rem;
  border-top: 2px solid rgba(245, 166, 35, 0.35);
  border-bottom: none;
  font-size: 0.95rem;
}

.summary-row.profit .amt {
  font-size: 1.28rem;
}

.profit-pos {
  color: #4ade80 !important;
}

.profit-neg {
  color: #f87171 !important;
}

.profit-zero {
  color: var(--text-muted) !important;
}

.actions-card .btn {
  margin-bottom: 0.5rem;
}

.actions-card .btn:last-child {
  margin-bottom: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.import-label {
  cursor: pointer;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.backup-toolbar {
  align-items: stretch;
}

@media (min-width: 480px) {
  .backup-toolbar {
    flex-direction: row;
    align-items: center;
  }
}

.site-footer {
  text-align: center;
  padding: 1.5rem 1rem 2rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Week history */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-empty {
  margin: 0;
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.history-card {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  list-style: none;
}

.history-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.history-date {
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--text);
}

.history-delete {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.4rem 0.65rem;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: #fca5a5;
  cursor: pointer;
}

.history-delete:hover {
  background: rgba(248, 113, 113, 0.12);
}

.history-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

@media (max-width: 380px) {
  .history-stats {
    grid-template-columns: 1fr;
  }
}

.history-stats span {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 700;
}

.history-stats .profit-good {
  color: #4ade80;
}

.history-stats .profit-bad {
  color: #f87171;
}

.history-details {
  margin-top: 0.65rem;
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
}

.history-details summary {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--accent);
  cursor: pointer;
  min-height: var(--touch);
  display: flex;
  align-items: center;
}

.history-lines {
  margin: 0.5rem 0 0;
  padding-left: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.history-lines li {
  margin-bottom: 0.2rem;
}

/* Mobile dock */
.calc-dock {
  position: fixed;
  z-index: 100;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.65rem 1rem calc(0.65rem + env(safe-area-inset-bottom, 0px));
  background: rgba(11, 18, 32, 0.94);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.35);
}

@media (min-width: 768px) {
  .calc-dock {
    display: none;
  }
}

.calc-dock-inner {
  width: min(var(--max), 100% - 0rem);
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.dock-block {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.dock-label {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.dock-profit {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.dock-gross {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.calc-dock .btn-dock {
  flex-shrink: 0;
  min-height: 44px;
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
  border-radius: 10px;
  background: var(--accent-soft);
  border: 1px solid rgba(245, 166, 35, 0.35);
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
