:root {
  --ink: #303638;
  --muted: #6c746f;
  --navy: #343b3d;
  --navy-dark: #242a2c;
  --blue-soft: #edf1ed;
  --paper: #ffffff;
  --canvas: #f5f7f3;
  --line: #d9dfd7;
  --teal: #668c27;
  --teal-soft: #edf6dc;
  --house-green: #a8da50;
  --amber: #c87912;
  --amber-soft: #fff0d5;
  --red: #b5473d;
  --red-soft: #fde7e4;
  --shadow: 0 14px 36px rgba(45, 53, 50, .09);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { font-size: 16px; background: var(--canvas); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--canvas); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
img { display: block; max-width: 100%; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .35rem; font-size: clamp(1.85rem, 5vw, 2.75rem); line-height: 1.08; letter-spacing: -.035em; }
h2 { margin-bottom: .8rem; font-size: 1.2rem; letter-spacing: -.015em; }
h3 { margin-bottom: .25rem; font-size: 1rem; }
p { margin-bottom: .75rem; }

.topbar { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; justify-content: space-between; height: 78px; padding: 0 max(1.25rem, calc((100vw - 1180px) / 2)); border-bottom: 1px solid rgba(217, 223, 215, .92); background: rgba(255,255,255,.94); backdrop-filter: blur(14px); }
.brand, .login-brand { display: flex; align-items: center; gap: .7rem; }
.brand span:last-child, .login-brand div { display: flex; flex-direction: column; line-height: 1.1; }
.brand strong, .login-brand strong { font-size: 1.05rem; letter-spacing: -.02em; }
.brand small, .login-brand small { margin-top: .2rem; color: var(--muted); font-size: .75rem; }
.brand-mark { display: block; width: 40px; height: 40px; border-radius: 11px; object-fit: cover; box-shadow: 0 7px 16px rgba(48, 54, 56, .2); }
.account-menu { position: relative; }
.account-menu summary { display: grid; place-items: center; width: 42px; height: 42px; color: #fff; border: 3px solid #e9f5d4; border-radius: 50%; background: var(--teal); font-weight: 750; cursor: pointer; list-style: none; }
.account-menu summary::-webkit-details-marker { display:none; }
.account-menu > div { position: absolute; right: 0; top: 50px; display: flex; flex-direction: column; min-width: 230px; padding: 1rem; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
.account-menu small { margin: .15rem 0 .8rem; color: var(--muted); }
.account-menu a, .link-button { padding: .55rem 0; color: var(--navy); border: 0; background: none; text-align: left; cursor: pointer; font-weight: 650; }

.page-shell { width: min(1180px, calc(100% - 2.5rem)); margin: 0 auto; padding: 2.35rem 0 7rem; }
.eyebrow { margin: 0 0 .35rem; color: var(--teal); font-size: .74rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.muted, .page-head p, .welcome-row p { color: var(--muted); }
.welcome-row, .page-head { display: flex; align-items: end; justify-content: space-between; gap: 1.5rem; margin-bottom: 2rem; }
.welcome-row h1, .page-head h1 { margin-bottom: .25rem; }
.welcome-row p:last-child, .page-head p:last-child { margin-bottom: 0; }

.button { display: inline-flex; min-height: 46px; align-items: center; justify-content: center; gap: .35rem; padding: .7rem 1rem; border: 1px solid transparent; border-radius: 12px; cursor: pointer; font-weight: 750; transition: .16s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: #fff; background: var(--navy); box-shadow: 0 7px 16px rgba(48, 54, 56, .17); }
.button.primary:hover { background: var(--navy-dark); }
.button.secondary { color: #fff; background: var(--teal); box-shadow: 0 7px 16px rgba(102, 140, 39, .18); }
.button.ghost { color: var(--navy); border-color: var(--line); background: #fff; }
.button.full { width: 100%; }

.status-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 2.5rem; }
.stat-card { display: flex; align-items: center; gap: 1rem; padding: 1.15rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.stat-card strong { display: block; font-size: 1.75rem; line-height: 1; }
.stat-card div span { color: var(--muted); font-size: .84rem; }
.stat-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px; font-weight: 850; }
.stat-icon.amber { color: var(--amber); background: var(--amber-soft); }
.stat-icon.red { color: var(--red); background: var(--red-soft); }
.stat-icon.teal { color: var(--teal); background: var(--teal-soft); }

.content-grid, .detail-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .8fr); gap: 1.5rem; align-items: start; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: .85rem; }
.section-head h2, .section-head p { margin-bottom: 0; }
.section-head > a { color: var(--teal); font-size: .9rem; font-weight: 750; }
.section-head.compact { align-items: center; }
.card-list { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.card-list.spacious { overflow: visible; display: grid; gap: .8rem; border: 0; border-radius: 0; background: transparent; }
.card-list.spacious .issue-card { border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.issue-card { display: flex; align-items: center; gap: .85rem; min-height: 92px; padding: 1rem 1.15rem; border-bottom: 1px solid var(--line); transition: .15s ease; }
.issue-card:last-child { border-bottom: 0; }
.issue-card:hover { background: #fbfdf8; transform: translateY(-1px); box-shadow: 0 8px 24px rgba(45, 53, 50, .07); }
.issue-card h3, .issue-card p { margin-bottom: 0; }
.issue-card p { color: var(--muted); font-size: .86rem; }
.grow { min-width: 0; flex: 1; }
.card-meta { display: flex; align-items: center; gap: .55rem; margin-bottom: .22rem; color: var(--muted); font-size: .75rem; }
.card-meta time { margin-left: auto; }
.priority-dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; background: #969e99; box-shadow: 0 0 0 5px #eef1ee; }
.priority-dot.important { background: var(--amber); box-shadow: 0 0 0 5px var(--amber-soft); }
.priority-dot.urgent { background: var(--red); box-shadow: 0 0 0 5px var(--red-soft); }
.status-pill, .priority-label { display: inline-flex; align-items: center; width: fit-content; padding: .32rem .58rem; border-radius: 999px; color: var(--navy); background: var(--blue-soft); font-size: .72rem; font-weight: 750; white-space: nowrap; }
.status-pill.status-resolved { color: var(--teal); background: var(--teal-soft); }
.status-pill.status-new, .priority-label.urgent { color: var(--red); background: var(--red-soft); }
.status-pill.status-commissioned, .status-pill.status-scheduled, .priority-label.important { color: var(--amber); background: var(--amber-soft); }

.panel { padding: 1.2rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: 0 8px 28px rgba(45,53,50,.045); }
.accent-panel { border-top: 4px solid var(--teal); }
.side-stack { display: grid; gap: 1rem; }
.event-row, .document-row { display: flex; align-items: center; gap: .85rem; padding: .75rem 0; border-top: 1px solid var(--line); }
.event-row time { display: flex; flex: 0 0 46px; flex-direction: column; align-items: center; color: var(--navy); line-height: 1.05; }
.event-row time strong { font-size: 1.3rem; }
.event-row time span { color: var(--muted); font-size: .7rem; text-transform: uppercase; }
.event-row h3, .document-row h3, .event-row p, .document-row p { margin-bottom: 0; }
.event-row p, .document-row p { color: var(--muted); font-size: .78rem; }
.document-row > span, .file-icon { display: grid; flex: 0 0 44px; place-items: center; height: 44px; border-radius: 11px; color: var(--red); background: var(--red-soft); font-size: .65rem; font-weight: 850; }

.filter-tabs { display: flex; gap: .4rem; overflow-x: auto; margin-bottom: 1.25rem; padding-bottom: .25rem; scrollbar-width: none; }
.filter-tabs a { padding: .5rem .8rem; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--muted); font-size: .84rem; font-weight: 650; white-space: nowrap; }
.filter-tabs a.active { color: #fff; border-color: var(--navy); background: var(--navy); }
.narrow-page { max-width: 760px; margin: 0 auto; }
.back-link { display: inline-block; margin-bottom: 1.25rem; color: var(--teal); font-size: .9rem; font-weight: 700; }
.form-panel { padding: clamp(1.1rem, 4vw, 2rem); border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.stack-form { display: grid; gap: .9rem; }
.stack-form > div, .field { display: grid; gap: .35rem; }
.stack-form label { color: var(--ink); font-size: .84rem; font-weight: 700; }
.stack-form input, .stack-form textarea, .stack-form select { width: 100%; min-height: 46px; padding: .72rem .8rem; color: var(--ink); border: 1px solid #cbd2cc; border-radius: 10px; outline: none; background: #fff; }
.stack-form textarea { resize: vertical; }
.stack-form input:focus, .stack-form textarea:focus, .stack-form select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(168, 218, 80, .25); }
.stack-form input[type=file] { padding: .55rem; background: var(--canvas); }
.form-actions { display: flex !important; grid-template-columns: 1fr 1fr; justify-content: flex-end; gap: .7rem !important; margin-top: .5rem; }
.error, .form-error { color: var(--red); }
.form-error { padding: .75rem; border-radius: 10px; background: var(--red-soft); }
.errorlist { margin: 0; padding-left: 1.2rem; color: var(--red); font-size: .85rem; }
.notification-form { gap: 1rem; }
.email-account { padding: .9rem 1rem; border-radius: 12px; background: var(--blue-soft); }
.email-account span, .email-account strong { display: block; }
.email-account span { color: var(--muted); font-size: .78rem; }
.email-account p { margin: .25rem 0 0; color: var(--muted); font-size: .84rem; }
.email-account.missing { background: var(--amber-soft); }
.subscription-card { display: flex !important; align-items: flex-start; gap: .8rem !important; padding: 1rem; border: 1px solid var(--line); border-radius: 14px; cursor: pointer; }
.subscription-card input[type="checkbox"] { display: grid; flex: 0 0 24px; place-items: center; appearance: none; width: 24px !important; min-height: 24px !important; margin: .05rem 0 0; border: 2px solid #8b948d; border-radius: 6px; background: #fff; cursor: pointer; transition: .14s ease; }
.subscription-card input[type="checkbox"]::after { color: #fff; content: "✓"; font-size: 1rem; font-weight: 900; line-height: 1; opacity: 0; transform: scale(.6); transition: .14s ease; }
.subscription-card input[type="checkbox"]:checked { border-color: var(--teal); background: var(--teal); box-shadow: 0 0 0 4px var(--teal-soft); }
.subscription-card input[type="checkbox"]:checked::after { opacity: 1; transform: scale(1); }
.subscription-card input[type="checkbox"]:focus-visible { outline: 3px solid rgba(168, 218, 80, .45); outline-offset: 2px; }
.subscription-card:has(input:checked) { border-color: #b8d488; background: #fbfdf7; }
.subscription-card span { display: grid; gap: .15rem; }
.subscription-card strong { font-size: .95rem; }
.subscription-card small, .privacy-note { color: var(--muted); font-size: .82rem; }
.subscription-status { width: fit-content; margin-top: .25rem; padding: .18rem .5rem; border-radius: 999px; font-weight: 750; }
.subscription-card .status-on { display: none; color: #47661b; background: var(--teal-soft); }
.subscription-card .status-off { display: inline-flex; color: var(--muted); background: var(--blue-soft); }
.subscription-card input:checked + span .status-on { display: inline-flex; }
.subscription-card input:checked + span .status-off { display: none; }
.privacy-note { margin: 0; }
.autosave-note { margin: -.25rem 0 0; color: var(--teal); font-size: .8rem; font-weight: 700; }
.button:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.detail-head { margin-bottom: 1.15rem; padding: .4rem 0 .9rem; }
.detail-badges { display: flex; gap: .5rem; margin-top: .85rem; }
.prose p { color: #47504c; }
.prose dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin: 1.25rem 0 0; padding-top: 1rem; border-top: 1px solid var(--line); }
.prose dl div { display: grid; }
.prose dt { color: var(--muted); font-size: .75rem; }
.prose dd { margin: .1rem 0 0; font-weight: 650; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-bottom: 1.5rem; }
.photo-grid img { aspect-ratio: 4/3; width: 100%; border-radius: 13px; object-fit: cover; }
.timeline { margin: 0; padding: 0; list-style: none; }
.timeline li { position: relative; display: grid; grid-template-columns: 18px 1fr; gap: .75rem; padding-bottom: 1.2rem; }
.timeline li::before { position: absolute; top: 15px; bottom: -2px; left: 6px; width: 2px; background: var(--line); content: ""; }
.timeline li:last-child::before { display: none; }
.timeline li > span { z-index: 1; width: 14px; height: 14px; margin-top: 3px; border: 3px solid #fff; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 2px var(--teal-soft); }
.timeline li > div { padding: .9rem; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.timeline li > div > div { display: flex; justify-content: space-between; gap: .5rem; }
.timeline time { color: var(--muted); font-size: .76rem; }
.timeline p { margin: .35rem 0 0; color: #4f5853; }

.calendar-list { display: grid; gap: .8rem; }
.calendar-card { display: grid; grid-template-columns: 84px 1fr; gap: 1.2rem; padding: 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.calendar-card.important { border-left: 5px solid var(--amber); }
.calendar-card > time { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 82px; border-radius: 14px; background: var(--blue-soft); line-height: 1.05; }
.calendar-card > time strong { font-size: 2rem; }
.calendar-card > time span { margin-top: .2rem; color: var(--muted); font-size: .75rem; text-transform: uppercase; }
.calendar-card h2 { margin-bottom: .35rem; }
.calendar-card p { color: #4f5853; }
.calendar-card footer { color: var(--muted); font-size: .85rem; font-weight: 650; }
.calendar-card .card-meta b { color: var(--amber); }
.past-events { margin-top: 2rem; }
.past-events summary { cursor: pointer; color: var(--teal); font-weight: 700; }
.compact-list { margin-top: 1rem; opacity: .78; }

.document-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.document-group { margin-bottom: 2rem; }
.document-group-head { display: flex; align-items: center; gap: .75rem; margin-bottom: .8rem; }
.document-group-head h2, .document-group-head p { margin-bottom: 0; }
.document-group-head p { color: var(--muted); font-size: .85rem; }
.folder-icon { display: grid; flex: 0 0 42px; place-items: center; width: 42px; height: 38px; border-radius: 9px; color: var(--teal); background: var(--teal-soft); font-size: 1.1rem; }
.document-card { display: flex; align-items: flex-start; gap: 1rem; padding: 1.2rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.document-card > div { min-width: 0; flex: 1; }
.document-card h2 { margin-bottom: .35rem; }
.document-card p { color: var(--muted); }
.document-card .button { min-height: 38px; margin-top: .35rem; padding: .45rem .7rem; font-size: .83rem; }

.empty-state { padding: 2.3rem 1rem; text-align: center; }
.empty-state > span { display: grid; place-items: center; width: 48px; height: 48px; margin: 0 auto .7rem; border-radius: 50%; color: var(--teal); background: var(--teal-soft); font-size: 1.25rem; font-weight: 800; }
.empty-state h3, .empty-state p { margin-bottom: .2rem; }
.empty-state p { color: var(--muted); }
.toast-stack { position: fixed; z-index: 50; top: 88px; right: 1rem; display: grid; gap: .5rem; }
.toast { max-width: 340px; padding: .8rem 1rem; border: 1px solid #c9dfa4; border-radius: 12px; background: var(--teal-soft); box-shadow: var(--shadow); }
.toast.error { border-color: #f0c0ba; background: var(--red-soft); }

.bottom-nav { display: none; }
.auth-page { display: grid; place-items: center; background: radial-gradient(circle at 15% 10%, rgba(168,218,80,.24), transparent 35%), linear-gradient(145deg, #fafbf8, #e8ece7); }
.auth-shell { width: min(100% - 2rem, 460px); padding: 2rem 0; }
.login-card { display: grid; gap: 1.5rem; padding: clamp(1.4rem, 6vw, 2.4rem); border: 1px solid rgba(255,255,255,.86); border-radius: 24px; background: rgba(255,255,255,.94); box-shadow: 0 24px 70px rgba(48, 54, 56, .15); }
.login-brand { padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.login-help { margin: 0; color: var(--muted); font-size: .82rem; text-align: center; }
.form-link { color: var(--teal); font-weight: 700; }
.stack-form > .form-link { margin-top: -.35rem; text-align: right; font-size: .84rem; }
.account-email-form { margin-bottom: 1rem; }
.account-email-form h2, .subscription-form h2 { margin-bottom: .2rem; }

@media (max-width: 820px) {
  .page-shell { width: min(100% - 1.5rem, 680px); padding-top: 1.5rem; }
  .content-grid, .detail-layout { grid-template-columns: 1fr; }
  .status-grid { grid-template-columns: repeat(3, 1fr); }
  .stat-card { flex-direction: column; align-items: flex-start; gap: .55rem; }
  .document-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .topbar { height: 66px; padding: 0 .8rem; }
  .brand-mark { width: 35px; height: 35px; }
  .page-shell { width: calc(100% - 1.25rem); padding: 1.25rem 0 calc(6.5rem + env(safe-area-inset-bottom)); }
  .welcome-row, .page-head { align-items: stretch; flex-direction: column; gap: 1rem; margin-bottom: 1.35rem; }
  .welcome-row .button, .page-head .button { width: 100%; }
  .status-grid { grid-template-columns: repeat(3, 1fr); gap: .45rem; margin-bottom: 1.8rem; }
  .stat-card { padding: .75rem .65rem; }
  .stat-icon { width: 34px; height: 34px; border-radius: 10px; }
  .stat-card strong { font-size: 1.4rem; }
  .stat-card div span { display: block; font-size: .7rem; line-height: 1.2; }
  .issue-card { align-items: flex-start; min-height: 0; padding: .9rem; }
  .issue-card .status-pill { align-self: center; max-width: 92px; white-space: normal; text-align: center; }
  .card-meta time { display: none; }
  .panel { padding: 1rem; }
  .prose dl { grid-template-columns: 1fr; gap: .7rem; }
  .photo-grid { grid-template-columns: repeat(2, 1fr); }
  .calendar-card { grid-template-columns: 62px 1fr; gap: .8rem; padding: .9rem; }
  .calendar-card > time { min-height: 70px; }
  .calendar-card > time strong { font-size: 1.55rem; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .button { width: 100%; }
  .bottom-nav { position: fixed; z-index: 30; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(4, 1fr); padding: .45rem .25rem max(.45rem, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(255,255,255,.97); box-shadow: 0 -8px 28px rgba(45,53,50,.08); backdrop-filter: blur(14px); }
  .bottom-nav a { display: flex; align-items: center; flex-direction: column; gap: .15rem; padding: .28rem; color: #747c77; font-size: .68rem; font-weight: 650; }
  .bottom-nav a > span { display: grid; place-items: center; width: 26px; height: 24px; font-size: 1.12rem; font-weight: 800; }
  .bottom-nav a.active { color: var(--navy); }
  .bottom-nav a.active > span { color: var(--teal); }
  .toast-stack { top: 74px; right: .7rem; left: .7rem; }
  .toast { max-width: none; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
