@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Fraunces:opsz,wght@9..144,600;9..144,700&display=swap');

:root {
  --ink: #17242c;
  --ink-soft: #53616a;
  --muted: #859098;
  --paper: #f7f7f3;
  --white: #ffffff;
  --line: #e2e5e2;
  --line-dark: #c9cfcc;
  --yellow: #ffe000;
  --red: #c51d28;
  --green: #087a43;
  --blue: #0756b7;
  --navy: #101a22;
  --sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --serif: 'Fraunces', Georgia, serif;
  --shadow: 0 14px 30px rgba(23, 36, 44, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: var(--sans); font-size: 15px; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid rgba(7, 86, 183, .45); outline-offset: 3px; }
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; }
.login-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(300px, .85fr) minmax(360px, 420px); grid-template-rows: 1fr auto; gap: 28px 9vw; align-content: center; padding: 8vh 12vw; background: var(--navy); color: var(--white); position: relative; overflow: hidden; }
.login-screen::before { content: ''; position: absolute; width: 640px; height: 640px; border: 1px solid rgba(255,255,255,.1); border-radius: 50%; right: -250px; top: -200px; box-shadow: 0 0 0 42px rgba(255,255,255,.025), 0 0 0 84px rgba(255,255,255,.018); }
.login-screen::after { content: ''; position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--yellow); left: 8vw; top: 15vh; box-shadow: 16px 0 0 rgba(255,255,255,.12), 32px 0 0 rgba(255,255,255,.06); }
.login-mark { width: 150px; height: 150px; position: absolute; left: 12vw; top: 7vh; display: grid; place-items: center; opacity: .98; }
.login-mark img { display: block; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 12px 18px rgba(0,0,0,.22)); }
.login-copy { grid-column: 1; grid-row: 1; align-self: end; max-width: 530px; position: relative; z-index: 1; padding-top: 90px; }
.kicker, .card-kicker { margin: 0 0 14px; color: var(--yellow); font-size: 11px; font-weight: 700; letter-spacing: .09em; line-height: 1.3; text-transform: uppercase; }
.login-copy h1 { margin: 0; font-family: var(--serif); font-size: clamp(52px, 7vw, 102px); font-weight: 600; letter-spacing: -.065em; line-height: .87; }
.login-copy h1 em, .welcome-row h1 em { color: var(--yellow); font-style: normal; }
.login-intro { max-width: 360px; margin: 30px 0 0; color: rgba(255,255,255,.68); font-size: 16px; line-height: 1.6; }
.login-card { grid-column: 2; grid-row: 1; align-self: center; position: relative; z-index: 1; display: grid; gap: 17px; padding: 35px; color: var(--ink); background: var(--white); box-shadow: 16px 18px 0 rgba(255, 224, 0, .95); }
.login-card h2, .record-dialog h2 { margin: 0; font-family: var(--serif); font-size: 27px; font-weight: 600; letter-spacing: -.04em; }
.login-card .card-kicker, .record-dialog .card-kicker { color: var(--muted); margin-bottom: 7px; }
.login-card label, .dialog-fields label { display: grid; gap: 7px; color: var(--ink-soft); font-size: 12px; font-weight: 600; }
.login-card input, .dialog-fields input { width: 100%; height: 46px; border: 1px solid var(--line-dark); border-radius: 0; padding: 0 13px; color: var(--ink); background: #fbfcfa; transition: border-color .15s, background .15s; }
.login-card input:focus, .dialog-fields input:focus { border-color: var(--ink); background: var(--white); outline: none; }
.dialog-fields input[readonly] { color: var(--ink-soft); background: #f3f5f2; }
.button { min-height: 43px; border: 1px solid transparent; border-radius: 0; padding: 0 17px; font-size: 12px; font-weight: 700; transition: transform .15s, background .15s, border-color .15s; }
.button:hover { transform: translateY(-1px); }
.button-dark { color: var(--white); background: var(--navy); }
.button-dark:hover { background: #263b49; }
.button-quiet { color: var(--ink-soft); background: transparent; }
.button-quiet:hover { color: var(--ink); background: #eef1ee; }
.button-outline { color: var(--ink-soft); border-color: var(--line-dark); background: transparent; }
.button-outline:hover { border-color: var(--ink); color: var(--ink); }
.form-error { margin: 0; color: #a71922; font-size: 12px; line-height: 1.45; }
.login-note { grid-column: 1 / -1; grid-row: 2; position: relative; z-index: 1; margin: 0; color: rgba(255,255,255,.36); font-size: 11px; }

.main-view { min-height: 100vh; background: var(--paper); }
.topbar { min-height: 77px; padding: 0 max(24px, 5vw); display: flex; align-items: center; justify-content: space-between; gap: 24px; background: var(--white); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand strong { display: block; font-family: var(--serif); font-size: 20px; letter-spacing: -.045em; line-height: 1; }
.brand small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; letter-spacing: .04em; }
.brand-logo { display: block; width: 44px; height: 44px; object-fit: contain; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.user-badge { margin-right: 6px; color: var(--muted); font-size: 11px; }
.content { width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 78px 0 72px; }
.welcome-row { display: flex; align-items: end; justify-content: space-between; gap: 40px; padding-bottom: 63px; }
.welcome-row .kicker, .section-heading .kicker { color: var(--green); }
.welcome-row h1 { max-width: 610px; margin: 0; font-family: var(--serif); font-size: clamp(48px, 7.4vw, 88px); font-weight: 600; letter-spacing: -.072em; line-height: .91; }
.welcome-row h1 em { color: var(--green); }
.lead { max-width: 415px; margin: 27px 0 0; color: var(--ink-soft); font-size: 15px; line-height: 1.55; }
.totals-note { display: flex; align-items: center; gap: 12px; padding: 0 0 5px; color: var(--ink-soft); font-size: 12px; line-height: 1.3; }
.totals-number { font-family: var(--serif); color: var(--ink); font-size: 55px; letter-spacing: -.08em; line-height: .8; }
.stats-strip { display: grid; grid-template-columns: 150px 1fr; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat-intro { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; font-weight: 600; }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(8,122,67,.12); }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); }
.stat { min-height: 88px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 18px 17px; border: 0; border-left: 1px solid var(--line); color: var(--ink); font: inherit; text-align: left; }
.stat-name { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; }
.stat-name i, .tab i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--group-color); }
.stat-numbers { color: var(--muted); font-size: 11px; text-align: right; line-height: 1.35; }
.stat-numbers strong { display: block; color: inherit; font-family: var(--serif); font-size: 24px; font-weight: 600; letter-spacing: -.04em; }
.group-launcher { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; align-items: center; position: relative; overflow: hidden; color: var(--group-text); background: var(--group-color); transition: filter .15s, transform .15s, box-shadow .15s; }
.group-launcher .stat-name, .group-launcher .stat-numbers { color: inherit; }
.group-launcher .stat-name i { background: currentColor; }
.group-launcher-action { grid-column: 1 / -1; align-self: end; margin-top: 8px; font-size: 10px; font-weight: 700; opacity: .8; }
.group-launcher:hover { filter: saturate(1.12) brightness(.96); transform: translateY(-2px); }
.group-launcher.is-active { box-shadow: inset 0 -4px 0 var(--ink); }
.group-launcher[style*='#ffe000'] { color: #191919; }
.group-launcher:focus-visible { position: relative; z-index: 1; outline-color: var(--ink); outline-offset: -5px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 54px 0 40px; }
.search-wrap { min-width: 270px; flex: 1; max-width: 430px; position: relative; }
.search-label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.search-icon { position: absolute; top: 28px; left: 0; color: var(--ink-soft); font-size: 26px; line-height: 1; transform: rotate(-20deg); }
.search-wrap input { width: 100%; height: 43px; border: 0; border-bottom: 1px solid var(--line-dark); border-radius: 0; padding: 0 32px; color: var(--ink); background: transparent; font-size: 13px; }
.search-wrap input::placeholder { color: #98a0a3; }
.search-wrap input:focus { border-color: var(--ink); outline: none; }
.clear-search { position: absolute; top: 25px; right: 0; width: 30px; height: 30px; border: 0; color: var(--muted); background: transparent; font-size: 22px; }
.group-tabs { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; }
.tab { min-height: 36px; border: 1px solid transparent; padding: 0 12px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 600; }
.tab i { margin-right: 6px; opacity: .3; }
.tab:hover, .tab.is-active { border-color: var(--line-dark); color: var(--ink); background: var(--white); }
.tab.is-active i { opacity: 1; }
.records-section { min-height: 400px; scroll-margin-top: 24px; }
.records-blank { padding: 70px 20px; color: var(--muted); text-align: center; }
.records-blank strong { display: block; margin-bottom: 7px; color: var(--ink); font-family: var(--serif); font-size: 24px; font-weight: 600; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; padding-bottom: 19px; border-bottom: 2px solid var(--ink); }
.section-heading .kicker { margin-bottom: 8px; }
.section-heading h2 { margin: 0; font-family: var(--serif); font-size: 31px; font-weight: 600; letter-spacing: -.05em; }
.result-count { padding-bottom: 4px; color: var(--muted); font-size: 11px; }
.records-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding-top: 18px; }
.record-card { min-height: 216px; display: flex; flex-direction: column; border: 1px solid var(--line); background: var(--white); position: relative; transition: border-color .15s, box-shadow .15s, transform .15s; }
.record-card:hover { border-color: var(--line-dark); box-shadow: var(--shadow); transform: translateY(-2px); }
.record-card:focus-visible { border-color: var(--group-color); outline-color: var(--group-color); }
.card-name-label { display: block; margin-bottom: 5px; color: var(--group-color); font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.card-top { display: flex; align-items: start; justify-content: space-between; gap: 8px; padding: 15px 16px 11px; border-bottom: 1px solid var(--line); }
.card-group { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; font-weight: 700; }
.card-group i { width: 7px; height: 7px; border-radius: 50%; background: var(--group-color); }
.card-number { color: var(--group-color); font-family: var(--serif); font-size: 29px; font-weight: 600; letter-spacing: -.07em; line-height: .9; }
.card-body { flex: 1; padding: 15px 16px; }
.card-child { margin: 0 0 8px; color: var(--ink); font-family: var(--serif); font-size: 19px; font-weight: 600; letter-spacing: -.045em; line-height: 1.08; }
.card-empty .card-child { color: #a4adae; font-size: 15px; font-family: var(--sans); font-weight: 500; letter-spacing: -.02em; }
.card-detail { display: block; overflow: hidden; color: var(--ink-soft); font-size: 11px; line-height: 1.55; text-overflow: ellipsis; white-space: nowrap; }
.card-detail + .card-detail { color: var(--muted); }
.card-full-name { color: var(--ink-soft); font-weight: 600; }
.card-bottom { display: flex; align-items: center; justify-content: space-between; padding: 11px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.edit-hint { color: var(--ink-soft); font-weight: 700; }
.card-empty .edit-hint { color: var(--group-color); }
.empty-state { padding: 72px 20px; text-align: center; }
.empty-icon { display: block; color: var(--muted); font-size: 44px; transform: rotate(-20deg); }
.empty-state h3 { margin: 15px 0 5px; font-family: var(--serif); font-size: 23px; letter-spacing: -.04em; }
.empty-state p { margin: 0; color: var(--muted); font-size: 13px; }
.footer { width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 19px 0 30px; display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; border-top: 1px solid var(--line); }

.record-dialog { width: min(500px, calc(100% - 28px)); padding: 0; border: 0; border-top: 5px solid var(--dialog-color, var(--yellow)); color: var(--ink); background: var(--white); box-shadow: 0 24px 70px rgba(16,26,34,.3); }
.record-dialog::backdrop { background: rgba(16,26,34,.62); }
.record-dialog form { max-height: min(720px, calc(100dvh - 32px)); overflow-y: auto; padding: 30px; }
.dialog-head { display: flex; justify-content: space-between; gap: 15px; margin-bottom: 27px; }
.dialog-title-wrap { display: flex; gap: 11px; align-items: center; }
.dialog-color { width: 10px; height: 45px; background: var(--dialog-color, var(--yellow)); }
.dialog-close { width: 32px; height: 32px; border: 0; color: var(--muted); background: transparent; font-size: 27px; line-height: 1; }
.dialog-fields { display: grid; gap: 17px; }
.field-row { display: grid; grid-template-columns: 1fr 140px; gap: 14px; }
.dialog-meta { min-height: 16px; margin: 18px 0 0; color: var(--muted); font-size: 10px; }
.dialog-actions { display: flex; justify-content: end; gap: 8px; margin-top: 21px; padding-top: 18px; border-top: 1px solid var(--line); }
.toast-region { position: fixed; right: 24px; bottom: 24px; z-index: 20; display: grid; gap: 8px; }
.toast { max-width: 330px; padding: 13px 17px; color: var(--white); background: var(--navy); box-shadow: var(--shadow); font-size: 12px; animation: toast-in .2s ease-out; }
.toast.error { background: #a71922; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 900px) {
  .login-screen { grid-template-columns: 1fr; grid-template-rows: auto auto auto; gap: 35px; padding: 100px 9vw 35px; }
  .login-mark { left: auto; right: 9vw; top: 34px; width: 94px; height: 94px; }
  .login-copy { grid-column: 1; grid-row: 1; padding-top: 0; }
  .login-card { grid-column: 1; grid-row: 2; width: min(420px, 100%); justify-self: start; }
  .login-note { grid-column: 1; grid-row: 3; }
  .records-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 680px) {
  .topbar { min-height: 68px; padding: 0 18px; }
  .brand small, .export-button { display: none; }
  .brand-logo { width: 38px; height: 38px; }
  .user-badge { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .content { width: calc(100% - 32px); padding-top: 44px; }
  .welcome-row { align-items: start; flex-direction: column; gap: 30px; padding-bottom: 42px; }
  .welcome-row h1 { font-size: clamp(43px, 14vw, 72px); }
  .totals-note { padding: 0; }
  .stats-strip { display: block; }
  .stat-intro { min-height: 42px; padding: 0 2px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat { min-height: 86px; padding: 14px 11px; }
  .group-launcher { border-left: 0; }
  .group-launcher-action { display: block; }
  .toolbar { align-items: stretch; flex-direction: column; gap: 20px; padding: 37px 0 28px; }
  .search-wrap { max-width: none; }
  .group-tabs { justify-content: start; gap: 4px; }
  .tab { padding: 0 9px; }
  .section-heading h2 { font-size: 27px; }
  .records-grid { grid-template-columns: repeat(2, 1fr); gap: 7px; padding-top: 12px; }
  .record-card { min-height: 190px; }
  .card-top { padding: 12px 11px 9px; }
  .card-body { padding: 12px 11px; }
  .card-bottom { padding: 9px 11px; }
  .card-child { font-size: 16px; }
  .card-detail { font-size: 10px; }
  .footer { width: calc(100% - 32px); }
  .field-row { grid-template-columns: 1fr; gap: 17px; }
  .record-dialog { width: calc(100% - 24px); max-height: calc(100dvh - 24px); }
  .record-dialog form { max-height: calc(100dvh - 24px); padding: 24px 19px; }
  .dialog-actions { position: sticky; bottom: 0; margin-inline: -19px; padding: 15px 19px calc(15px + env(safe-area-inset-bottom)); background: var(--white); }
  .toast-region { left: 16px; right: 16px; bottom: 16px; }
  .toast { max-width: none; }
}
@media (max-width: 350px) {
  .stats-grid { grid-template-columns: 1fr; }
  .records-grid { grid-template-columns: 1fr; }
  .record-card { min-height: 160px; }
  .topbar-actions { gap: 4px; }
  .user-badge { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
