:root {
    --ink: #172126;
    --muted: #627078;
    --line: #dbe2e6;
    --soft: #f4f7f8;
    --paper: #ffffff;
    --primary: #0d6b6f;
    --primary-dark: #095156;
    --secondary: #34495e;
    --accent: #d89420;
    --danger: #b83f45;
    --success: #28744d;
    --info: #3867a8;
    --shadow: 0 18px 45px rgba(23, 33, 38, 0.12);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: #eef3f4;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
    letter-spacing: 0;
}

button {
    cursor: pointer;
}

label {
    display: block;
    margin-bottom: 8px;
    color: #34444c;
    font-size: 0.92rem;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #cbd6dc;
    border-radius: 8px;
    background: var(--paper);
    color: var(--ink);
    padding: 12px 13px;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 107, 111, 0.16);
}

input[type="file"] {
    padding: 10px;
}

.field-help {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.45;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 72px;
    padding: 14px clamp(18px, 4vw, 52px);
    border-bottom: 1px solid rgba(219, 226, 230, 0.9);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(14px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: 180px;
}

.brand-mark {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-weight: 900;
}

.brand-logo {
    width: 42px;
    height: 42px;
    object-fit: contain;
    flex: 0 0 auto;
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    line-height: 1.1;
}

.brand small {
    color: var(--muted);
    font-size: 0.78rem;
    margin-top: 2px;
}

.topnav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
}

.topnav a {
    border-radius: 8px;
    color: #36464d;
    font-size: 0.94rem;
    font-weight: 700;
    padding: 9px 11px;
}

.topnav a:hover {
    background: var(--soft);
}

.topnav .nav-pill {
    border: 1px solid var(--line);
    background: #fff;
}

.flash-wrap {
    position: fixed;
    top: 84px;
    right: 24px;
    z-index: 40;
    display: grid;
    gap: 10px;
    width: min(390px, calc(100vw - 32px));
}

.flash {
    border: 1px solid var(--line);
    border-left: 5px solid var(--secondary);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
    padding: 14px 16px;
    font-weight: 700;
}

.flash-success {
    border-left-color: var(--success);
}

.flash-error {
    border-left-color: var(--danger);
}

.public-shell,
.form-shell,
.admin-shell,
.auth-shell,
.success-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
}

.public-shell {
    padding: 44px 0 48px;
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
    align-items: stretch;
    gap: 28px;
    min-height: 420px;
    border-radius: 8px;
    background:
        linear-gradient(120deg, rgba(13, 107, 111, 0.92), rgba(26, 52, 66, 0.94)),
        repeating-linear-gradient(135deg, rgba(255,255,255,0.18) 0 1px, transparent 1px 18px);
    color: #fff;
    overflow: hidden;
}

.hero-copy {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(32px, 6vw, 68px);
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero .eyebrow {
    color: #f5c15b;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    max-width: 820px;
    margin-bottom: 16px;
    font-size: 2.35rem;
    line-height: 1.08;
}

h2 {
    margin-bottom: 16px;
    font-size: 1.12rem;
}

.lead {
    max-width: 660px;
    margin-bottom: 0;
    color: rgba(255, 255, 255, 0.86);
    font-size: 1.08rem;
    line-height: 1.65;
}

.code-panel {
    align-self: center;
    display: grid;
    gap: 18px;
    min-height: 245px;
    margin: 32px 32px 32px 0;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.96);
    color: var(--ink);
    padding: 26px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.2);
}

.code-panel label {
    color: var(--ink);
}

.status-link {
    color: var(--primary);
    font-size: 0.92rem;
    font-weight: 800;
    text-align: center;
}

.flow-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-top: 22px;
}

.flow-grid article,
.stat-card,
.panel,
.form-section,
.auth-card,
.success-box {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--paper);
    box-shadow: 0 10px 26px rgba(23, 33, 38, 0.07);
}

.flow-grid article {
    padding: 20px;
}

.flow-grid span {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 8px;
    background: #e8f4f2;
    color: var(--primary);
    font-weight: 900;
}

.flow-grid strong {
    display: block;
    margin-top: 14px;
    font-size: 1rem;
}

.flow-grid p,
.page-heading p,
.empty,
.hint {
    color: var(--muted);
    line-height: 1.6;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 10px 16px;
    font-weight: 800;
    text-align: center;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    border-color: #cdd7dc;
    background: #fff;
    color: var(--secondary);
}

.btn-ghost {
    border-color: transparent;
    background: transparent;
    color: var(--secondary);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-small {
    min-height: 34px;
    padding: 7px 11px;
    font-size: 0.86rem;
}

.form-shell,
.admin-shell,
.success-shell,
.auth-shell {
    padding: 36px 0 50px;
}

.admin-shell.narrow {
    width: min(850px, calc(100% - 32px));
}

.page-heading {
    margin-bottom: 22px;
}

.page-heading h1 {
    margin-bottom: 8px;
}

.with-action {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.wide-form,
.form-grid {
    display: grid;
    gap: 18px;
}

.form-section {
    padding: 22px;
}

.form-subtitle {
    margin: 4px 0 -2px;
    border-top: 1px solid var(--line);
    padding-top: 16px;
    color: var(--primary);
    font-size: 0.98rem;
}

.form-subtitle:first-child {
    border-top: 0;
    padding-top: 0;
}

.two-col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.span-2 {
    grid-column: span 2;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.auth-shell,
.success-shell {
    display: grid;
    min-height: calc(100vh - 150px);
    place-items: center;
}

.auth-card,
.success-box {
    width: min(440px, 100%);
    padding: 28px;
}

.auth-card {
    display: grid;
    gap: 18px;
}

.auth-card h1,
.success-box h1 {
    margin-bottom: 4px;
    font-size: 1.8rem;
}

.hint {
    margin: 0;
    font-size: 0.92rem;
}

.success-box {
    text-align: center;
}

.status-card {
    width: min(500px, 100%);
}

.status-display {
    margin: 18px 0 0;
}

.status-display .badge {
    font-size: 1rem;
    min-height: 38px;
    padding: 8px 14px;
}

.success-mark {
    display: inline-grid;
    width: 54px;
    height: 54px;
    place-items: center;
    margin-bottom: 14px;
    border-radius: 8px;
    background: #e7f5ee;
    color: var(--success);
    font-weight: 900;
}

.receipt {
    display: grid;
    gap: 10px;
    margin: 22px 0;
    text-align: left;
}

.receipt div,
.detail-list div {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
    padding: 12px;
}

.receipt dt,
.detail-list dt {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 800;
}

.receipt dd,
.detail-list dd {
    margin: 4px 0 0;
    font-weight: 800;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.stat-card {
    padding: 20px;
}

.stat-card span {
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 800;
}

.stat-card strong {
    display: block;
    margin-top: 10px;
    font-size: 2rem;
}

.split-layout,
.detail-layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 18px;
}

.panel {
    padding: 20px;
}

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

.panel-head h2,
.panel h2 {
    margin-bottom: 0;
}

.panel-head a {
    color: var(--primary);
    font-weight: 800;
}

.mini-list {
    display: grid;
    gap: 8px;
}

.mini-list a {
    display: block;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fbfcfd;
}

.mini-list a:hover {
    border-color: var(--primary);
}

.mini-list strong,
.mini-list span {
    display: block;
}

.mini-list span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.88rem;
}

.download-link {
    display: inline-block;
    margin-top: 4px;
    color: var(--primary);
    font-weight: 900;
}

.download-link + small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-weight: 700;
}

.filter-bar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 190px auto;
    gap: 10px;
    margin-bottom: 16px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
}

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

th {
    background: #f7fafb;
    color: #405057;
    font-size: 0.8rem;
    text-transform: uppercase;
}

td small,
.muted {
    color: var(--muted);
}

tr:last-child td {
    border-bottom: 0;
}

.empty-cell {
    padding: 28px;
    color: var(--muted);
    text-align: center;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 8px;
    background: #eef2f4;
    color: #41515a;
    padding: 5px 9px;
    font-size: 0.8rem;
    font-weight: 900;
}

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

.badge-warning {
    background: #fff3d6;
    color: #8a5a00;
}

.badge-danger {
    background: #fde7e9;
    color: var(--danger);
}

.badge-info {
    background: #e7eefb;
    color: var(--info);
}

.inline-form {
    display: inline;
}

.status-form {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) auto;
    gap: 10px;
}

.detail-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 16px 0 0;
}

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

.detail-list .wide {
    grid-column: 1 / -1;
}

.footer {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    padding: 22px clamp(18px, 4vw, 52px);
    font-size: 0.88rem;
}

.proof-shell {
    width: min(920px, calc(100% - 32px));
    margin: 0 auto;
    padding: 34px 0 50px;
}

.proof-document {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
    padding: clamp(26px, 5vw, 48px);
}

.proof-head {
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 2px solid var(--ink);
    padding-bottom: 18px;
}

.proof-logo {
    width: 72px;
    height: 92px;
    object-fit: contain;
    flex: 0 0 auto;
}

.proof-head h1 {
    margin: 0 0 4px;
    font-size: 1.55rem;
}

.proof-head p {
    margin: 0;
    color: var(--muted);
}

.proof-status {
    margin: 28px auto 22px;
    width: fit-content;
    border: 2px solid var(--success);
    border-radius: 8px;
    color: var(--success);
    padding: 10px 22px;
    font-size: 1.45rem;
    font-weight: 900;
}

.proof-copy {
    color: #34444c;
    line-height: 1.7;
    text-align: center;
}

.proof-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 24px 0 34px;
}

.proof-list div {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.proof-list dt {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 900;
}

.proof-list dd {
    margin: 5px 0 0;
    font-weight: 900;
}

.proof-signature {
    display: flex;
    justify-content: flex-end;
    margin-top: 26px;
}

.proof-signature div {
    min-width: 240px;
    text-align: center;
}

.proof-signature p {
    margin-bottom: 8px;
}

.proof-signature strong {
    display: block;
    margin-top: 72px;
}

.proof-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

@media (max-width: 920px) {
    .hero,
    .split-layout,
    .detail-layout {
        grid-template-columns: 1fr;
    }

    .code-panel {
        margin: 0 24px 24px;
    }

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

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

@media (max-width: 680px) {
    .topbar,
    .with-action,
    .footer {
        align-items: stretch;
        flex-direction: column;
    }

    .topnav {
        justify-content: flex-start;
    }

    h1 {
        font-size: 1.85rem;
    }

    .hero {
        min-height: 0;
    }

    .hero-copy {
        padding: 28px;
    }

    .flow-grid,
    .stat-grid,
    .two-col,
    .filter-bar,
    .status-form,
    .proof-list,
    .detail-list,
    .detail-list.three {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: auto;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions .btn,
    .filter-bar .btn,
    .status-form .btn {
        width: 100%;
    }

    .flash-wrap {
        top: 112px;
        right: 16px;
    }
}

@media print {
    body {
        background: #fff;
    }

    .topbar,
    .footer,
    .flash-wrap,
    .no-print {
        display: none !important;
    }

    .proof-shell {
        width: 100%;
        padding: 0;
    }

    .proof-document {
        border: 0;
        box-shadow: none;
        padding: 0;
    }

    .proof-list div {
        break-inside: avoid;
    }
}
