:root {
  --bg: #f8f6f0;
  --paper: #fffdf8;
  --paper-2: #f0eee5;
  --ink: #262722;
  --muted: #6c6d63;
  --line: #ded9cb;
  --sage: #6e7f69;
  --sage-dark: #455744;
  --gold: #b99b5f;
  --terracotta: #b7654c;
  --danger: #b84a3e;
  --ok: #4d7350;
  --shadow: 0 16px 36px rgba(48, 45, 35, 0.12);
  --shadow-soft: 0 10px 22px rgba(48, 45, 35, 0.08);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255,253,248,.8), rgba(248,246,240,.2) 360px),
    var(--bg);
  color: var(--ink);
}

button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(185, 155, 95, .38);
  outline-offset: 2px;
}

.hero {
  min-height: calc(100vh - 66px);
  display: grid;
  align-items: end;
  background:
    linear-gradient(90deg, rgba(248,246,240,.98) 0%, rgba(248,246,240,.86) 45%, rgba(248,246,240,.18) 100%),
    url("assets/planner-hero.png") center/cover;
  border-bottom: 1px solid var(--line);
}

.hero-inner {
  width: min(1120px, 100%);
  padding: 28px 18px 48px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  min-height: 66px;
  padding: 10px 14px;
  background: rgba(255, 253, 248, .92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  min-height: 42px;
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--ink);
  font-weight: 850;
  letter-spacing: .02em;
  text-align: left;
}

.lang-switch, .nav, .actions, .segmented {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.admin-link {
  display: inline-flex;
  align-items: center;
}

.app-topbar {
  z-index: 40;
}

.topbar-account {
  display: none;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.plan-badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 5px 9px;
  border-radius: 8px;
  color: white;
  background: var(--sage-dark);
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.app-sidebar {
  position: sticky;
  top: 66px;
  z-index: 35;
  display: flex;
  gap: 8px;
  padding: 8px;
  overflow-x: auto;
  background: rgba(255, 253, 248, .96);
  border-bottom: 1px solid var(--line);
}

.sidebar-section {
  display: flex;
  gap: 8px;
  align-items: center;
}

.sidebar-section .eyebrow {
  display: none;
}

.sidebar-item {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--paper);
  white-space: nowrap;
}

.sidebar-item.active {
  color: white;
  background: var(--sage-dark);
  border-color: var(--sage-dark);
}

.sidebar-item.locked {
  color: var(--muted);
  background: #f3efe4;
}

.sidebar-item small {
  padding: 3px 6px;
  border-radius: 999px;
  color: var(--sage-dark);
  background: #e8dfca;
  font-size: .68rem;
  font-weight: 800;
}

.sidebar-item.active small {
  color: var(--ink);
  background: #e2cf9d;
}

.nav {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 30;
  padding: 8px 8px max(8px, env(safe-area-inset-bottom));
  overflow-x: auto;
  flex-wrap: nowrap;
  background: rgba(255, 253, 248, .96);
  box-shadow: 0 -10px 26px rgba(48, 45, 35, .08);
  border-top: 1px solid var(--line);
}

.nav button, .pill, .icon-btn {
  min-height: 42px;
  padding: 10px 13px;
  border-radius: 8px;
  background: var(--paper-2);
  color: var(--ink);
  border: 1px solid transparent;
  white-space: nowrap;
  transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
}

.nav button.active, .pill.active, .primary {
  background: var(--sage-dark);
  color: white;
  box-shadow: var(--shadow-soft);
}

.nav button:hover, .pill:hover { transform: translateY(-1px); }

.secondary {
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
}

.danger { color: var(--danger); }
.ok { color: var(--ok); }
.muted { color: var(--muted); }

.container {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px 14px 96px;
}

.app-shell {
  display: grid;
  gap: 14px;
}

h1 {
  margin: 0 0 14px;
  font-size: clamp(2.2rem, 7vw, 4.9rem);
  line-height: .98;
  max-width: 760px;
  letter-spacing: 0;
}

h2 { margin: 8px 0 14px; font-size: 1.45rem; }
h3 { margin: 0 0 10px; font-size: 1rem; }
p { line-height: 1.55; }

.lead {
  max-width: 630px;
  font-size: clamp(1.06rem, 2.8vw, 1.28rem);
  color: var(--muted);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-bottom: 10px;
  color: var(--sage-dark);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.page-title {
  padding: 8px 2px 2px;
}

.page-title h1 {
  max-width: none;
  margin-bottom: 8px;
  font-size: clamp(2rem, 5vw, 3.4rem);
}

.page-title p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
}

.hero-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  max-width: 790px;
  margin-top: 24px;
}

.hero-panel > div {
  padding: 14px;
  background: rgba(255,253,248,.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.hero-panel span,
.hero-panel strong,
.billing-card span,
.billing-card strong,
.billing-card small {
  display: block;
}

.benefits {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin: 16px 0 0;
}

.benefit, .card, .modal-box {
  background: rgba(255, 253, 248, .92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.benefit {
  padding: 14px;
  min-height: 76px;
  display: flex;
  align-items: center;
  font-weight: 700;
}

.card { padding: 16px; }

.toolbar-card {
  background: rgba(255,253,248,.72);
  box-shadow: none;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.dashboard-hero,
.subscription-hero {
  display: grid;
  gap: 18px;
  padding: 20px;
  color: white;
  background:
    linear-gradient(135deg, rgba(69,87,68,.98), rgba(38,39,34,.95)),
    var(--sage-dark);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.dashboard-hero h1,
.subscription-hero h1 {
  max-width: 760px;
  margin-bottom: 6px;
  font-size: clamp(2rem, 6vw, 4rem);
}

.dashboard-hero p,
.subscription-hero p {
  color: rgba(255,255,255,.78);
  margin: 0;
}

.dashboard-hero .eyebrow,
.subscription-hero .eyebrow {
  color: #e2cf9d;
}

.hero-stat,
.billing-card {
  align-self: stretch;
  padding: 16px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
}

.hero-stat span { display: block; color: rgba(255,255,255,.74); }
.hero-stat strong, .billing-card strong { font-size: clamp(1.8rem, 5vw, 3rem); }

.metric strong {
  display: block;
  font-size: 1.35rem;
  margin-top: 3px;
}

.progress {
  height: 10px;
  overflow: hidden;
  background: #e9e4d6;
  border-radius: 999px;
}

.progress > span {
  display: block;
  height: 100%;
  width: var(--value);
  max-width: 100%;
  background: var(--sage);
}

.warning {
  padding: 10px 12px;
  border-left: 4px solid var(--terracotta);
  background: #fff4ed;
  border-radius: 8px;
}

form, .form-grid {
  display: grid;
  gap: 10px;
}

.form-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: .88rem;
}

input, select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 11px;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}

input:hover, select:hover, textarea:hover {
  border-color: #c9bfaa;
}

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

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow-soft);
}

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

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

th { color: var(--muted); font-size: .82rem; }

tbody tr:hover { background: rgba(240,238,229,.48); }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions button { min-height: 34px; padding: 7px 9px; border-radius: 8px; }

.subscription-plan {
  display: grid;
  gap: 10px;
  align-content: space-between;
  border-top: 4px solid var(--sage);
}

.subscription-plan.featured {
  border-top-color: var(--gold);
  box-shadow: var(--shadow);
}

.subscription-plan ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.subscription-note {
  background: #fbf7eb;
}

.price {
  font-size: 2rem;
  font-weight: 800;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  align-items: end;
  padding: 14px;
  background: rgba(38, 39, 34, .52);
  backdrop-filter: blur(8px);
}

.modal-box {
  width: min(760px, 100%);
  max-height: 88vh;
  overflow: auto;
  margin: 0 auto;
  padding: 18px;
}

.empty {
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.admin-page {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(248,246,240,.96), rgba(239,235,222,.9)),
    var(--bg);
}

.admin-login {
  min-height: 100vh;
  display: grid;
  align-items: center;
  gap: 22px;
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 24px 16px;
}

.admin-copy h1 {
  max-width: 660px;
  font-size: clamp(2.5rem, 8vw, 5.2rem);
}

.admin-copy p {
  max-width: 560px;
  color: var(--muted);
  font-size: 1.08rem;
}

.admin-card {
  padding: 18px;
}

.admin-topbar {
  position: sticky;
}

pre {
  min-width: 720px;
  margin: 0;
  padding: 14px;
  white-space: pre-wrap;
  color: #2d2d28;
  font-size: .82rem;
}

.print-only { display: none; }

@media (min-width: 860px) {
  .topbar { padding: 14px 28px; }
  .topbar-account { display: flex; }
  .app-sidebar {
    position: fixed;
    inset: 66px auto 0 0;
    width: 248px;
    display: block;
    padding: 18px 12px;
    overflow-x: hidden;
    overflow-y: auto;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    box-shadow: 10px 0 24px rgba(48, 45, 35, .05);
  }
  .sidebar-section {
    display: grid;
    gap: 7px;
  }
  .sidebar-section .eyebrow {
    display: inline-flex;
    margin: 0 0 5px 4px;
  }
  .sidebar-item {
    width: 100%;
  }
  .app-sidebar + .container {
    width: min(1180px, calc(100% - 248px));
    margin-left: 248px;
  }
  .nav {
    position: static;
    padding: 0;
    border: 0;
    background: transparent;
  }
  .container { padding: 30px 24px 56px; }
  .hero-inner { padding: 60px 42px 70px; margin: 0 auto; }
  .modal { align-items: center; }
  .dashboard-hero,
  .subscription-hero {
    grid-template-columns: 1fr minmax(240px, 320px);
    align-items: end;
    padding: 28px;
  }
  .grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  }
  .admin-login {
    grid-template-columns: 1fr minmax(330px, 430px);
    padding: 40px 28px;
  }
}

@media (max-width: 520px) {
  .topbar {
    align-items: flex-start;
  }
  .lang-switch {
    justify-content: flex-end;
  }
  .lang-switch .pill {
    min-height: 34px;
    padding: 7px 9px;
    font-size: .78rem;
  }
  .hero {
    background:
      linear-gradient(180deg, rgba(248,246,240,.99) 0%, rgba(248,246,240,.9) 58%, rgba(248,246,240,.42) 100%),
      url("assets/planner-hero.png") center/cover;
  }
  .card,
  .dashboard-hero,
  .subscription-hero {
    padding: 14px;
  }
}

@media print {
  .topbar, .nav, .no-print, .modal { display: none !important; }
  body { background: white; }
  .container { padding: 0; }
  .card, .benefit { box-shadow: none; break-inside: avoid; }
  .print-only { display: block; }
}
