:root {
    --bg: #f3f1ea;
    --panel: #ffffff;
    --ink: #1f2a30;
    --muted: #5f6d74;
    --brand: #0e6a63;
    --brand-2: #d6a83d;
    --line: #d7d4cd;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    font-family: "Segoe UI", "Trebuchet MS", sans-serif;
}

.app-bg {
    background:
        radial-gradient(circle at 10% 20%, rgba(14, 106, 99, 0.1), transparent 45%),
        radial-gradient(circle at 90% 0%, rgba(214, 168, 61, 0.14), transparent 30%),
        var(--bg);
    min-height: 100vh;
}

.shell {
    max-width: 1120px;
    margin: 0 auto;
    padding: 24px;
    display: grid;
    gap: 16px;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.login-panel {
    width: 100%;
    max-width: 460px;
}

.login-panel h1 {
    margin-top: 0;
}

.login-form {
    display: grid;
    gap: 12px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 20px;
}

.tab-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.tab-btn {
    border: 1px solid #b9d3cf;
    background: #f2faf8;
    color: #0a504b;
    padding: 10px 14px;
    border-radius: 999px;
    font: inherit;
    cursor: pointer;
}

.tab-btn.is-active {
    background: linear-gradient(135deg, var(--brand), #0f8780);
    color: #fff;
    border-color: transparent;
}

.tab-panel {
    display: none;
    grid-column: span 2;
}

.tab-panel.is-active {
    display: block;
}

.hero h1 {
    margin: 0 0 8px;
}

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

.edit-banner {
    margin-top: 8px !important;
    color: #0d5f58 !important;
    font-weight: 700;
}

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

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

label {
    font-size: 0.9rem;
    color: var(--muted);
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #c8c3b8;
    border-radius: 10px;
    padding: 11px 12px;
    font: inherit;
    background: #fffdfa;
}

textarea {
    resize: vertical;
}

.actions {
    margin-top: 4px;
}

.hint {
    margin: 0;
    font-size: 0.9rem;
    color: var(--muted);
}

.btn {
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--brand), #0f8780);
    color: white;
    padding: 11px 18px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.btn-soft {
    background: #d8ecea;
    color: #094b47;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    border-bottom: 1px solid var(--line);
    text-align: left;
    padding: 10px 6px;
    font-size: 0.95rem;
}

.print-bg {
    background: #ece8dc;
    margin: 0;
    min-height: 100vh;
    padding: 12px;
}

.toolbar {
    max-width: 1180px;
    margin: 0 auto 10px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.toolbar form {
    margin: 0;
}

.certificate {
    width: 297mm;
    min-height: 210mm;
    margin: 0 auto;
    background: #fffdf8;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.12);
    position: relative;
}

.cert-border {
    border: 5px double #c59d42;
    min-height: 210mm;
    padding: 16mm 18mm;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background:
        linear-gradient(140deg, rgba(14, 106, 99, 0.07), rgba(255, 255, 255, 0) 45%),
        linear-gradient(320deg, rgba(197, 157, 66, 0.07), rgba(255, 255, 255, 0) 48%);
}

.cert-header {
    text-align: center;
}

.cert-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    min-height: 64px;
}

.logo-box {
    width: 70mm;
    height: 22mm;
    display: flex;
    align-items: center;
}

.logo-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.cert-meta {
    text-align: right;
}

.cert-header h1 {
    margin: 8px 0 6px;
    letter-spacing: 1px;
    font-size: 2rem;
}

.cert-sub {
    margin: 2px 0;
    color: var(--muted);
}

.cert-body {
    margin-top: 8mm;
}

.cert-body h2 {
    margin-top: 0;
    text-align: center;
}

.cert-body p {
    line-height: 1.55;
    margin: 10px 0;
    font-size: 1.03rem;
}

.cert-note {
    margin-top: 12px;
    font-size: 0.95rem;
    color: var(--muted);
}

.cert-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 14px;
    margin-top: 10mm;
}

.signatures {
    display: flex;
    gap: 14px;
    width: 100%;
}

.sign-box {
    flex: 1;
}

.line {
    display: block;
    border-top: 1px solid #777;
    margin-bottom: 5px;
}

.sign-box p {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.qr-block {
    text-align: center;
}

.qr-block img {
    width: 38mm;
    height: 38mm;
    border: 1px solid #bbb;
    background: #fff;
    padding: 3px;
}

.qr-block p {
    margin: 4px 0 0;
    font-size: 0.85rem;
    color: var(--muted);
}

.verify-bg {
    background: linear-gradient(180deg, #f8f3ea, #eef5f4);
    min-height: 100vh;
}

.verify-shell {
    max-width: 860px;
    margin: 0 auto;
    padding: 24px;
}

.verify-panel h1 {
    margin-top: 0;
}

.valid {
    color: #0b6d2e;
    font-weight: 700;
}

.invalid {
    color: #9b1c1c;
    font-weight: 700;
}

.verify-grid {
    display: grid;
    gap: 8px;
    margin-top: 8px;
}

.logo-current {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-current img {
    width: 110px;
    height: 40px;
    object-fit: contain;
    border: 1px solid #d3d3d3;
    background: #fff;
    padding: 3px;
}

.inline-form {
    margin-top: 8px;
}

.btn-danger {
    border-color: rgba(150, 43, 43, 0.28);
    color: #8f1d1d;
}

.btn-danger:hover {
    background: rgba(143, 29, 29, 0.08);
}

.check-row {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.check-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

@media (max-width: 900px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

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

    .certificate {
        width: 100%;
        min-height: auto;
    }

    .cert-border {
        min-height: auto;
        padding: 18px;
    }

    .cert-footer,
    .signatures {
        flex-direction: column;
        align-items: stretch;
    }

    .cert-top {
        flex-direction: column;
        align-items: stretch;
    }

    .cert-meta {
        text-align: left;
    }
}

@media print {
    @page {
        size: A4 landscape;
        margin: 0;
    }

    .no-print {
        display: none !important;
    }

    body {
        background: #fff;
        padding: 0;
        margin: 0;
    }

    .certificate {
        box-shadow: none;
        width: 297mm;
        min-height: 210mm;
    }
}
