:root {
    --bg: #eef3f6;
    --bg-accent: #dce7ea;
    --surface: rgba(255, 255, 255, 0.92);
    --surface-strong: #ffffff;
    --surface-soft: #f7fafb;
    --text: #0f172a;
    --text-soft: #486071;
    --border: #d7e3e8;
    --border-strong: #bfd0d7;
    --brand: #0f6a5b;
    --brand-dark: #0a4a40;
    --brand-soft: #e6f4f1;
    --brand-soft-2: #edf8f6;
    --accent: #0f4c81;
    --accent-soft: #eaf1f9;
    --success: #166534;
    --success-bg: #e9f8ee;
    --warning: #8a6a05;
    --warning-bg: #fff7d6;
    --error: #8d1e24;
    --error-bg: #fdebec;
    --shadow: 0 18px 44px rgba(15, 23, 42, 0.08);
    --shadow-soft: 0 8px 22px rgba(15, 23, 42, 0.06);
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 12px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: Inter, Arial, Helvetica, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(15, 106, 91, 0.10), transparent 28%),
        radial-gradient(circle at top right, rgba(15, 76, 129, 0.10), transparent 26%),
        linear-gradient(180deg, #f4f8fa 0%, var(--bg) 58%, #eaf0f4 100%);
}

a { color: inherit; }
code, pre {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.page {
    max-width: 1360px;
    margin: 0 auto;
    padding: 24px;
}

.page.narrow {
    max-width: 1040px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    margin-bottom: 18px;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(14px);
    border: 1px solid rgba(215, 227, 232, 0.8);
    border-radius: 999px;
    box-shadow: var(--shadow-soft);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 12px 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.brand-logo-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: linear-gradient(180deg, #ffffff 0%, #eef6f4 100%);
    border: 1px solid rgba(15, 106, 91, 0.12);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.6);
    overflow: hidden;
    flex: 0 0 auto;
}

.brand-logo-wrap img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand-copy {
    min-width: 0;
}

.brand-kicker,
.eyebrow,
.overline {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: .12em;
    font-size: .76rem;
    color: var(--text-soft);
}

.brand-title {
    margin: 2px 0 0;
    font-size: 1rem;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.topbar-inline {
    margin: 0;
}

.hero {
    position: relative;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1.8fr) minmax(320px, 1fr);
    gap: 24px;
    padding: 30px;
    margin-bottom: 22px;
    border: 1px solid rgba(255,255,255,0.45);
    border-radius: 32px;
    background:
        linear-gradient(135deg, rgba(10, 74, 64, 0.96), rgba(15, 106, 91, 0.94) 46%, rgba(15, 76, 129, 0.94));
    box-shadow: 0 28px 70px rgba(15, 74, 64, 0.22);
    color: #fff;
}

.hero::before,
.hero::after {
    content: "";
    position: absolute;
    border-radius: 999px;
    background: rgba(255,255,255,.08);
}

.hero::before {
    width: 280px;
    height: 280px;
    right: -60px;
    top: -110px;
}

.hero::after {
    width: 180px;
    height: 180px;
    right: 220px;
    bottom: -90px;
}

.hero-content,
.hero-side {
    position: relative;
    z-index: 1;
}

.hero h1 {
    margin: 12px 0 14px;
    font-size: clamp(2rem, 3.1vw, 3rem);
    line-height: 1.08;
    letter-spacing: -0.02em;
}

.subtitle {
    margin: 0;
    max-width: 900px;
    color: rgba(255,255,255,.92);
    font-size: 1rem;
    line-height: 1.6;
}

.hero-points {
    margin: 22px 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.hero-points li {
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.12);
    font-weight: 600;
}

.hero-side {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.hero-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.meta-card,
.card,
.glass-card {
    background: var(--surface);
    border: 1px solid rgba(255,255,255,0.45);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
}

.meta-card {
    padding: 18px;
    color: var(--text);
}

.meta-card strong {
    display: block;
    font-size: 1.45rem;
    margin-top: 8px;
}

.meta-card .meta-label {
    display: block;
    color: var(--text-soft);
    font-size: .84rem;
}

.info-card {
    padding: 18px 20px;
    border-radius: 20px;
    background: rgba(255,255,255,.14);
    border: 1px solid rgba(255,255,255,.16);
    color: rgba(255,255,255,.95);
}

.info-card p {
    margin: 8px 0 0;
    font-size: .96rem;
    line-height: 1.55;
    color: rgba(255,255,255,.92);
}

.status-grid,
.stat-grid,
.grid {
    display: grid;
    gap: 20px;
    margin-bottom: 20px;
}

.status-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card {
    padding: 22px;
}

.card h1,
.card h2,
.card h3 {
    margin: 0 0 8px;
    letter-spacing: -0.02em;
}

.card p,
.card li,
.card dd,
.card dt,
.card th,
.card td {
    line-height: 1.55;
}

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.card-head p {
    margin: 6px 0 0;
    color: var(--text-soft);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 18px 0 0;
}

.btn,
.link-btn,
.ghost-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 18px;
    border-radius: 14px;
    font-weight: 800;
    text-decoration: none;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
}

.btn {
    border: none;
    cursor: pointer;
}

.btn-primary {
    color: #fff;
    background: linear-gradient(180deg, var(--brand) 0%, var(--brand-dark) 100%);
    box-shadow: 0 12px 24px rgba(10, 74, 64, 0.22);
}

.btn-primary:hover,
.link-btn:hover,
.ghost-link:hover {
    transform: translateY(-1px);
}

.btn-secondary,
.link-btn {
    color: var(--brand-dark);
    background: linear-gradient(180deg, #ffffff 0%, #edf5f3 100%);
    border: 1px solid rgba(15, 106, 91, 0.16);
    box-shadow: 0 8px 18px rgba(15, 106, 91, 0.08);
}

.btn-outline,
.ghost-link {
    color: var(--accent);
    background: rgba(255,255,255,.5);
    border: 1px solid rgba(15, 76, 129, 0.16);
}

.ghost-danger {
    color: var(--error);
    background: rgba(253, 235, 236, 0.9);
    border: 1px solid rgba(141, 30, 36, 0.18);
}

.ghost-danger:hover {
    background: rgba(253, 235, 236, 1);
}

button:disabled {
    opacity: .42;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.alert {
    border-radius: 16px;
    padding: 16px 18px;
    margin-bottom: 18px;
    border: 1px solid transparent;
    box-shadow: var(--shadow-soft);
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border-color: #b6e3c2;
}

.alert-error {
    background: var(--error-bg);
    color: var(--error);
    border-color: #f2c5c8;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: .84rem;
    font-weight: 800;
}

.badge::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    opacity: .75;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-pending {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-error {
    background: var(--error-bg);
    color: var(--error);
}

.kpi-card {
    padding: 20px;
    background: var(--surface-strong);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow-soft);
}

.kpi-label {
    display: block;
    color: var(--text-soft);
    font-size: .84rem;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.kpi-value {
    display: block;
    margin-top: 10px;
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: -0.03em;
}

.kpi-helper {
    display: block;
    margin-top: 8px;
    color: var(--text-soft);
    font-size: .94rem;
}

.flow-list {
    display: grid;
    gap: 14px;
    padding: 0;
    margin: 0;
    list-style: none;
}

.flow-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 14px;
    align-items: center;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, #ffffff 0%, #f8fbfc 100%);
}

.flow-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-weight: 900;
}

.flow-content strong {
    display: block;
    margin-bottom: 2px;
}

.flow-content span,
.note,
.empty,
.footer,
.receipt-item p,
.back-link,
.definition-list dt,
.card-copy,
.muted {
    color: var(--text-soft);
}

.note {
    margin: 14px 0 0;
    font-size: .95rem;
}

.empty-state {
    padding: 18px;
    border-radius: 18px;
    border: 1px dashed var(--border-strong);
    background: linear-gradient(180deg, #ffffff 0%, #f8fbfc 100%);
}

.empty {
    margin: 0;
}

.result-table-wrap,
.definition-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 540px;
}

thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f2f7f8;
    color: #204458;
    font-size: .84rem;
    text-transform: uppercase;
    letter-spacing: .06em;
}

th, td {
    padding: 14px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

tbody tr:hover {
    background: #f7fbfc;
}

.number-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 46px;
    min-height: 36px;
    padding: 0 10px;
    border-radius: 12px;
    font-weight: 900;
    color: var(--brand-dark);
    background: var(--brand-soft);
    border: 1px solid rgba(15, 106, 91, 0.14);
}

.province-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.province-list.compact {
    grid-template-columns: 1fr;
}

.province-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #f6fafb 100%);
    border-radius: 16px;
    border: 1px solid var(--border);
}

.province-list strong {
    flex: 0 0 auto;
}

.province-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.receipt-list {
    display: grid;
    gap: 14px;
}

.receipt-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbfc 100%);
}

.receipt-item strong {
    display: block;
    margin-bottom: 4px;
}

.receipt-item p {
    margin: 0;
    font-size: .95rem;
}

.receipt-links {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.definition-list {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 12px 18px;
    margin: 0;
}

.definition-list dt,
.definition-list dd {
    margin: 0;
    padding-bottom: 12px;
    border-bottom: 1px dashed var(--border);
}

.definition-list dd {
    word-break: break-word;
}

.audit-panel {
    display: grid;
    grid-template-columns: 1.1fr .9fr;
    gap: 20px;
}

.mini-list {
    margin: 0;
    padding-left: 18px;
    color: var(--text-soft);
}

.mini-list li + li {
    margin-top: 8px;
}

.footer {
    margin-top: 12px;
    padding: 18px 22px;
    border-radius: 20px;
    background: rgba(255,255,255,.72);
    border: 1px solid rgba(215, 227, 232, 0.9);
    box-shadow: var(--shadow-soft);
    font-size: .95rem;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    text-decoration: none;
    font-weight: 700;
}

pre.code-block {
    margin: 0;
    padding: 16px;
    border-radius: 16px;
    background: #0f172a;
    color: #eef2ff;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.logo-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 124px;
    padding: 18px;
    border-radius: 20px;
    background: rgba(255,255,255,.14);
    border: 1px solid rgba(255,255,255,.16);
}

.logo-panel img {
    width: min(100%, 420px);
    max-height: 88px;
    object-fit: contain;
    filter: drop-shadow(0 8px 20px rgba(0,0,0,.10));
}

@media (max-width: 1180px) {
    .hero,
    .grid.two,
    .grid.three,
    .audit-panel,
    .status-grid,
    .stat-grid {
        grid-template-columns: 1fr;
    }

    .hero-points,
    .hero-meta {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 900px) {
    .page {
        padding: 16px;
    }

    .topbar {
        border-radius: 22px;
    }

    .topbar-inner,
    .card-head,
    .receipt-item,
    .definition-list,
    .brand,
    .hero {
        display: grid;
        grid-template-columns: 1fr;
    }

    .topbar-actions,
    .receipt-links {
        justify-content: flex-start;
    }

    .brand-logo-wrap {
        width: 58px;
        height: 58px;
    }

    .hero {
        padding: 22px;
        border-radius: 26px;
    }

    .hero-points,
    .hero-meta,
    .province-list,
    .definition-list {
        grid-template-columns: 1fr;
    }

    .flow-item {
        grid-template-columns: auto 1fr;
    }

    .flow-item .badge {
        grid-column: 1 / -1;
        justify-self: flex-start;
    }

    table {
        min-width: 520px;
    }
}
