/* Tirelire.ch — design tokens (web app) */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Instrument+Serif:ital@0;1&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #FAFAF6;
  --surface: #FFFFFF;
  --surface-2: #F5F5EF;
  --surface-3: #EEEEE5;
  --green: #1E8E5C;
  --green-2: #176E48;
  --green-soft: #E7F4ED;
  --yellow: #F2C035;
  --yellow-soft: #FBF1D2;
  --coral: #C8553D;
  --coral-soft: #FBEDE8;
  --ink: #15181A;
  --ink-2: #2A2D30;
  --muted: #6B7280;
  --muted-2: #9AA0A6;
  --border: #E8E8E2;
  --border-strong: #D6D6CE;

  --r-card: 12px;
  --r-input: 8px;
  --r-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(20,24,28,0.04);
  --shadow-md: 0 1px 2px rgba(20,24,28,0.04), 0 6px 18px rgba(20,24,28,0.05);
  --shadow-lg: 0 12px 32px rgba(20,24,28,0.10), 0 4px 12px rgba(20,24,28,0.05);

  --sans: 'Plus Jakarta Sans', system-ui, sans-serif;
  --serif: 'Instrument Serif', Georgia, serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

[data-theme="dark"] {
  --bg: #0E120F;
  --surface: #161A17;
  --surface-2: #1E231F;
  --surface-3: #262B27;
  --green: #4CC689;
  --green-2: #3DAE76;
  --green-soft: #1B2A22;
  --yellow: #E9B934;
  --yellow-soft: #2A2516;
  --coral: #E07A60;
  --coral-soft: #2A1A16;
  --ink: #F0F0EA;
  --ink-2: #C9C9C2;
  --muted: #9CA2A8;
  --muted-2: #6B7280;
  --border: #262B27;
  --border-strong: #343A35;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.30);
  --shadow-md: 0 1px 2px rgba(0,0,0,0.30), 0 6px 18px rgba(0,0,0,0.40);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.45), 0 4px 12px rgba(0,0,0,0.25);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: var(--sans); }

.app-root {
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  display: flex;
  flex-direction: column;
  position: relative;
}

button { font-family: inherit; cursor: pointer; }
input, button, select, textarea { font-family: inherit; }
input { color: var(--ink); }

button:focus-visible, input:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.section-num {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
}

.hairline { height: 1px; background: var(--border); border: 0; margin: 0; }

/* Animations */
.fade-in { animation: fade-in 320ms ease both; }
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.modal-enter { animation: modal-in 240ms cubic-bezier(.2,.8,.2,1) both; }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.backdrop-enter { animation: bd-in 180ms ease both; }
@keyframes bd-in { from { opacity: 0 } to { opacity: 1 } }

/* Skeleton */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
  border-radius: 6px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 13px 22px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: toast-in 320ms cubic-bezier(.2,.8,.2,1) both;
  white-space: nowrap;
  display: inline-flex; align-items: center; gap: 10px;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 16px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* App shell */
.shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100%;
  gap: 0;
}
.shell-sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg);
  padding: 22px 18px 18px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  max-height: 100%;
}
.shell-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Top bar inside main */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: 0; z-index: 30;
}

.content-wrap {
  max-width: 1180px;
  margin: 0 auto;
  width: 100%;
  padding: 28px 32px 80px;
}

@media (max-width: 880px) {
  .shell { grid-template-columns: 1fr; }
  .shell-sidebar {
    position: sticky; top: 0; height: auto;
    flex-direction: row; align-items: center;
    padding: 8px 12px; gap: 4px;
    border-right: 0; border-bottom: 1px solid var(--border);
  }
  .sidebar-wordmark { display: none; }
  .shell-sidebar .nav-item > span:nth-child(2) { display: none; }
  .shell-sidebar .nav-item { width: 44px; justify-content: center; padding: 8px 0; }
  .shell-sidebar nav { flex-direction: row; gap: 2px; }
  .sidebar-user { display: none; }
  .sidebar-footer { display: none; }
  .topbar { padding: 14px 18px; }
  .content-wrap { padding: 20px 18px 100px; }
}

@media (max-width: 600px) {
  .summary-grid { grid-template-columns: 1fr !important; }
  .rule-grid { grid-template-columns: 1fr !important; gap: 12px !important; }
  .topbar { flex-wrap: wrap; gap: 10px; padding: 12px 14px; }
  .btn-add-label { display: none; }
  .topbar-month-title { display: none; }
  .amount-input { font-size: 26px !important; }
  .cat-grid { display: flex !important; flex-wrap: wrap; justify-content: center; gap: 5px; }
  .cat-grid > * { flex: 0 0 calc(33.33% - 4px); }
  .backdrop-enter { align-items: flex-end !important; padding: 0 !important; }
  .modal-enter { border-radius: 20px 20px 0 0 !important; max-height: 88svh !important; }
  .modal-inner { padding: 16px 16px 8px !important; }
  .tx-header { display: none !important; }
  .tx-row { grid-template-columns: 36px 1fr auto 36px !important; gap: 10px !important; padding: 12px 16px !important; }
  .tx-date-cell { display: none !important; }
  .tx-solde { grid-template-columns: 36px 1fr auto 36px !important; gap: 10px !important; padding: 12px 16px !important; }
  .tx-solde-date { display: none !important; }
  .annual-summary { grid-template-columns: 1fr !important; gap: 4px !important; }
}

/* ── Cat grid (modal transaction) ── */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

/* ── Bottom Navigation (mobile) ── */
.bottom-nav { display: none; }

@media (max-width: 880px) {
  .shell-sidebar { display: none; }
  .content-wrap { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  .bottom-nav {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--bg);
    border-top: 1px solid var(--border);
    z-index: 50;
    padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .bottom-nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 10px; min-width: 56px;
    color: var(--muted); font-size: 11px; font-weight: 500;
    background: none; border: 0; cursor: pointer;
    transition: color 140ms ease;
  }
  .bottom-nav-item.active { color: var(--green); }
  .bottom-nav-item svg { display: block; }
}

/* Nav items */
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 8px;
  color: var(--muted); font-size: 14px; font-weight: 500;
  cursor: pointer; background: transparent; border: 0;
  width: 100%; text-align: left;
  min-height: 44px;
  transition: background 140ms ease, color 140ms ease;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--border); }
.nav-item .badge {
  margin-left: auto; font-family: var(--mono); font-size: 10px;
  color: var(--muted); background: var(--surface-2); padding: 2px 6px; border-radius: 4px;
}

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 1040px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 880px) {
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .content-wrap { padding: 14px 14px 80px; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .shell-sidebar { padding: 8px 12px; }
}
