:root {
    --ink: #17202a;
    --muted: #6b7280;
    --line: #d9dee8;
    --brand: #0b6b5f;
    --brand-dark: #084d45;
    --accent: #b8872d;
    --bg: #f5f7fb;
    --danger: #b42318;
    --success: #067647;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font-family: Arial, Helvetica, sans-serif;
}

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

.site-header,
.admin-header {
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.container {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
}

.site-header .container,
.admin-header .container {
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    color: var(--brand-dark);
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 0;
}

.nav {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.panel,
.stat-card,
.login-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.page {
    padding: 36px 0;
}

.hero {
    display: grid;
    grid-template-columns: 0.95fr 1.05fr;
    gap: 36px;
    align-items: center;
    padding: 34px 0;
}

.hero h1,
.page-title h1 {
    margin: 0 0 12px;
    color: var(--brand-dark);
    font-size: clamp(32px, 5vw, 58px);
    line-height: 1.02;
    letter-spacing: 0;
}

.hero p,
.page-title p {
    color: var(--muted);
    font-size: 18px;
    line-height: 1.6;
}

.search-panel {
    padding: 28px;
}

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

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

.field label {
    display: block;
    margin-bottom: 7px;
    font-weight: 700;
    color: #2f3744;
}

.field input,
.field textarea,
.field select {
    width: 100%;
    border: 1px solid #cbd3df;
    border-radius: 6px;
    padding: 11px 12px;
    font: inherit;
    background: #fff;
}

.field textarea {
    min-height: 92px;
    resize: vertical;
}

.actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 22px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: var(--brand);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

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

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

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

.alert {
    margin: 0 0 18px;
    padding: 12px 14px;
    border-radius: 6px;
    border: 1px solid;
}

.alert.error {
    color: var(--danger);
    border-color: #f3b6af;
    background: #fff1f0;
}

.alert.success {
    color: var(--success);
    border-color: #9edbbd;
    background: #ecfdf3;
}

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

.login-card {
    width: min(420px, 100%);
    padding: 30px;
}

.admin-main {
    padding: 28px 0 50px;
}

.page-title {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-end;
    margin-bottom: 22px;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

th,
td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: #364152;
    background: #f8fafc;
    font-size: 14px;
}

.inline-form {
    display: inline;
}

.signature-preview {
    max-width: 190px;
    max-height: 86px;
    display: block;
    margin-top: 10px;
    border: 1px solid var(--line);
    background: #fff;
}

.certificate-shell {
    padding: 24px 0 44px;
}

.certificate-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-bottom: 18px;
}

.certificate {
    position: relative;
    overflow: hidden;
    background: #fff;
    border: 10px solid #0b6b5f;
    outline: 2px solid var(--accent);
    min-height: 760px;
    padding: 58px 64px;
    text-align: center;
}

.watermark {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: rgba(11, 107, 95, 0.08);
    font-size: 118px;
    font-weight: 900;
    transform: rotate(-24deg);
    pointer-events: none;
    white-space: nowrap;
}

.certificate-content {
    position: relative;
    z-index: 1;
}

.certificate h1 {
    margin: 12px 0 0;
    color: var(--brand-dark);
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 52px;
    letter-spacing: 0;
}

.certificate .subtitle {
    margin: 8px 0 38px;
    color: var(--accent);
    font-size: 20px;
    font-weight: 700;
    text-transform: uppercase;
}

.cert-name {
    margin: 18px auto;
    color: #111827;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 42px;
    border-bottom: 2px solid #111827;
    width: min(620px, 100%);
    padding-bottom: 8px;
}

.cert-text {
    margin: 0 auto;
    max-width: 820px;
    color: #2f3744;
    font-size: 20px;
    line-height: 1.75;
}

.cert-meta {
    margin: 32px auto;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    max-width: 820px;
    text-align: left;
}

.cert-meta div {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 11px 12px;
}

.cert-meta span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.cert-footer {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 18px;
    align-items: end;
    margin-top: 52px;
}

.signature img,
.stamp img {
    max-height: 92px;
    max-width: 180px;
}

.signature-line {
    border-top: 1px solid #111827;
    padding-top: 8px;
    font-weight: 700;
}

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

@media (max-width: 760px) {
    .hero,
    .grid,
    .grid-3,
    .cert-meta,
    .cert-footer {
        grid-template-columns: 1fr;
    }

    .page-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .certificate {
        padding: 36px 22px;
        min-height: auto;
    }

    .certificate h1 {
        font-size: 36px;
    }

    .watermark {
        font-size: 64px;
    }
}

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

    .site-header,
    .certificate-actions {
        display: none;
    }

    .certificate-shell {
        padding: 0;
    }

    .container {
        width: 100%;
    }

    .certificate {
        border-width: 8px;
        outline: 2px solid var(--accent);
        min-height: 96vh;
        page-break-inside: avoid;
    }
}
