:root {
  --ink: #17202a;
  --soft: #46515d;
  --muted: #7a7263;
  --paper: #faf7f0;
  --paper2: #f1ebdd;
  --card: #fffdf8;
  --navy: #0b2440;
  --navy2: #071a30;
  --gold: #c19a3d;
  --gold-dark: #8d6e25;
  --line: #ddd3bd;
  --line2: #eae2cf;
  --red: #a33b32;
  --green: #32735a;
  --serif: Georgia, "Times New Roman", Times, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); line-height: 1.5; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: var(--serif); color: var(--navy); }
h2 { font-size: clamp(30px, 4vw, 44px); margin: 0; line-height: 1.05; }
h3 { margin: 0 0 8px; font-size: 21px; }
p { margin-top: 0; }
.eyebrow { margin: 0 0 5px; color: var(--gold-dark); font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.eyebrow.light { color: var(--gold); }
.muted { color: var(--muted); }
.error { color: var(--red); font-weight: 700; }
.success { color: var(--green); font-weight: 700; }
.btn { border: 1px solid var(--navy); background: transparent; color: var(--navy); padding: 8px 13px; border-radius: 3px; font-weight: 700; font-size: 14px; }
.btn:hover { background: var(--paper2); }
.btn.primary { background: var(--navy); color: white; }
.btn.primary:hover { background: var(--navy2); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: white; }
.btn.ghost { color: #d7e0ea; border-color: #33507a; }
.btn.small { padding: 6px 9px; font-size: 13px; }
.btn.large { width: 100%; padding: 12px; }
.btn.full { width: 100%; margin-top: 8px; }
.btn.danger { color: var(--red); border-color: #d6a49f; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; }
.icon-btn { border: 0; background: transparent; font-size: 28px; line-height: 1; color: var(--muted); }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 22px; background: radial-gradient(circle at top left, #17395e, var(--navy2) 58%); }
.login-card { width: min(430px, 100%); background: var(--card); padding: 34px; border-top: 6px solid var(--gold); box-shadow: 0 24px 70px rgba(0,0,0,.32); }
.login-card h1 { font-size: 44px; margin: 0; }
.tagline { font-family: var(--serif); font-style: italic; color: var(--muted); font-size: 18px; }
label { display: block; font-weight: 700; font-size: 14px; margin: 0 0 14px; color: var(--soft); }
input, select, textarea { width: 100%; margin-top: 6px; border: 1px solid #cfc4a9; border-radius: 3px; background: white; color: var(--ink); padding: 10px 11px; font-weight: 400; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(193,154,61,.45); border-color: var(--gold); }
.login-note { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line2); color: var(--muted); font-size: 14px; }
.login-note strong { display: block; color: var(--navy); }

/* Shell */
.shell { min-height: 100vh; display: grid; grid-template-columns: 278px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; overflow: auto; background: var(--navy2); color: #dbe4ee; padding: 24px 18px; display: flex; flex-direction: column; }
.brand-block { padding: 4px 6px 20px; border-bottom: 1px solid #294563; }
.brand-block h1 { color: white; font-size: 34px; margin: 0; }
.brand-block p:last-child { color: #aebfd1; font-family: var(--serif); font-style: italic; margin: 6px 0 0; }
#mainNav { display: flex; flex-direction: column; gap: 4px; padding: 18px 0; }
#mainNav button { display: flex; justify-content: space-between; align-items: center; width: 100%; text-align: left; background: transparent; border: 0; border-left: 3px solid transparent; color: #dbe4ee; padding: 10px 10px; font-weight: 700; }
#mainNav button:hover { background: #102c4c; }
#mainNav button.active { background: #132f52; border-left-color: var(--gold); color: white; }
.count { min-width: 25px; text-align: center; background: var(--gold); color: white; border-radius: 999px; padding: 1px 7px; font-size: 12px; }
.small-label { color: #93a8bd; font-size: 11px; letter-spacing: .1em; }
.side-actions { margin-top: auto; border-top: 1px solid #294563; padding-top: 16px; }
.main { min-width: 0; padding: 26px clamp(18px, 4vw, 46px) 54px; }
.topbar { display: flex; justify-content: space-between; align-items: end; gap: 18px; padding-bottom: 18px; border-bottom: 3px double var(--ink); margin-bottom: 22px; }
.owner-chip { text-align: right; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }
.owner-chip strong { display: block; color: var(--navy); font-family: var(--serif); font-size: 19px; text-transform: none; letter-spacing: 0; }
.alert { display: flex; justify-content: space-between; gap: 18px; align-items: center; background: #fff3cf; border: 1px solid #dfc26e; border-left: 6px solid var(--gold); padding: 14px 16px; margin-bottom: 18px; }
.alert strong { display: block; color: var(--navy); }
.alert span { color: var(--soft); font-size: 14px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 30; background: var(--navy); color: white; padding: 12px 16px; border-radius: 3px; box-shadow: 0 12px 34px rgba(0,0,0,.22); font-weight: 700; }

/* Common modules */
.view { animation: fade .18s ease-out; }
@keyframes fade { from { opacity: .35; transform: translateY(2px); } to { opacity: 1; transform: none; } }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 18px; }
.toolbar p { color: var(--muted); margin-bottom: 0; }
.panel, .info-card, .quick-card { background: var(--card); border: 1px solid var(--line2); padding: 19px; }
.panel-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; border-bottom: 1px solid var(--line2); padding-bottom: 10px; margin-bottom: 12px; }
.panel-head h3 { margin: 0; font-size: 19px; }
.quick-card { border-top: 5px solid var(--gold); margin-bottom: 20px; }
.quick-card p { color: var(--muted); }
.quick-row { display: grid; grid-template-columns: minmax(0, 1fr) 130px auto; gap: 9px; }
.quick-row input, .quick-row select { margin: 0; }
.stats-grid { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: 13px; margin-bottom: 20px; }
.stats-grid.compact { grid-template-columns: repeat(4, minmax(130px, 1fr)); }
.stat { background: var(--navy); color: white; padding: 16px; min-height: 104px; }
.stat span { display: block; color: #b9c7d6; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; }
.stat strong { display: block; font-family: var(--serif); font-size: 36px; line-height: 1; margin: 8px 0 5px; }
.stat p { color: #cbd6e2; font-size: 13px; margin: 0; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.list-item { display: flex; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line2); }
.list-item:last-child { border-bottom: 0; }
.list-item h4 { margin: 0 0 3px; font-size: 16px; color: var(--ink); }
.list-item p { margin: 0; color: var(--muted); font-size: 14px; }
.item-actions { display: flex; gap: 6px; align-items: start; flex-wrap: wrap; justify-content: end; }
.mini-btn { border: 1px solid var(--line); background: white; color: var(--navy); padding: 5px 8px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.mini-btn:hover { border-color: var(--gold); }
.mini-btn.red { color: var(--red); }
.pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 8px; background: var(--paper2); color: var(--gold-dark); font-size: 11px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.pill.red { color: var(--red); background: #fbeae7; }
.pill.green { color: var(--green); background: #e7f3ed; }
.empty { color: var(--muted); padding: 12px 0; font-style: italic; }
.big-days { font-family: var(--serif); font-size: 38px; line-height: 1; color: var(--navy); text-align: right; }
.big-days span { display: block; font-family: var(--sans); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }

/* Calendar */
.month-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.month-nav h3 { margin: 0 0 0 8px; font-size: 26px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); background: white; }
.day-head, .day-cell { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.day-head { background: var(--navy); color: white; padding: 8px; font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .09em; }
.day-cell { min-height: 118px; padding: 8px; background: #fffefa; }
.day-cell.muted { background: #f5f0e4; color: #aaa; }
.day-cell.today { box-shadow: inset 0 0 0 2px var(--gold); }
.day-num { font-weight: 900; color: var(--navy); }
.cal-event { display: block; width: 100%; text-align: left; border: 0; border-left: 3px solid var(--gold); background: var(--paper2); margin-top: 5px; padding: 4px 6px; font-size: 12px; font-weight: 700; color: var(--navy); }
.space-top { margin-top: 20px; }

/* Cards */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(265px, 1fr)); gap: 16px; }
.person-card, .date-card { background: var(--card); border: 1px solid var(--line2); padding: 18px; }
.person-card h3, .date-card h3 { margin-bottom: 3px; }
.person-card .role { color: var(--gold-dark); font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.meta-list { margin: 13px 0; font-size: 14px; color: var(--soft); }
.meta-list div { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--line2); }
.meta-list span { color: var(--muted); }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }
.search-row { margin-bottom: 16px; }
.search-row input { margin: 0; }
.date-card { display: flex; justify-content: space-between; gap: 16px; }
.date-card .meta-list { min-width: 0; }

/* Tasks / wins */
.task-group { margin-bottom: 22px; }
.task-group > h3 { border-bottom: 2px solid var(--ink); padding-bottom: 7px; }
.task-row { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line2); padding: 13px 15px; margin-bottom: 8px; }
.task-row input[type="checkbox"] { width: 21px; height: 21px; margin: 0; accent-color: var(--navy); }
.task-row.done { opacity: .66; }
.task-row.done h4 { text-decoration: line-through; }
.task-row h4 { margin: 0; }
.task-row p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.timeline-month { margin-bottom: 24px; }
.timeline-month > h3 { border-bottom: 2px solid var(--gold); padding-bottom: 7px; }
.win-row { display: grid; grid-template-columns: 105px minmax(0,1fr) auto; gap: 16px; padding: 13px 0 13px 16px; border-left: 3px solid var(--gold); border-bottom: 1px solid var(--line2); }
.win-date { font-weight: 900; color: var(--gold-dark); }
.win-row h4 { margin: 0 0 3px; }
.win-row p { margin: 0; color: var(--muted); }

/* Family */
.generation { margin-bottom: 26px; }
.generation > h3 { display: flex; align-items: center; gap: 12px; }
.generation > h3::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.family-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 15px; }
.family-card { background: var(--navy); color: white; padding: 18px; border-top: 5px solid var(--gold); }
.family-card h3 { color: white; margin-bottom: 4px; }
.family-card p { color: #c4d2df; font-size: 14px; }
.family-card .rel-line { border-top: 1px solid #33507a; padding: 7px 0; font-size: 14px; }
.family-card .rel-line span { color: var(--gold); font-weight: 900; text-transform: uppercase; font-size: 11px; letter-spacing: .08em; margin-right: 7px; }
.family-card .mini-btn { background: transparent; color: white; border-color: #54708f; }

/* Shopping */
.shopping-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 17px; }
.shop-card { background: var(--card); border: 1px solid var(--line2); padding: 18px; }
.shop-card.active { border-top: 5px solid var(--gold); }
.shop-head { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.shop-head h3 { margin: 0; }
.shop-count { font-family: var(--serif); color: var(--gold-dark); font-size: 23px; }
.fast-add { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 7px; margin: 14px 0; }
.fast-add input { margin: 0; }
.shop-item { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 9px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line2); }
.shop-item input[type="checkbox"] { width: 20px; height: 20px; margin: 0; accent-color: var(--navy); }
.shop-item.checked .item-name { text-decoration: line-through; color: var(--muted); }
.item-name { font-weight: 750; }
.item-meta { color: var(--muted); font-size: 13px; }

/* Reminders / security / settings */
.reminder-row { display: grid; grid-template-columns: 118px minmax(0,1fr) auto; gap: 16px; align-items: center; background: var(--card); border: 1px solid var(--line2); border-left: 6px solid var(--gold); padding: 15px 17px; }
.reminder-row.overdue { border-left-color: var(--red); }
.reminder-kind { font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .1em; color: var(--gold-dark); }
.reminder-row h4 { margin: 0 0 3px; }
.reminder-row p { margin: 0; color: var(--muted); }
.security-hero { background: var(--navy); color: white; padding: 30px; margin-bottom: 18px; }
.security-hero h3 { color: white; font-size: 34px; }
.security-hero p { color: #cbd6e2; max-width: 760px; }
.security-grid article { min-height: 180px; }
.settings-grid { align-items: start; }
.form-panel h3 { border-bottom: 1px solid var(--line2); padding-bottom: 10px; }
.form-panel .btn { margin-top: 4px; }

/* Dialog */
dialog { width: min(680px, calc(100vw - 28px)); border: 1px solid var(--line); padding: 0; background: var(--card); box-shadow: 0 28px 80px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(7,26,48,.55); }
#editorForm { padding: 22px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--ink); padding-bottom: 10px; margin-bottom: 17px; }
.dialog-head h3 { margin: 0; font-size: 26px; }
.editor-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 15px; }
.editor-fields label.wide { grid-column: 1 / -1; }
.dialog-actions { display: flex; justify-content: end; gap: 8px; border-top: 1px solid var(--line2); padding-top: 15px; }

@media (max-width: 980px) {
  .stats-grid, .stats-grid.compact { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { display: block; }
  .sidebar { position: static; height: auto; padding: 17px; }
  .brand-block { padding-bottom: 10px; }
  #mainNav { flex-direction: row; overflow-x: auto; padding: 12px 0; }
  #mainNav button { white-space: nowrap; border-left: 0; border-bottom: 3px solid transparent; }
  #mainNav button.active { border-bottom-color: var(--gold); }
  .side-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .main { padding: 19px 14px 42px; }
  .topbar { align-items: start; }
  .owner-chip { display: none; }
  .toolbar { align-items: start; flex-direction: column; }
  .quick-row { grid-template-columns: 1fr; }
  .calendar-grid { font-size: 12px; }
  .day-cell { min-height: 78px; padding: 5px; }
  .cal-event { font-size: 10px; padding: 3px; }
  .editor-fields { grid-template-columns: 1fr; }
  .reminder-row { grid-template-columns: 1fr; gap: 5px; }
  .task-row { grid-template-columns: auto 1fr; }
  .task-row .item-actions { grid-column: 2; justify-content: start; }
  .win-row { grid-template-columns: 1fr; gap: 4px; }
  .alert { align-items: start; flex-direction: column; }
}
