/* ------------------------------------------------------------------
   Peppol Converter
   ------------------------------------------------------------------ */

:root {
    --ink: #101014;
    --ink-2: #3f3f46;
    --muted: #71717a;
    --faint: #a1a1aa;

    --line: #e7e7ea;
    --line-soft: #f2f2f4;
    --surface: #ffffff;
    --canvas: #f7f7f8;
    --wash: #fafafa;

    --accent: #0d9488;
    --accent-strong: #0f766e;
    --accent-deep: #115e59;
    --accent-soft: #f0fdfa;
    --accent-line: #99f6e4;

    --ok: #15803d;
    --ok-wash: #dcfce7;
    --warn: #b45309;
    --warn-wash: #fef3c7;
    --bad: #b91c1c;
    --bad-wash: #fee2e2;
    --info-wash: #e0f2fe;
    --info: #075985;

    --radius: 14px;
    --radius-sm: 9px;

    /* A close contact shadow plus a wide soft one: surfaces lift off the page
       without a border, which is what removes most of the visual noise. */
    --shadow: 0 1px 2px rgba(16, 16, 20, .04), 0 10px 30px -18px rgba(16, 16, 20, .18);
    --shadow-lift: 0 2px 4px rgba(16, 16, 20, .05), 0 16px 40px -20px rgba(16, 16, 20, .28);
}

*, *::before, *::after {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--canvas);
    color: var(--ink);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

/* ---- App bar ----------------------------------------------------- */

.appbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: 60px;
    padding: 0 24px;
    background: rgba(255, 255, 255, .88);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}

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

.logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: linear-gradient(150deg, var(--accent) 0%, var(--accent-deep) 100%);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -.4px;
}

.brand-name {
    font-size: 15px;
    font-weight: 650;
    letter-spacing: -.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Segmented language control */
.lang {
    display: flex;
    gap: 2px;
    padding: 3px;
    background: var(--line-soft);
    border-radius: var(--radius-sm);
}

.lang button {
    padding: 4px 11px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .3px;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.lang button:hover {
    color: var(--ink);
}

.lang button.active {
    background: var(--surface);
    color: var(--accent-strong);
    box-shadow: var(--shadow);
}

/* ---- Layout ------------------------------------------------------ */

.wrap {
    flex: 1;
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 48px 24px 64px;
}

.page-title {
    margin: 0 0 8px;
    font-size: 28px;
    font-weight: 680;
    letter-spacing: -.7px;
    line-height: 1.2;
}

.page-sub {
    margin: 0 0 36px;
    max-width: 60ch;
    font-size: 14.5px;
    color: var(--muted);
}

.footer {
    padding: 20px 24px;
    border-top: 1px solid var(--line);
    color: var(--faint);
    text-align: center;
    font-size: 12px;
}

.footer a {
    color: var(--accent-strong);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* ---- Cards ------------------------------------------------------- */

/* No border — the shadow alone separates the card from the page. */
.card {
    margin-bottom: 20px;
    padding: 26px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card h3 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 18px;
    font-size: 11px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--faint);
}

.card-err {
    background: #fffbfb;
    border-color: #fecaca;
    border-left: 3px solid var(--bad);
}

.card-err strong {
    color: var(--bad);
}

/* ---- Upload ------------------------------------------------------ */

.dropzone {
    position: relative;
    padding: 52px 24px;
    background: var(--wash);
    border: 1.5px dashed #dcdce0;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: border-color .18s, background .18s, box-shadow .18s;
}

.dropzone:hover,
.dropzone.dragover {
    background: var(--accent-soft);
    border-color: var(--accent);
}

.dropzone.dragover {
    box-shadow: 0 0 0 4px rgba(13, 148, 136, .12);
}

.dropzone input[type=file] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.drop-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: 0 auto 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--accent-strong);
    transition: transform .18s, border-color .18s;
}

.dropzone:hover .drop-icon,
.dropzone.dragover .drop-icon {
    transform: translateY(-2px);
    border-color: var(--accent-line);
}

.drop-title {
    margin-bottom: 4px;
    font-size: 15px;
    font-weight: 620;
}

.drop-sub {
    font-size: 13px;
    color: var(--muted);
}

.drop-sub .browse {
    color: var(--accent-strong);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.file-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-top: 16px;
}

.file-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 5px 11px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
}

.file-chip .size {
    color: var(--faint);
    font-weight: 400;
    font-variant-numeric: tabular-nums;
}

.option {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 9px;
    max-width: 52ch;
    margin: 20px auto 0;
    padding-top: 18px;
    border-top: 1px solid var(--line-soft);
}

.option input[type=checkbox] {
    width: 15px;
    height: 15px;
    margin-top: 3px;
    flex: 0 0 auto;
    accent-color: var(--accent);
}

.option label {
    font-weight: 550;
    cursor: pointer;
}

.option-hint {
    margin-top: 1px;
    font-size: 12px;
    color: var(--muted);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.limits {
    margin-top: 12px;
    text-align: center;
    font-size: 12px;
    color: var(--faint);
}

/* ---- Buttons ----------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 13px;
    font-weight: 620;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background .15s, border-color .15s, box-shadow .15s, transform .1s;
}

.btn-primary {
    background: var(--accent-strong);
    color: #fff;
    box-shadow: var(--shadow);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-deep);
    box-shadow: var(--shadow-lift);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(1px);
}

.btn-ghost {
    background: var(--surface);
    border-color: var(--line);
    color: var(--ink-2);
}

.btn-ghost:hover {
    background: var(--line-soft);
    border-color: #d4d4d8;
}

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

.btn-link {
    padding: 0;
    background: none;
    border: none;
    color: var(--accent-strong);
    font: inherit;
    font-size: 12px;
    font-weight: 620;
    cursor: pointer;
}

.btn-link:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ---- Download links ---------------------------------------------- */

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

/* Neutral at rest so a long results table stays calm; the accent appears on hover. */
.dl {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: var(--line-soft);
    border: 1px solid transparent;
    border-radius: 7px;
    color: var(--ink-2);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
}

.dl:hover {
    background: var(--accent-soft);
    border-color: var(--accent-line);
    color: var(--accent-deep);
}

/* The batch-level download is the one place the accent is worth spending at rest. */
.stats .dl.primary {
    padding: 9px 16px;
    background: var(--accent-strong);
    border-color: transparent;
    color: #fff;
    font-size: 13px;
    box-shadow: var(--shadow);
}

.stats .dl.primary:hover {
    background: var(--accent-deep);
    color: #fff;
    box-shadow: var(--shadow-lift);
}

/* ---- Stats ------------------------------------------------------- */

/* Sits directly on the page — no container box, no dividers. The numbers do the work. */
.stats {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin: 0 4px 26px;
}

.stat-row {
    display: flex;
    flex-wrap: wrap;
    gap: 40px;
}

.stat .value {
    font-size: 26px;
    font-weight: 640;
    line-height: 1.05;
    letter-spacing: -.9px;
    font-variant-numeric: tabular-nums;
}

.stat .label {
    margin-top: 6px;
    font-size: 10.5px;
    font-weight: 620;
    color: var(--faint);
    text-transform: uppercase;
    letter-spacing: .09em;
}

.stat.ok .value {
    color: var(--ok);
}

.stat.bad .value {
    color: var(--bad);
}

.stat.accent .value {
    color: var(--accent-strong);
}

/* ---- Tables ------------------------------------------------------ */

.table-scroll {
    overflow-x: auto;
    margin: 0 -22px;
    padding: 0 22px;
}

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

thead th {
    padding: 9px 12px;
    border-bottom: 1px solid var(--line-soft);
    color: var(--faint);
    font-size: 10.5px;
    font-weight: 620;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: .09em;
    white-space: nowrap;
}

tbody td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: top;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--wash);
}

.num {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.strong {
    font-weight: 650;
}

/* ---- Results table ------------------------------------------------ */

/* Two calm lines per cell: the value, then its context in a lighter tone. */
.results tbody td {
    padding: 16px 10px;
    vertical-align: middle;
}

.results thead th {
    padding: 10px;
}

.results tbody td:first-child,
.results thead th:first-child {
    padding-left: 2px;
}

.results tbody td:last-child,
.results thead th:last-child {
    padding-right: 2px;
}

.cell-main {
    line-height: 1.35;
}

.cell-sub {
    margin-top: 3px;
    color: var(--faint);
    font-size: 11.5px;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 24ch;
}

.truncate {
    max-width: 22ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* The VIES verdict rides next to the number as a dot rather than taking a third line. */
.dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-left: 5px;
    border-radius: 50%;
    vertical-align: middle;
}

.dot-green { background: #22c55e; }
.dot-red { background: #ef4444; }
.dot-amber { background: #f59e0b; }
.dot-gray { background: #d4d4d8; }

.actions-col {
    width: 1%;
    white-space: nowrap;
}

.row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

/* An open row and its panel read as one block, so the separator between them goes away. */
.results tr.open td {
    border-bottom-color: transparent;
}

.results tr.detail-row:hover {
    background: transparent;
}

.results tr.detail-row > td {
    padding: 0 14px 16px;
    background: transparent;
}

/* The label hugs its own text so the value sits right beside it instead of across a void. */
.info-table th {
    width: 1%;
    padding-left: 0;
    padding-right: 22px;
    border-bottom: 1px solid var(--line-soft);
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    text-align: left;
    text-transform: none;
    letter-spacing: 0;
    white-space: nowrap;
}

.info-table td {
    width: 99%;
    padding-right: 0;
    font-size: 13px;
}

.compact td, .compact th {
    padding-top: 6px;
    padding-bottom: 6px;
}

/* A short table should not stretch across the whole panel just because it can. */
.narrow {
    width: auto;
    min-width: 340px;
    max-width: 520px;
}

.narrow th, .narrow td {
    padding-right: 26px;
}

/* ---- Pills ------------------------------------------------------- */

.pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: .2px;
    white-space: nowrap;
}

.pill-green {
    background: var(--ok-wash);
    color: #166534;
}

.pill-red {
    background: var(--bad-wash);
    color: #991b1b;
}

.pill-amber {
    background: var(--warn-wash);
    color: #92400e;
}

.pill-gray {
    background: var(--line-soft);
    color: var(--muted);
}

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

.mono {
    font-family: 'Cascadia Mono', ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 12.5px;
}

/* ---- Detail panel ------------------------------------------------ */

.detail {
    padding: 20px 22px;
    background: var(--wash);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 26px 32px;
}

.detail h4 {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .6px;
}

/* Only stacked sections need the gap. Inside the grid the sections are columns, and this rule
   would offset the second one, leaving its heading a line lower than its neighbour's. */
.detail > section + section {
    margin-top: 24px;
}

.detail-grid > section + section {
    margin-top: 0;
}

.detail-grid + section {
    margin-top: 24px;
}

/* A second block stacked inside one grid column. */
.section-block {
    margin-top: 24px;
}

.detail .card-err {
    margin: 0;
}

.party {
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}

.party + .party {
    margin-top: 10px;
}

.party-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 4px;
    font-weight: 650;
}

.issue-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.issue-list li {
    display: flex;
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px solid var(--line-soft);
    font-size: 13px;
}

.issue-list li:last-child {
    border-bottom: none;
}

.issue-detail {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.meter {
    height: 4px;
    margin-top: 5px;
    background: var(--line);
    border-radius: 999px;
    overflow: hidden;
}

.meter span {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
}

.raw-text {
    max-height: 280px;
    margin: 10px 0 0;
    padding: 12px;
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--ink-2);
    font-family: 'Cascadia Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

details > summary {
    cursor: pointer;
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 620;
}

details > summary::marker {
    color: var(--faint);
}

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

.stack {
    display: flex;
    flex-direction: column;
    gap: 3px;
    align-items: flex-start;
}

.small {
    font-size: 12px;
}

/* ---- Progress ---------------------------------------------------- */

.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}

/* ---- Responsive -------------------------------------------------- */

@media (max-width: 760px) {
    .appbar {
        height: 54px;
        padding: 0 14px;
    }

    .wrap {
        padding: 20px 14px 36px;
    }

    .page-title {
        font-size: 20px;
    }

    .card {
        padding: 16px;
    }

    .table-scroll {
        margin: 0 -16px;
        padding: 0 16px;
    }

    .actions .btn {
        flex: 1 1 auto;
        justify-content: center;
    }

    .stat {
        min-width: 84px;
    }

    .cell-sub, .truncate {
        max-width: 18ch;
    }
}

/* ---- Blazor plumbing --------------------------------------------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 1000;
    width: 100%;
    padding: 12px 20px;
    background: #fef3c7;
    border-top: 1px solid #fcd34d;
    font-size: 13px;
    box-shadow: 0 -2px 8px rgba(24, 24, 27, .08);
}

#blazor-error-ui .dismiss {
    position: absolute;
    top: 10px;
    right: 20px;
    cursor: pointer;
}
