:root {
    --bg: #0b1220;
    --bg-soft: #0f1a2e;
    --surface: #ffffff;
    --ink: #0f172a;
    --ink-soft: #475569;
    --line: #e2e8f0;
    --brand: #0e7490;
    --brand-deep: #155e75;
    --brand-light: #ecfeff;
    --accent: #0891b2;
    --danger: #dc2626;
    --warn: #b45309;
    --ok: #15803d;
    --shadow: 0 10px 30px rgba(2, 13, 35, .12);
    --radius: 14px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
    background: #f1f5f9;
    line-height: 1.55;
}

.container { width: min(1140px, 92%); margin: 0 auto; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Navbar ---------- */
.navbar {
    position: sticky; top: 0; z-index: 50;
    background: rgba(11, 18, 32, .9);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-badge {
    background: var(--accent); color: #fff; font-size: 13px; font-weight: 800;
    padding: 4px 9px; border-radius: 8px; letter-spacing: .5px;
}
.brand-text { font-size: 16px; letter-spacing: .3px; }
.nav-links { display: flex; align-items: center; gap: 22px; margin-left: auto; order: 2; }
.nav-links a { color: #cbd5e1; font-size: 14.5px; font-weight: 500; }
.nav-links a:hover { color: #fff; text-decoration: none; }
.nav-right { display: flex; align-items: center; gap: 12px; order: 3; }
.nav-toggle {
    display: none; flex-direction: column; justify-content: center; gap: 4px;
    width: 40px; height: 36px; padding: 0 9px; cursor: pointer;
    background: transparent; border: 1px solid rgba(148, 163, 184, .5); border-radius: 8px;
}
.nav-toggle span { display: block; height: 2px; width: 100%; background: #e2e8f0; border-radius: 2px; transition: .2s; }
.nav-toggle.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
.lang-switch { display: inline-flex; border: 1px solid rgba(148, 163, 184, .5); border-radius: 8px; overflow: hidden; }
.lang-btn {
    background: transparent; color: #cbd5e1; border: none; cursor: pointer;
    font-size: 12.5px; font-weight: 700; letter-spacing: .5px; padding: 6px 11px; transition: .15s;
}
.lang-btn:hover { color: #fff; background: rgba(148, 163, 184, .18); }
.lang-btn.active { background: var(--accent); color: #fff; }

/* ---------- Hero ---------- */
.hero {
    background: radial-gradient(1200px 500px at 80% -10%, #155e75 0%, transparent 60%),
                linear-gradient(160deg, #0b1220 0%, #0f1a2e 60%, #102a3a 100%);
    color: #e2e8f0; padding: 36px 0 84px;
}
.logo-strip {
    display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
    padding-bottom: 28px; margin-bottom: 34px; border-bottom: 1px solid rgba(148, 163, 184, .22);
}
.logo-strip a { display: inline-flex; line-height: 0; transition: transform .15s; }
.logo-strip a:hover { transform: translateY(-2px); }
.logo-strip-img {
    width: 64px; height: 64px; object-fit: contain; display: block;
    background: #fff; border-radius: 10px; padding: 8px; box-sizing: border-box;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
}
@media (max-width: 600px) {
    .logo-strip { gap: 14px; justify-content: center; }
    .logo-strip-img { width: 52px; height: 52px; }
}
.hero-inner { display: grid; grid-template-columns: 1.4fr 1fr; gap: 48px; align-items: center; }
.eyebrow { color: #67e8f9; font-weight: 700; letter-spacing: 1.5px; font-size: 12.5px; text-transform: uppercase; margin: 0 0 14px; }
.hero h1 { font-size: clamp(28px, 4vw, 44px); line-height: 1.12; margin: 0 0 18px; color: #fff; letter-spacing: -.5px; }
.hero-sub { font-size: 17px; color: #cbd5e1; max-width: 60ch; margin: 0 0 28px; }
.hero-sub em { color: #a5f3fc; font-style: italic; }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 34px; }
.hero-meta { display: grid; gap: 14px; }
.hero-meta div { display: grid; gap: 2px; }
.hero-meta strong { color: #67e8f9; font-size: 12px; text-transform: uppercase; letter-spacing: .8px; }
.hero-meta span { color: #94a3b8; font-size: 14px; }

.hero-card {
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(103, 232, 249, .25);
    border-radius: 18px; padding: 28px; backdrop-filter: blur(6px);
}
.hero-card-title { color: #67e8f9; font-weight: 700; font-size: 14px; margin-bottom: 12px; }
.hero-card p { color: #cbd5e1; font-size: 14.5px; margin: 0 0 22px; }
.hero-stats { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 12px; }
.hero-stats li { background: rgba(255, 255, 255, .05); border-radius: 12px; padding: 14px 10px; text-align: center; }
.stat-num { display: block; font-size: 26px; font-weight: 800; color: #fff; }
.stat-label { display: block; font-size: 12px; color: #94a3b8; margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px; padding: 11px 20px; border-radius: 10px; font-size: 14.5px; font-weight: 600;
    cursor: pointer; border: 1px solid transparent; transition: .15s ease; white-space: nowrap;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--brand-deep); }
.btn-ghost { background: transparent; color: inherit; border-color: rgba(148, 163, 184, .5); }
.btn-ghost:hover { background: rgba(148, 163, 184, .14); }
.btn-sm { padding: 8px 14px; font-size: 13px; }

/* ---------- Sections ---------- */
.section { padding: 64px 0; }
.section-data { background: #f8fafc; }
.section-title { font-size: 28px; margin: 0 0 8px; color: var(--ink); letter-spacing: -.4px; }
.section-desc { color: var(--ink-soft); margin: 0 0 26px; }
.section-intro {
    color: var(--ink); font-size: 15.5px; line-height: 1.65; margin: 0 0 10px; max-width: 90ch;
    padding: 14px 18px; background: var(--brand-light); border-left: 4px solid var(--accent); border-radius: 0 10px 10px 0;
}

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 8px; color: var(--brand-deep); font-size: 17px; }
.card p { margin: 0; color: var(--ink-soft); font-size: 14.5px; }

/* ---------- Methodology ---------- */
.section-method { background: var(--surface); }
.method-figure {
    margin: 0; background: #f8fafc; border: 1px solid var(--line);
    border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); text-align: center;
}
.method-figure img {
    max-width: 100%; height: auto; border-radius: 10px; background: #fff;
}
.method-figure figcaption {
    margin-top: 18px; color: var(--ink-soft); font-size: 14px; line-height: 1.6;
    max-width: 80ch; margin-left: auto; margin-right: auto; text-align: left;
}
.method-figure figcaption strong { color: var(--brand-deep); }
.method-note { display: block; margin-top: 8px; font-style: italic; color: #94a3b8; font-size: 13px; }

/* ---------- Toolbar / Filters ---------- */
.toolbar {
    display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px 20px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.field { display: grid; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .5px; }
.field input, .field select {
    padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px;
    min-width: 220px; background: #fff; color: var(--ink); outline: none; transition: .15s;
}
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(8, 145, 178, .15); }
.result-count { margin-left: auto; color: var(--ink-soft); font-size: 13.5px; font-weight: 600; }

/* ---------- Table ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.data-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 14.5px; }
.data-table th, .data-table td { overflow-wrap: anywhere; }
.data-table thead th {
    background: var(--brand-deep); color: #fff; text-align: left; padding: 14px 16px;
    font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .5px;
}
.data-table .col-no { width: 64px; text-align: center; }
.data-table .col-actions { width: 150px; text-align: center; }

.row-main { border-top: 1px solid var(--line); cursor: pointer; transition: background .12s; }
.row-main:hover { background: var(--brand-light); }
.row-main.open { background: var(--brand-light); }
.row-main td { padding: 13px 16px; vertical-align: top; }
.row-main .col-no { text-align: center; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.taxon-cell { display: flex; align-items: center; gap: 8px; }
.caret { color: var(--accent); transition: transform .18s; display: inline-block; font-size: 12px; }
.row-main.open .caret { transform: rotate(90deg); }
.taxon-name { font-weight: 600; font-style: italic; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .3px; }
.badge-priority { background: #fee2e2; color: #b91c1c; }
.badge-non { background: #e0f2fe; color: #0369a1; }
.badge-none { background: #e2e8f0; color: #475569; }

.actions-cell { text-align: center; white-space: nowrap; }
.icon-btn {
    border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 11px;
    font-size: 13px; font-weight: 600; cursor: pointer; margin: 0 2px; transition: .12s;
}
.icon-btn.edit { color: var(--brand-deep); }
.icon-btn.edit:hover { background: var(--brand-light); border-color: var(--accent); }
.icon-btn.del { color: var(--danger); }
.icon-btn.del:hover { background: #fef2f2; border-color: var(--danger); }

/* ---------- Detail (expanded row) ---------- */
.row-detail > td { padding: 0; background: #f8fafc; border-top: 0; }
.detail-inner { padding: 20px 22px 24px; border-left: 4px solid var(--accent); }
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 28px; margin-bottom: 18px; }
.detail-item { display: grid; gap: 2px; }
.detail-item.full { grid-column: 1 / -1; }
.detail-item .k { font-size: 11.5px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .6px; }
.detail-item .v { font-size: 14px; color: var(--ink); word-break: break-word; }
.detail-item .v.muted { color: #94a3b8; }
.hl-id { background: #bae6fd; color: #075985; border-radius: 4px; padding: 1px 5px; font-weight: 600; }

.detail-sub { font-size: 13px; font-weight: 700; color: var(--brand-deep); text-transform: uppercase; letter-spacing: .6px; margin: 4px 0 8px; }
.terms-table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.terms-table th, .terms-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.terms-table thead th {
    background: var(--brand-deep); color: #fff; font-size: 11px; text-transform: uppercase;
    letter-spacing: .3px; text-align: center; border-bottom: 1px solid rgba(255, 255, 255, .2);
}
.terms-table thead th.year-group { border-left: 1px solid rgba(255, 255, 255, .35); }
.terms-table thead th.sub { font-size: 10.5px; font-weight: 600; background: #1d6f86; }
.terms-table thead th.sub.last, .terms-table td.last { border-right: 1px solid var(--line); }
.terms-table tbody tr:last-child td { border-bottom: 0; }
.terms-table tbody tr.term-live td { background: #fef9c3; }
.terms-scroll { overflow-x: auto; }
.terms-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

.empty { text-align: center; padding: 40px 16px; color: var(--ink-soft); }

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(8, 15, 30, .55); backdrop-filter: blur(3px);
    display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 100; overflow-y: auto;
}
.modal-overlay[hidden] { display: none; }
.modal { background: #fff; width: min(900px, 100%); border-radius: 16px; box-shadow: 0 30px 70px rgba(2, 13, 35, .4); animation: pop .18s ease; }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 19px; color: var(--ink); }
.modal-close { background: none; border: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--ink-soft); }
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 22px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-field { display: grid; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
.form-field span { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.form-field input, .form-field select, .form-field textarea {
    padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px;
    font-family: inherit; outline: none; transition: .15s; resize: vertical;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
    border-color: var(--accent); box-shadow: 0 0 0 3px rgba(8, 145, 178, .15);
}
.modal-foot { display: flex; justify-content: flex-end; gap: 12px; padding: 18px 22px; border-top: 1px solid var(--line); margin: 22px -22px -22px; }

/* ---------- Terms editor (modal) ---------- */
.terms-editor { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 18px; }
.terms-editor-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 12px; }
.terms-editor-title { font-size: 12.5px; font-weight: 700; color: var(--brand-deep); text-transform: uppercase; letter-spacing: .6px; }
.terms-edit-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.terms-edit-table { border-collapse: collapse; font-size: 12.5px; min-width: 100%; }
.terms-edit-table th, .terms-edit-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; text-align: left; }
.terms-edit-table thead th {
    background: var(--brand-deep); color: #fff; font-size: 10px; text-transform: uppercase;
    letter-spacing: .3px; text-align: center; border-bottom: 1px solid rgba(255, 255, 255, .2);
}
.terms-edit-table thead th.year-group { border-left: 1px solid rgba(255, 255, 255, .35); }
.terms-edit-table thead th.sub { font-weight: 600; background: #1d6f86; }
.terms-edit-table thead th.sub.last, .terms-edit-table td.last { border-right: 1px solid var(--line); }
.terms-edit-table tbody tr:last-child td { border-bottom: 0; }
.terms-edit-table input {
    border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; font-size: 12.5px; font-family: inherit;
    width: 78px; outline: none; transition: .12s;
}
.terms-edit-table input.term-term { width: 130px; }
.terms-edit-table input.term-unit { width: 64px; }
.terms-edit-table input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(8, 145, 178, .15); }
.term-remove {
    border: 1px solid var(--line); background: #fff; color: var(--danger); border-radius: 6px;
    width: 26px; height: 26px; cursor: pointer; font-size: 15px; line-height: 1; padding: 0;
}
.term-remove:hover { background: #fef2f2; border-color: var(--danger); }
.terms-empty { color: var(--ink-soft); font-size: 13px; padding: 10px 8px; }

/* ---------- Toast ---------- */
.toast {
    position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: var(--ink); color: #fff; padding: 13px 22px; border-radius: 11px; font-size: 14px;
    font-weight: 600; box-shadow: var(--shadow); z-index: 200; opacity: 0; transition: .25s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: #166534; }
.toast.err { background: #b91c1c; }

/* ---------- Footer ---------- */
.footer { background: #0b1220; color: #94a3b8; padding: 28px 0; font-size: 13.5px; text-align: center; }
.footer code { color: #67e8f9; }

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
    .hero-inner { grid-template-columns: 1fr; }
    .cards { grid-template-columns: 1fr; }
    .detail-grid, .form-grid { grid-template-columns: 1fr; }
    .field input, .field select { min-width: 160px; }
    .result-count { margin-left: 0; width: 100%; }
}

/* ---------- Mobile navbar ---------- */
@media (max-width: 760px) {
    .nav-inner { height: 58px; gap: 10px; }
    .brand-badge { font-size: 12px; padding: 3px 7px; }
    .brand-text { font-size: 13.5px; }
    .nav-right { margin-left: auto; }
    .nav-toggle { display: flex; }
    .nav-links {
        order: 3; position: absolute; top: 58px; left: 0; right: 0; margin: 0;
        flex-direction: column; align-items: stretch; gap: 0;
        background: #0b1220; border-top: 1px solid rgba(255, 255, 255, .08);
        box-shadow: 0 16px 30px rgba(0, 0, 0, .35); padding: 6px 0; display: none;
    }
    .nav-links.open { display: flex; }
    .nav-links a { padding: 13px 22px; font-size: 15px; border-bottom: 1px solid rgba(255, 255, 255, .05); }
    .nav-links a:last-child { border-bottom: 0; }
}
@media (max-width: 430px) {
    .brand-text { display: none; }
}

/* ---------- Mobile table & toolbar ---------- */
@media (max-width: 560px) {
    .section { padding: 42px 0; }
    .section-title { font-size: 23px; }
    .toolbar { padding: 14px; gap: 12px; }
    .toolbar .field { width: 100%; }
    .toolbar .field input, .toolbar .field select { width: 100%; min-width: 0; }
    #btnReset { width: 100%; }
    .result-count { text-align: center; }

    .data-table { font-size: 13px; }
    .data-table thead th { padding: 11px 9px; font-size: 10.5px; }
    .row-main td { padding: 11px 9px; }
    .data-table .col-no { width: 34px; }
    .data-table .col-actions { width: 86px; }
    .col-criteria { display: none; }
    .taxon-cell { flex-wrap: wrap; gap: 6px; }
    .taxon-name { font-size: 13.5px; }
    .actions-cell { white-space: normal; }
    .icon-btn { display: block; width: 100%; margin: 3px 0; padding: 7px 6px; font-size: 12px; }

    .detail-inner { padding: 16px 14px 18px; }
    .modal-overlay { padding: 16px 10px; }
    .modal-body { padding: 16px; }
    .modal-foot { padding: 14px 16px; margin: 16px -16px -16px; }
}
