@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("./fonts/source-sans-3-v20-latin.woff2") format("woff2");
}

@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("./fonts/source-serif-4-v15-latin.woff2") format("woff2");
}

/* ---------- tokens ---------- */
:root {
  --ink: #0e392f;
  --ink-2: #17493d;
  --accent: #fbb03c;
  --accent-soft: #fef4e2;
  --soft: #f0f4f2;
  --muted: #5d6c66;
  --line: #e1e8e4;
  --line-strong: #cad6d0;
  --card: #fff;
  --page: #f5f7f6;
  --ok: #067647;
  --ok-soft: #ecfdf3;
  --warn: #b54708;
  --warn-soft: #fffaeb;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --info: #175cd3;
  --info-soft: #eff8ff;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-card: 0 10px 30px -22px rgba(14, 57, 47, 0.5);
  --shadow-pop: 0 24px 60px -24px rgba(14, 57, 47, 0.45);
  --font-head: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-body: "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, sans-serif;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font: 14px/1.55 var(--font-body);
  font-synthesis: none;
}

body.app-body {
  background: var(--page);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

:is(a, button, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1,
h2,
h3 {
  font-family: var(--font-head);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

img {
  max-width: 100%;
}

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

.small {
  font-size: 12px;
}

.money {
  font-family: var(--font-head);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.ico {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.btn-primary:hover {
  background: var(--ink-2);
  border-color: var(--ink-2);
}

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #241a05;
}

.btn-accent:hover {
  filter: brightness(1.04);
}

.btn-ghost {
  background: #fff;
  border-color: var(--line-strong);
}

.btn-ghost:hover {
  border-color: var(--ink);
}

.btn-quiet {
  padding: 0 8px;
  min-height: 30px;
  color: var(--muted);
}

.btn-quiet:hover {
  color: var(--ink);
  background: var(--soft);
}

.btn-danger-quiet {
  color: var(--danger);
}

.btn-danger-quiet:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  min-height: 32px;
  padding: 0 11px;
  font-size: 12px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}

.icon-btn:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}

/* ---------- pills ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.pill-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.pill-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.pill-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.pill-info {
  background: var(--info-soft);
  color: var(--info);
}

.pill-gold {
  background: var(--accent-soft);
  color: #8a5a00;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

/* ---------- app shell ---------- */
.app {
  display: flex;
  min-height: 100vh;
}

.sider {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  width: 244px;
  flex: none;
  height: 100vh;
  background: #fff;
  border-right: 1px solid var(--line);
}

.sider-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
}

.sider-brand img {
  height: 30px;
  width: auto;
}

.sider-brand .brand-tag {
  margin-top: 0;
  padding-left: 10px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font: 700 9px/1.35 var(--font-body);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.sider-nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 12px;
}

.nav-label {
  padding: 12px 8px 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  margin-bottom: 2px;
  padding: 0 10px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

button.nav-item {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  font-family: inherit;
}

.nav-item:hover {
  background: var(--soft);
  color: var(--ink);
}

.nav-item.active {
  background: var(--soft);
  color: var(--ink);
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav-item .pill {
  margin-left: auto;
}

.sider-foot {
  padding: 12px;
  border-top: 1px solid var(--line);
}

.sider-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
}

.sider-user:hover {
  background: var(--soft);
}

.sider-user b {
  display: block;
  font-size: 12px;
  line-height: 1.3;
}

.sider-user span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.avatar-lg {
  width: 44px;
  height: 44px;
  font-size: 14px;
}

.app-main {
  flex: 1;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 10px 24px;
  background: rgba(245, 247, 246, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.menu-btn {
  display: none;
}

.topbar-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.topbar-title h1 {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-title p {
  margin-top: 1px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.context {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.context select {
  max-width: 150px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

.bell {
  position: relative;
}

.bell::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--danger);
  border: 1px solid #fff;
}

.subject-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 24px;
  background: var(--accent-soft);
  border-bottom: 1px solid #f3dfb7;
  color: #6b4700;
  font-size: 12px;
}

.subject-banner b {
  font-weight: 700;
}

.subject-banner .btn {
  margin-left: auto;
}

.install-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 24px 0;
  padding: 10px 12px;
  border: 1px solid #f0dfbd;
  border-radius: 12px;
  background: linear-gradient(135deg, #fffaf0, #fff 70%);
}

.install-banner img {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 10px;
}

.install-copy {
  flex: 1;
  min-width: 0;
}

.install-copy b {
  display: block;
  font-size: 12px;
  line-height: 1.3;
}

.install-copy span {
  display: block;
  margin-top: 1px;
  color: #6b4700;
  font-size: 11px;
  line-height: 1.35;
}

.install-close {
  width: 32px;
  height: 32px;
  flex: none;
  border: 0;
  background: transparent;
}

.install-hero {
  display: flex;
  align-items: center;
  gap: 14px;
}

.install-hero img {
  border-radius: 14px;
}

.install-hero b {
  display: block;
  font-family: var(--font-head);
  font-size: 20px;
  line-height: 1.2;
}

.install-hero span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.install-steps {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
}

.install-steps li {
  padding-left: 2px;
}

.mobile-tabs {
  display: none;
}

.content {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.page-head h2 {
  font-size: 24px;
}

.page-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  max-width: 620px;
}

.page-head .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.card-pad {
  padding: 18px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.card-head h3 {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
}

.card-head .btn,
.card-head .link {
  margin-left: auto;
}

.link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.link:hover {
  border-bottom-color: var(--accent);
}

/* ---------- summary ---------- */
.hero-band {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 16px;
}

.hero-band .eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.hero-band h2 {
  margin-top: 4px;
  font-size: 28px;
}

.hero-band .hero-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi {
  position: relative;
  overflow: hidden;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.kpi-top {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.kpi-top .ico {
  width: 15px;
  height: 15px;
}

.kpi-value {
  margin-top: 10px;
  font-family: var(--font-head);
  font-size: 23px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.kpi-foot {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}

.kpi-unit {
  margin-left: 2px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.kpi-accent {
  background: linear-gradient(135deg, #fffaf0 0%, #fff 60%);
  border-color: #f0dfbd;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stack {
  display: grid;
  gap: 12px;
}

/* ---------- rows & accounts ---------- */
.due-list,
.acct-list,
.cert-list {
  display: grid;
  gap: 2px;
}

.due-row,
.acct-row,
.cert-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 8px;
  border-radius: 9px;
}

.due-row:hover,
.acct-row:hover,
.cert-row:hover {
  background: #fafcfb;
}

.due-date {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 10px;
  background: var(--soft);
  color: var(--ink);
  text-align: center;
  line-height: 1;
}

.due-date b {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 600;
}

.due-date span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.due-main,
.acct-main,
.cert-main {
  min-width: 0;
  flex: 1;
}

.due-main b,
.acct-main b,
.cert-main b {
  display: block;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}

.due-main span,
.acct-main span,
.cert-main span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.row-side {
  text-align: right;
  flex: none;
}

.row-side .money {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.row-side .pill {
  margin-top: 4px;
}

.acct-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 11px;
  background: var(--soft);
  color: var(--ink);
}

.acct-icon.gold {
  background: var(--accent-soft);
  color: #8a5a00;
}

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

.acct-card {
  display: flex;
  flex-direction: column;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.acct-card-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.acct-card-top b {
  display: block;
  font-size: 13px;
}

.acct-card-top span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.acct-card-top .pill {
  margin-left: auto;
}

.acct-balance {
  margin: 16px 0 2px;
  font-family: var(--font-head);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.acct-meta {
  display: grid;
  gap: 4px;
  margin: 12px 0 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.acct-meta div {
  display: flex;
  gap: 8px;
}

.acct-meta b {
  margin-left: auto;
  color: var(--ink);
  font-weight: 600;
}

.acct-card .btn {
  margin-top: auto;
}

.summary-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 28px;
  padding: 16px 18px;
  margin-bottom: 16px;
  background: var(--ink);
  border-radius: var(--radius-lg);
  color: #fff;
}

.summary-strip .label {
  color: rgba(255, 255, 255, 0.68);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.summary-strip .value {
  margin-top: 2px;
  font-family: var(--font-head);
  font-size: 25px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.summary-strip .aside {
  margin-left: auto;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  max-width: 340px;
}

.progress {
  height: 6px;
  margin-top: 10px;
  border-radius: 999px;
  background: var(--soft);
  overflow: hidden;
}

.progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--ink);
}

/* ---------- events ---------- */
.event-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 12px;
}

.event-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.event-cover {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--soft);
  overflow: hidden;
}

.event-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.event-cover .pill {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(4px);
}

.event-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 14px;
}

.event-body h3 {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0;
}

.event-body .desc {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.event-meta {
  display: grid;
  gap: 4px;
  margin: 12px 0;
  color: var(--muted);
  font-size: 11px;
}

.event-meta div {
  display: flex;
  align-items: center;
  gap: 6px;
}

.event-meta .ico {
  width: 13px;
  height: 13px;
}

.event-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
}

.event-foot .quota {
  color: var(--muted);
  font-size: 11px;
}

.event-foot .btn {
  margin-left: auto;
}

.mini-events {
  display: grid;
  gap: 10px;
}

.mini-event {
  display: flex;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
}

.mini-event .date-chip {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 9px;
  background: var(--accent-soft);
  color: #6b4700;
  text-align: center;
  line-height: 1;
}

.mini-event .date-chip b {
  font-family: var(--font-head);
  font-size: 16px;
}

.mini-event .date-chip span {
  margin-top: 2px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mini-event b {
  display: block;
  font-size: 12px;
  line-height: 1.35;
}

.mini-event span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

/* ---------- misc ---------- */
.callout {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--info-soft);
  border: 1px solid #d1e9ff;
  color: #194185;
  font-size: 12px;
}

.callout.warn {
  background: var(--warn-soft);
  border-color: #fedf89;
  color: #7a2e0e;
}

.callout .ico {
  margin-top: 1px;
}

.callout b {
  font-weight: 700;
}

.empty {
  display: grid;
  place-items: center;
  padding: 32px 20px;
  text-align: center;
  color: var(--muted);
}

.empty .empty-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 10px;
  border-radius: 50%;
  background: var(--soft);
  color: var(--ink);
}

.empty b {
  display: block;
  color: var(--ink);
  font-size: 13px;
}

.empty p {
  margin-top: 4px;
  max-width: 320px;
  font-size: 12px;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 14px 0;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.chip:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

/* ---------- family ---------- */
.person-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.person-card .who {
  flex: 1;
  min-width: 0;
}

.person-card .who b {
  font-size: 14px;
}

.person-card .who span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.person-card .chip-row {
  margin-top: 8px;
}

.person-card .btn {
  align-self: center;
}

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

/* ---------- sheet / dialog ---------- */
.sheet {
  width: min(560px, 100vw);
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 14px 0 0 14px;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}

.sheet.sm {
  width: min(420px, 100vw);
}

.sheet::backdrop {
  background: rgba(8, 30, 25, 0.42);
  backdrop-filter: blur(2px);
}

.sheet-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.sheet-head .kicker {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sheet-head h2 {
  margin-top: 3px;
  font-size: 20px;
}

.sheet-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.sheet-close {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--muted);
}

.sheet-close:hover {
  color: var(--ink);
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.sheet-body.center {
  display: grid;
  place-items: center;
}

.sheet-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.sheet-foot .btn-primary,
.sheet-foot .btn-accent {
  flex: 1;
}

.detail-hero {
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--soft);
}

.detail-hero .label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.detail-hero .value {
  margin: 4px 0 6px;
  font-family: var(--font-head);
  font-size: 28px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}

.info-grid div {
  min-width: 0;
}

.info-grid dt {
  color: var(--muted);
  font-size: 11px;
}

.info-grid dd {
  margin: 2px 0 0;
  font-size: 12px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.tx-list {
  display: grid;
  gap: 2px;
}

.tx-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--soft);
}

.tx-row:last-child {
  border-bottom: 0;
}

.tx-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 9px;
  background: var(--soft);
  color: var(--ink);
}

.tx-icon.out {
  background: var(--danger-soft);
  color: var(--danger);
}

.tx-main {
  flex: 1;
  min-width: 0;
}

.tx-main b {
  display: block;
  font-size: 12px;
  font-weight: 600;
}

.tx-main span {
  color: var(--muted);
  font-size: 11px;
}

.tx-amount {
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tx-amount.in {
  color: var(--ok);
}

.tx-amount.out {
  color: var(--danger);
}

.sched {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.sched th {
  padding: 6px 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  text-align: right;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line);
}

.sched th:first-child,
.sched td:first-child {
  text-align: left;
}

.sched td {
  padding: 8px;
  text-align: right;
  border-bottom: 1px solid var(--soft);
  font-variant-numeric: tabular-nums;
}

.sched tr.overdue td {
  background: var(--danger-soft);
}

.sched-scroll {
  overflow-x: auto;
}

/* ---------- timeline ---------- */
.timeline {
  display: grid;
  gap: 0;
  margin-top: 6px;
}

.step {
  position: relative;
  display: flex;
  gap: 10px;
  padding-bottom: 16px;
}

.step:last-child {
  padding-bottom: 0;
}

.step::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 20px;
  bottom: 0;
  width: 1px;
  background: var(--line);
}

.step:last-child::before {
  display: none;
}

.step-dot {
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--muted);
}

.step.done .step-dot {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}

.step.done .step-dot .ico {
  width: 11px;
  height: 11px;
}

.step.now .step-dot {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #8a5a00;
}

.step b {
  display: block;
  font-size: 12px;
}

.step span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

/* ---------- forms ---------- */
.form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 5px;
}

.field > label {
  font-size: 12px;
  font-weight: 600;
}

.field .hint {
  color: var(--muted);
  font-size: 11px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #fff;
  font-size: 13px;
  outline: none;
}

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

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(251, 176, 60, 0.22);
}

.field.invalid input,
.field.invalid select,
.field.invalid textarea {
  border-color: var(--danger);
}

.field .error {
  display: none;
  color: var(--danger);
  font-size: 11px;
}

.field.invalid .error {
  display: block;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.input-wrap {
  position: relative;
}

.input-wrap input {
  padding-right: 42px;
}

.input-wrap .toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
}

.input-wrap .toggle:hover {
  color: var(--ink);
  background: var(--soft);
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

.check input {
  width: 16px;
  height: 16px;
  margin: 1px 0 0;
  accent-color: var(--ink);
  flex: none;
}

.check a {
  color: var(--ink);
  font-weight: 600;
}

.form-note {
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--soft);
  color: var(--muted);
  font-size: 11px;
}

.estimate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: #6b4700;
  font-size: 12px;
}

.estimate b {
  font-family: var(--font-head);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.success {
  display: grid;
  place-items: center;
  padding: 24px 8px;
  text-align: center;
}

.success-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 14px;
  border-radius: 50%;
  background: var(--ok-soft);
  color: var(--ok);
}

.success-icon .ico {
  width: 26px;
  height: 26px;
  stroke-width: 2;
}

.success h3 {
  font-family: var(--font-head);
  font-size: 22px;
}

.success p {
  margin-top: 6px;
  max-width: 340px;
  color: var(--muted);
  font-size: 12px;
}

.ref-box {
  width: 100%;
  margin: 16px 0;
  padding: 12px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: #fcfdfc;
  text-align: left;
}

.ref-box span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ref-box b {
  display: block;
  margin-top: 2px;
  font-size: 14px;
  letter-spacing: 0.04em;
}

.success-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

/* ---------- certificate preview ---------- */
.certificate-preview {
  position: relative;
  padding: 22px 18px;
  border: 1px solid #e7d5ab;
  border-radius: 8px;
  background: #fffdf7;
  text-align: center;
}

.certificate-preview::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid #f0dfbd;
  border-radius: 5px;
  pointer-events: none;
}

.certificate-preview .cert-kicker {
  color: #8a5a00;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.certificate-preview h3 {
  margin: 10px 0 4px;
  font-size: 21px;
}

.certificate-preview .cert-name {
  margin-top: 14px;
  font-family: var(--font-head);
  font-size: 18px;
  border-bottom: 1px solid #e7d5ab;
  display: inline-block;
  padding: 0 18px 3px;
}

.certificate-preview .cert-meta {
  margin-top: 12px;
  color: var(--muted);
  font-size: 10px;
}

.certificate-preview .cert-seal {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin: 14px auto 0;
  border-radius: 50%;
  border: 1px solid #e7d5ab;
  color: #8a5a00;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(8, 30, 25, 0.42);
}

/* ---------- auth ---------- */
.auth-body {
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 10% -10%, #e7efe9 0%, transparent 60%),
    radial-gradient(700px 420px at 100% 110%, #fdf2dc 0%, transparent 55%),
    var(--page);
}

.auth-wrap {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 28px 20px;
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  width: 100%;
  max-width: 1040px;
  min-height: 620px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 30px 80px -50px rgba(14, 57, 47, 0.55);
  overflow: hidden;
}

.auth-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 34px;
  background: var(--ink);
  color: #fff;
  overflow: hidden;
}

.auth-brand::before {
  content: "";
  position: absolute;
  right: -120px;
  top: -110px;
  width: 340px;
  height: 340px;
  border: 1px solid rgba(251, 176, 60, 0.22);
  border-radius: 50%;
}

.auth-brand::after {
  content: "";
  position: absolute;
  right: -40px;
  top: -40px;
  width: 220px;
  height: 220px;
  border: 1px solid rgba(251, 176, 60, 0.16);
  border-radius: 50%;
}

.auth-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  align-self: flex-start;
  padding: 8px 12px;
  border-radius: 9px;
  background: #fff;
}

.auth-logo img {
  height: 30px;
  width: auto;
}

.auth-brand .auth-copy {
  position: relative;
  z-index: 1;
  margin: auto 0;
  padding: 32px 0;
}

.auth-brand .eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.auth-brand h1 {
  margin-top: 10px;
  max-width: 400px;
  font-size: 34px;
  line-height: 1.12;
}

.auth-brand .sub {
  margin-top: 12px;
  max-width: 360px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
}

.auth-points {
  display: grid;
  gap: 10px;
  margin-top: 26px;
}

.auth-points div {
  display: flex;
  align-items: center;
  gap: 9px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 12px;
}

.auth-points .ico {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.auth-brand .auth-foot {
  position: relative;
  z-index: 1;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.62);
  font-size: 11px;
}

.auth-brand .auth-foot b {
  display: block;
  color: #fff;
  font-size: 12px;
}

.auth-panel {
  display: flex;
  flex-direction: column;
  padding: 34px 40px;
}

.auth-mobile-logo {
  display: none;
  margin-bottom: 18px;
}

.auth-mobile-logo img {
  height: 30px;
}

.auth-tabs {
  display: flex;
  gap: 22px;
  border-bottom: 1px solid var(--line);
}

.auth-tab {
  position: relative;
  padding: 0 0 11px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.auth-tab:hover {
  color: var(--ink);
}

.auth-tab.active {
  color: var(--ink);
}

.auth-tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
}

.auth-panel-body {
  flex: 1;
  padding-top: 22px;
}

.auth-panel h2 {
  font-size: 24px;
}

.auth-panel .lead {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.auth-panel .form {
  margin-top: 20px;
}

.auth-panel .btn-primary,
.auth-panel .btn-accent {
  min-height: 40px;
  margin-top: 2px;
}

.demo-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
  text-align: center;
}

.auth-panel .success {
  padding-top: 12px;
}

.auth-panel .success .success-actions .btn {
  flex: 1;
}

.auth-register {
  margin-top: 16px;
  color: var(--muted);
  text-align: center;
  font-size: 11px;
}

.auth-register a {
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.auth-register a:hover {
  text-decoration: underline;
}

.auth-legal {
  margin-top: auto;
  padding-top: 22px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.auth-steps {
  display: grid;
  gap: 10px;
  margin: 16px 0;
  padding: 14px;
  border-radius: 11px;
  background: var(--soft);
}

.auth-step {
  display: flex;
  gap: 9px;
  font-size: 11px;
  color: var(--muted);
}

.auth-step b {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: none;
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  font-size: 10px;
  border: 1px solid var(--line);
}

.auth-step strong {
  display: block;
  color: var(--ink);
  font-size: 12px;
}

.auth-alt {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 11px;
}

.auth-alt b {
  display: block;
  color: var(--ink);
  font-size: 12px;
}

.auth-help {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 11px;
}

.auth-help .ico {
  width: 14px;
  height: 14px;
}

.preview-link {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(6px);
}

.preview-link:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .sider {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    width: 268px;
    box-shadow: var(--shadow-pop);
  }

  .sider.open {
    transform: translateX(0);
  }

  .topbar {
    padding: 8px 12px;
  }

  .topbar .menu-btn {
    display: inline-grid;
  }
  .content {
    padding: 16px 12px 28px;
  }

  .install-banner {
    margin: 10px 12px 0;
  }

  .mobile-tabs {
    position: sticky;
    top: 64px;
    z-index: 18;
    display: flex;
    gap: 4px;
    padding: 7px 12px;
    overflow-x: auto;
    background: rgba(245, 247, 246, 0.97);
    border-bottom: 1px solid var(--line);
    scrollbar-width: none;
  }

  .mobile-tabs::-webkit-scrollbar {
    display: none;
  }

  .mobile-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: none;
    min-height: 34px;
    padding: 0 10px;
    border-radius: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
  }

  .mobile-tab .ico {
    width: 15px;
    height: 15px;
  }

  .mobile-tab.active {
    background: #fff;
    color: var(--ink);
    box-shadow: 0 0 0 1px var(--line);
  }

  .hero-band {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-actions {
    margin-left: 0;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .auth-shell {
    grid-template-columns: 1fr;
    max-width: 560px;
    min-height: 0;
  }

  .auth-brand {
    display: none;
  }

  .auth-panel {
    padding: 28px 24px;
  }

  .auth-mobile-logo {
    display: block;
  }
}

@media (max-width: 640px) {
  .preview-link {
    display: none;
  }

  .topbar-title h1 {
    font-size: 15px;
  }

  .topbar-title p {
    display: none;
  }

  .context {
    padding: 0 8px;
  }

  .context > span {
    display: none;
  }

  .context select {
    max-width: 108px;
  }

  .hero-band h2,
  .page-head h2 {
    font-size: 22px;
  }

  .page-head {
    flex-direction: column;
    gap: 10px;
  }

  .page-head .actions {
    margin-left: 0;
  }

  .kpi {
    padding: 13px;
  }

  .kpi-value {
    font-size: 19px;
  }

  .kpi-top {
    font-size: 10px;
  }

  .summary-strip {
    gap: 12px 20px;
  }

  .summary-strip .aside {
    margin-left: 0;
  }

  .due-row,
  .acct-row,
  .cert-row {
    gap: 9px;
    padding: 9px 4px;
  }

  .due-date {
    width: 38px;
    height: 38px;
  }

  .row-side .money {
    font-size: 13px;
  }

  .sheet {
    width: 100vw;
    border-radius: 0;
  }

  .sheet-head,
  .sheet-body,
  .sheet-foot {
    padding-left: 14px;
    padding-right: 14px;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .person-card {
    flex-wrap: wrap;
  }

  .person-card .btn {
    width: 100%;
  }

  .event-grid {
    grid-template-columns: 1fr;
  }

  .auth-wrap {
    padding: 0;
    align-items: stretch;
  }

  .auth-shell {
    max-width: none;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .auth-panel {
    padding: 22px 18px;
  }
}

@media (max-width: 420px) {
  #top-avatar {
    display: none;
  }
}

@media (max-width: 360px) {
  .bell {
    display: none;
  }
}

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