:root {
  --ink: #17324d;
  --muted: #64778b;
  --line: #dfe8ef;
  --surface: #ffffff;
  --canvas: #f4f8fa;
  --teal: #0f9f8f;
  --teal-dark: #087d72;
  --teal-soft: #dff7f2;
  --blue: #3978d4;
  --blue-soft: #e9f1ff;
  --coral: #ef786a;
  --coral-soft: #fff0ed;
  --violet: #7966cf;
  --violet-soft: #f0edff;
  --danger: #c93f52;
  --danger-soft: #fff0f2;
  --shadow-sm: 0 5px 18px rgba(23, 50, 77, 0.07);
  --shadow-lg: 0 24px 70px rgba(23, 50, 77, 0.17);
  --radius-sm: 12px;
  --radius: 20px;
  --radius-lg: 28px;
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 2% 0%, rgba(15, 159, 143, 0.1), transparent 26rem),
    radial-gradient(circle at 98% 12%, rgba(57, 120, 212, 0.08), transparent 24rem),
    var(--canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

button, input, select { font: inherit; }
a { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .65rem; font-size: clamp(2rem, 4vw, 3.3rem); line-height: 1.06; letter-spacing: -.045em; }
h2 { margin-bottom: .4rem; font-size: clamp(1.35rem, 2vw, 1.8rem); letter-spacing: -.025em; }
h3 { margin-bottom: .35rem; }
p { color: var(--muted); }

.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 100; padding: .8rem 1rem; border-radius: 10px; color: #fff; background: var(--ink); }
.skip-link:focus { top: 1rem; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.site-header { position: sticky; top: 0; z-index: 30; border-bottom: 1px solid rgba(209, 222, 232, .8); background: rgba(255, 255, 255, .88); backdrop-filter: blur(18px); }
.nav-shell { width: min(1180px, calc(100% - 2rem)); margin-inline: auto; }
.site-header .nav-shell { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; }
.brand { display: inline-flex; align-items: center; gap: .7rem; text-decoration: none; }
.brand-mark { display: grid; place-items: center; flex: 0 0 auto; width: 60px; height: 60px; filter: drop-shadow(0 7px 10px rgba(15, 86, 98, .16)); }
.brand-logo { display: block; width: 60px; height: 60px; object-fit: contain; object-position: center; }
.brand strong { display: block; letter-spacing: .03em; }
.brand small { display: block; color: var(--muted); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; }
nav { display: flex; align-items: center; gap: .35rem; }
nav a, .nav-link-button { border: 0; border-radius: 10px; padding: .62rem .82rem; color: #4d6379; background: transparent; text-decoration: none; cursor: pointer; }
nav a:hover, .nav-link-button:hover { color: var(--teal-dark); background: var(--teal-soft); }
.nav-cta { color: #fff !important; background: var(--ink) !important; }
.nav-form { margin: 0; }

.page-shell { width: min(1180px, calc(100% - 2rem)); margin: 0 auto; padding: 2.5rem 0 4rem; }
.narrow-shell { width: min(720px, calc(100% - 2rem)); }
.hero { position: relative; isolation: isolate; display: flex; align-items: center; justify-content: space-between; gap: 2rem; overflow: hidden; margin-bottom: 1.4rem; padding: clamp(2rem, 6vw, 4.2rem); border-radius: var(--radius-lg); color: #fff; background: linear-gradient(120deg, #17324d 0%, #1f5264 54%, #108f83 110%); box-shadow: var(--shadow-lg); }
.hero::after { content: ""; position: absolute; z-index: -1; width: 360px; height: 360px; right: -100px; top: -180px; border: 60px solid rgba(255, 255, 255, .06); border-radius: 50%; }
.hero h1, .hero p, .hero .eyebrow { color: #fff; }
.hero p { max-width: 680px; margin-bottom: 0; color: rgba(255, 255, 255, .78); font-size: 1.04rem; }
.compact-hero { min-height: 260px; }
.admin-hero { background: linear-gradient(120deg, #232f49, #3d4770 60%, #765ec1); }
.eyebrow { display: inline-block; margin-bottom: .55rem; color: var(--teal-dark); font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.page-intro { display: flex; justify-content: space-between; align-items: flex-end; gap: 2rem; margin-bottom: 1.5rem; }
.page-intro p { margin-bottom: 0; }
.detail-intro { align-items: center; }
.secure-note { display: inline-flex; align-items: center; gap: .4rem; padding: .65rem 1rem; border-radius: 999px; color: var(--teal-dark); background: var(--teal-soft); font-weight: 700; white-space: nowrap; }
.secure-note::before { content: "✓"; }

.card { border: 1px solid rgba(216, 228, 236, .9); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.4rem; }
.stat-card { position: relative; overflow: hidden; min-height: 132px; padding: 1.35rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow-sm); }
.stat-card::after { content: ""; position: absolute; width: 82px; height: 82px; right: -22px; bottom: -30px; border-radius: 50%; background: currentColor; opacity: .1; }
.stat-card span { display: block; margin-bottom: .7rem; color: var(--muted); font-size: .82rem; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
.stat-card strong { font-size: 2.4rem; line-height: 1; }
.stat-card.teal { color: var(--teal); } .stat-card.blue { color: var(--blue); } .stat-card.coral { color: var(--coral); } .stat-card.violet { color: var(--violet); }
.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.card-heading h2 { margin-bottom: 0; }
.result-count { padding: .35rem .7rem; border-radius: 999px; color: var(--blue); background: var(--blue-soft); font-size: .78rem; font-weight: 800; }
.records-card { padding: clamp(1rem, 3vw, 1.6rem); }

.filter-panel { display: grid; grid-template-columns: minmax(220px, 1.8fr) repeat(5, minmax(115px, 1fr)); gap: .75rem; align-items: end; margin-bottom: 1.2rem; padding: 1rem; border-radius: 16px; background: #f7fafc; }
.filter-panel label { min-width: 0; }
.filter-panel label > span:not(.sr-only) { display: block; margin-bottom: .3rem; color: var(--muted); font-size: .72rem; font-weight: 800; text-transform: uppercase; }
.filter-actions { display: flex; gap: .5rem; grid-column: 1 / -1; justify-content: flex-end; }
input, select { width: 100%; border: 1px solid #cddbe5; border-radius: 11px; padding: .76rem .86rem; color: var(--ink); background: #fff; outline: none; transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease; }
input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(15, 159, 143, .12); }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); background: #fffafb; }

.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 15px; }
.data-table { width: 100%; border-collapse: collapse; min-width: 860px; }
.data-table th { padding: .82rem .9rem; color: #536a7f; background: #f1f6f8; font-size: .72rem; text-align: left; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.data-table td { padding: .9rem; border-top: 1px solid var(--line); color: #425b70; vertical-align: middle; }
.data-table tbody tr { transition: background .15s ease; }
.data-table tbody tr:hover { background: #f9fcfd; }
.data-table td strong { display: block; color: var(--ink); }
.data-table td small { display: block; margin-top: .12rem; color: var(--muted); }
.actions-column { text-align: right !important; }
.table-actions { display: flex; justify-content: flex-end; gap: .35rem; flex-wrap: wrap; }
.inline-form { display: inline-flex; margin: 0; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; min-height: 34px; border: 1px solid var(--line); border-radius: 9px; padding: .35rem .58rem; color: #536a7f; background: #fff; text-decoration: none; cursor: pointer; font-size: .78rem; font-weight: 750; }
.icon-button:hover { color: var(--ink); border-color: #b7c9d6; background: #f4f8fa; }
.icon-button.accent { color: var(--teal-dark); border-color: #bce5dd; background: var(--teal-soft); }
.icon-button.danger { color: var(--danger); border-color: #f1c8cf; background: var(--danger-soft); }
.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .28rem .62rem; border-radius: 999px; font-size: .72rem; font-weight: 800; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.locked { color: var(--teal-dark); background: var(--teal-soft); }
.badge.archived { color: #6e628f; background: var(--violet-soft); }

.button { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 44px; border: 1px solid transparent; border-radius: 12px; padding: .72rem 1.08rem; text-decoration: none; font-weight: 780; cursor: pointer; transition: transform .16s ease, box-shadow .16s ease, opacity .16s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: #fff; background: linear-gradient(135deg, var(--teal), #168f9a); box-shadow: 0 9px 20px rgba(15, 159, 143, .22); }
.button.secondary { color: var(--ink); border-color: #cad9e3; background: #fff; }
.button.ghost { color: var(--muted); background: transparent; }
.button.danger-button { color: #fff; background: var(--danger); }
.button.small { min-height: 38px; padding: .55rem .82rem; font-size: .82rem; }
.button.full { width: 100%; }
.button:disabled { cursor: wait; opacity: .72; transform: none; }
.button.is-loading::before { content: ""; width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, .45); border-top-color: currentColor; border-radius: 50%; animation: spin .7s linear infinite; }
.button-row { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; }
@keyframes spin { to { transform: rotate(360deg); } }

.record-form { display: grid; gap: 1.2rem; }
.form-section { padding: clamp(1.2rem, 4vw, 2rem); }
.section-heading { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: 1.4rem; }
.section-heading p { margin-bottom: 0; }
.section-number { flex: 0 0 auto; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; color: var(--teal-dark); background: var(--teal-soft); font-weight: 850; }
.form-grid { display: grid; gap: 1rem; }
.three-columns { grid-template-columns: repeat(3, 1fr); }
.two-columns { grid-template-columns: repeat(2, 1fr); }
label { color: #314b62; font-size: .88rem; font-weight: 720; }
label > input, label > select { display: block; margin-top: .38rem; font-weight: 500; }
label > span[aria-hidden="true"] { margin-left: .2rem; color: var(--coral); }
label small { display: block; margin-top: .35rem; color: var(--muted); font-weight: 500; }
.field-error { color: var(--danger) !important; }
.indicator-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; }
.indicator-field { display: grid; grid-template-columns: 34px 1fr 110px; align-items: center; gap: .75rem; min-height: 76px; padding: .75rem; border: 1px solid var(--line); border-radius: 14px; background: #fbfdfe; }
.indicator-field input { margin-top: 0; text-align: right; }
.indicator-index { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; color: var(--blue); background: var(--blue-soft); font-size: .72rem; font-weight: 850; }
.indicator-field .field-error { grid-column: 2 / -1; }
.security-section { border-color: #bde6df; background: linear-gradient(135deg, #fff, #f2fbf9); }
.form-actions { display: flex; justify-content: flex-end; gap: .7rem; align-items: center; }
.stacked-form { display: grid; gap: 1rem; }

.detail-grid { display: grid; grid-template-columns: 310px 1fr; gap: 1.2rem; align-items: start; }
.metadata-card, .indicators-card { padding: 1.5rem; }
.metadata-card { position: sticky; top: 95px; }
dl { margin: 1rem 0 0; }
dl div { padding: .8rem 0; border-top: 1px solid var(--line); }
dt { color: var(--muted); font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
dd { margin: .22rem 0 0; color: var(--ink); font-weight: 700; }
.indicator-list { list-style: none; margin: 0; padding: 0; counter-reset: indicator; }
.indicator-list li { counter-increment: indicator; display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: .8rem; padding: .78rem .2rem; border-top: 1px solid var(--line); }
.indicator-list li::before { content: counter(indicator, decimal-leading-zero); display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; color: var(--blue); background: var(--blue-soft); font-size: .7rem; font-weight: 850; }
.indicator-list strong { min-width: 70px; text-align: right; font-size: 1.05rem; }

.modal { width: min(460px, calc(100% - 2rem)); max-width: none; padding: 0; border: 0; border-radius: var(--radius); color: var(--ink); background: transparent; box-shadow: var(--shadow-lg); }
.modal::backdrop { background: rgba(10, 28, 44, .58); backdrop-filter: blur(5px); }
.modal-card { position: relative; display: grid; gap: .8rem; margin: 0; padding: 2rem; border: 1px solid rgba(255, 255, 255, .7); border-radius: var(--radius); background: #fff; }
.modal-card h2, .modal-card p { margin-bottom: 0; }
.modal-close { position: absolute; top: .8rem; right: .8rem; width: 34px; height: 34px; border: 0; border-radius: 9px; color: var(--muted); background: #f1f5f7; cursor: pointer; font-size: 1.25rem; }
.status-icon { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: .2rem; border-radius: 14px; color: var(--teal-dark); background: var(--teal-soft); font-size: 1.4rem; font-weight: 850; }
.status-icon.danger { color: var(--danger); background: var(--danger-soft); }
.status-icon.download { color: var(--blue); background: var(--blue-soft); }

.auth-shell { width: min(1080px, calc(100% - 2rem)); min-height: calc(100vh - 150px); margin: 0 auto; display: grid; grid-template-columns: 1.15fr .85fr; align-items: center; gap: clamp(2rem, 7vw, 6rem); padding: 4rem 0; }
.auth-visual { padding: 3rem; border-radius: var(--radius-lg); color: #fff; background: linear-gradient(145deg, #17324d, #1a6270 70%, #0f9f8f); box-shadow: var(--shadow-lg); }
.auth-visual .eyebrow, .auth-visual h1 { color: #fff; }
.auth-visual p { color: rgba(255,255,255,.76); font-size: 1.08rem; }
.security-points { display: flex; gap: .55rem; flex-wrap: wrap; margin-top: 2rem; }
.security-points span { padding: .45rem .7rem; border: 1px solid rgba(255,255,255,.18); border-radius: 999px; color: rgba(255,255,255,.9); background: rgba(255,255,255,.08); font-size: .78rem; }
.auth-card { padding: 2rem; }
.auth-card > p { margin-bottom: 1.4rem; }
.text-link { display: inline-block; margin-top: 1.2rem; color: var(--teal-dark); text-decoration: none; font-weight: 720; }

.setup-card, .export-card { padding: clamp(1.5rem, 5vw, 2.5rem); }
.installer-page { width: min(980px, calc(100% - 2rem)); }
.installer-intro { display: grid; grid-template-columns: minmax(0, 1fr) 310px; align-items: center; gap: 1.5rem; margin-bottom: 1.5rem; padding: clamp(1rem, 4vw, 2.2rem) 0; }
.installer-intro h1 { max-width: 720px; }
.installer-intro p { max-width: 720px; margin-bottom: 0; font-size: 1.03rem; }
.requirement-card { padding: 1.25rem; }
.requirement-card h2 { font-size: 1.05rem; }
.requirement-list { display: grid; gap: .55rem; margin: 1rem 0 0; padding: 0; list-style: none; }
.requirement-list li { display: flex; align-items: center; gap: .6rem; color: var(--muted); font-size: .84rem; font-weight: 700; }
.requirement-list li span { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 8px; }
.requirement-list .passed span { color: var(--teal-dark); background: var(--teal-soft); }
.requirement-list .failed { color: var(--danger); }
.requirement-list .failed span { color: var(--danger); background: var(--danger-soft); }
.installer-form { display: grid; gap: 1rem; }
.install-mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.install-mode-card { position: relative; display: block; cursor: pointer; }
.install-mode-card input { position: absolute; width: 1px; height: 1px; margin: -1px; opacity: 0; }
.install-mode-card > span { display: block; height: 100%; min-height: 118px; padding: 1rem; border: 1px solid var(--line); border-radius: 14px; background: #fbfdfe; transition: border-color .18s ease, box-shadow .18s ease, background .18s ease; }
.install-mode-card strong, .install-mode-card small { display: block; }
.install-mode-card strong { margin-bottom: .35rem; color: var(--ink); }
.install-mode-card small { color: var(--muted); font-weight: 500; }
.install-mode-card input:checked + span { border-color: var(--teal); background: var(--teal-soft); box-shadow: 0 0 0 3px rgba(15, 159, 143, .1); }
.install-mode-card input:focus-visible + span { outline: 3px solid rgba(57, 120, 212, .28); outline-offset: 2px; }
.full-column { grid-column: 1 / -1; }
.create-database-option { display: grid; grid-template-columns: 22px 1fr; column-gap: .65rem; align-items: center; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: #f8fbfc; }
.create-database-option input { grid-row: 1 / span 2; width: 18px; height: 18px; margin: 0; accent-color: var(--teal); }
.create-database-option span, .create-database-option small { margin: 0; }
.installer-submit { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; padding: 1.2rem 1.4rem; border-color: #bde6df; }
.installer-submit p { margin: .15rem 0 0; font-size: .82rem; }
.installer-success { max-width: 700px; margin: 3rem auto; text-align: center; }
.installer-success .status-icon { width: 60px; height: 60px; margin: 0 auto 1rem; font-size: 1.8rem; }
.installer-success .button-row { justify-content: center; }
.export-features { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; margin: 1.4rem 0; }
.export-features span { padding: .7rem; border-radius: 10px; color: #425b70; background: #f3f7f9; font-size: .82rem; font-weight: 700; }
.export-features span::before { content: "✓"; margin-right: .45rem; color: var(--teal); }
.alert { margin-bottom: 1rem; padding: .8rem 1rem; border-radius: 12px; font-weight: 650; }
.alert.danger { color: #9d2d3d; border: 1px solid #f3cbd1; background: var(--danger-soft); }
.empty-state { padding: 3rem 1rem; text-align: center; }
.empty-state .status-icon { margin-inline: auto; }
.empty-state p { margin-bottom: 0; }

.toast-region { position: fixed; z-index: 80; top: 88px; right: 1rem; display: grid; gap: .6rem; width: min(390px, calc(100% - 2rem)); }
.toast { display: flex; align-items: center; gap: .75rem; padding: .85rem 1rem; border: 1px solid #c9e8e2; border-radius: 13px; color: #126d64; background: #f3fffc; box-shadow: var(--shadow-lg); animation: toast-in .25s ease both; font-weight: 680; }
.toast.error { color: #9d2d3d; border-color: #f3cbd1; background: #fff7f8; }
.toast button { margin-left: auto; border: 0; color: inherit; background: transparent; cursor: pointer; font-size: 1.2rem; }
.toast-leaving { animation: toast-out .22s ease both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }

.site-footer { border-top: 1px solid var(--line); background: rgba(255,255,255,.65); }
.footer-inner { min-height: 76px; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.footer-inner p { margin: 0; font-size: .82rem; }

@media (max-width: 1000px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-panel { grid-template-columns: repeat(3, 1fr); }
  .search-field { grid-column: span 3; }
  .indicator-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .metadata-card { position: static; }
}

@media (max-width: 720px) {
  body { font-size: 14px; }
  .site-header .nav-shell { min-height: 68px; }
  .brand-mark, .brand-logo { width: 46px; height: 46px; }
  .brand small { display: none; }
  nav { gap: .1rem; }
  nav a, .nav-link-button { padding: .5rem .55rem; font-size: .8rem; }
  .page-shell { padding-top: 1.5rem; }
  .hero { display: block; padding: 2rem 1.4rem; }
  .hero .button { margin-top: 1.2rem; }
  .page-intro { display: block; }
  .page-intro > :last-child { margin-top: 1rem; }
  .stats-grid { gap: .7rem; }
  .stat-card { min-height: 108px; padding: 1rem; }
  .stat-card strong { font-size: 2rem; }
  .filter-panel { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .filter-actions { justify-content: stretch; }
  .filter-actions .button { flex: 1; }
  .three-columns, .two-columns { grid-template-columns: 1fr; }
  .indicator-field { grid-template-columns: 30px 1fr; }
  .indicator-field input { grid-column: 1 / -1; }
  .form-actions { flex-direction: column-reverse; align-items: stretch; }
  .auth-shell { min-height: auto; grid-template-columns: 1fr; gap: 1rem; padding: 1.5rem 0 3rem; }
  .auth-visual { padding: 2rem 1.4rem; }
  .installer-intro { grid-template-columns: 1fr; padding-top: .5rem; }
  .install-mode-grid { grid-template-columns: 1fr; }
  .install-mode-card > span { min-height: 0; }
  .installer-submit { align-items: stretch; flex-direction: column; }
  .footer-inner { flex-direction: column; justify-content: center; gap: .15rem; text-align: center; }
}

@media (max-width: 460px) {
  .nav-cta { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .filter-panel { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
  .card-heading { align-items: flex-start; }
  .indicator-field { padding: .7rem; }
  .modal-card { padding: 1.5rem; }
  .export-features { grid-template-columns: 1fr; }
}

@media print {
  .site-header, .site-footer, .button-row, .toast-region, .modal { display: none !important; }
  body { background: #fff; }
  .page-shell { width: 100%; padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
  .detail-grid { grid-template-columns: 1fr; }
  .metadata-card { position: static; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
