:root {
    color-scheme: light;
    --border: #d8d6d0;
    --ink: #171717;
    --muted: #66645e;
    --accent: #0a7b3d;
    --paper: #fbfaf7;
    --deep: #103b27;
    --gold: #c39a52;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Vazirmatn, Tahoma, Arial, sans-serif;
    color: var(--ink);
    background: var(--paper);
    direction: rtl;
}

.shell {
    width: min(1040px, calc(100% - 32px));
    margin: 36px auto;
}

.site-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 22px;
    padding: 12px 14px;
    margin-bottom: 28px;
    border: 1px solid rgba(16, 59, 39, .12);
    border-radius: 16px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 10px 30px rgba(16, 59, 39, .08);
}

.site-brand { display: flex; align-items: center; gap: 11px; color: var(--deep); text-decoration: none; }
.site-brand > span:last-child { display: grid; line-height: 1.2; }
.site-brand strong { font-size: 15px; }
.site-brand small { margin-top: 4px; color: var(--muted); font-size: 10px; font-weight: 600; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; color: #fff; background: linear-gradient(145deg, #17643f, var(--deep)); box-shadow: 0 5px 12px rgba(16, 59, 39, .2); font-size: 13px; font-weight: 900; }
.primary-nav { display: flex; justify-content: center; gap: 5px; flex-wrap: wrap; }
.nav-button { padding: 9px 13px; border-radius: 9px; color: #46534b; text-decoration: none; font-size: 13px; transition: .18s ease; }
.nav-button:hover { color: var(--deep); background: #edf5f0; }
.nav-button.active { color: #fff; background: var(--deep); box-shadow: 0 4px 10px rgba(16, 59, 39, .18); }
.user-menu { display: flex; align-items: center; gap: 7px; }
.user-badge { padding: 7px 10px; border-radius: 999px; color: #7e281f; background: #fff1ef; font-size: 12px; font-weight: 800; }
.logout-button { padding: 7px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 12px; }
.logout-button:hover { color: #9d261d; background: #fff1ef; }
.nav-toggle { display: none; min-height: 38px; padding: 0 14px; }

.portal-hero { display: grid; grid-template-columns: 1.5fr .7fr; align-items: center; min-height: 330px; padding: 48px; overflow: hidden; border-radius: 24px; color: #fff; background: radial-gradient(circle at 15% 10%, rgba(195,154,82,.28), transparent 32%), linear-gradient(135deg, #0d3020, #16573a); box-shadow: 0 22px 50px rgba(16,59,39,.2); }
.portal-eyebrow { color: #ead7b4; font-weight: 800; font-size: 13px; }
.portal-hero h1 { margin: 10px 0 12px; font-size: clamp(34px, 5vw, 58px); }
.portal-hero p { max-width: 610px; margin-bottom: 28px; color: #d9e7de; line-height: 1.9; }
.hero-action, .hero-secondary { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 20px; border-radius: 10px; color: var(--deep); background: #f2d69f; text-decoration: none; }
.portal-emblem { display: grid; place-items: center; aspect-ratio: 1; border: 1px solid rgba(242,214,159,.4); border-radius: 50%; outline: 1px solid rgba(242,214,159,.16); outline-offset: 14px; color: #ead7b4; text-align: center; }
.portal-emblem span, .portal-emblem strong { grid-area: 1/1; }
.portal-emblem span { transform: translateY(-18px); font-size: 14px; }
.portal-emblem strong { transform: translateY(15px); font-size: 24px; }
.portal-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 20px; }
.portal-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; min-height: 112px; padding: 20px; border: 1px solid var(--border); border-radius: 16px; color: var(--ink); background: #fff; text-decoration: none; transition: transform .18s ease, box-shadow .18s ease; }
.portal-card:hover { transform: translateY(-3px); box-shadow: 0 14px 28px rgba(16,59,39,.1); }
.portal-card > span:nth-child(2) { display: grid; gap: 6px; }
.portal-card small { color: var(--muted); font-weight: 500; }
.card-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 13px; color: var(--deep); background: #e9f4ed; font-size: 20px; }
.card-arrow { color: var(--gold); font-size: 22px; }

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

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

.brand-block {
    display: grid;
    gap: 6px;
}

.brand-block h1 {
    margin-bottom: 0;
}

.current-user {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-weight: 700;
}

.current-user span {
    color: var(--ink);
}

.current-user strong {
    color: #b42318;
}

.current-user a {
    font-weight: 700;
}

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

a {
    color: var(--accent);
    font-weight: 700;
}

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

.panel,
.entry,
.alert {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.panel {
    padding: 20px;
}

.automatic-poster-panel { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 22px; margin-bottom: 20px; border-color: #b9d8c3; background: #f5fbf7; }
.automatic-poster-panel h2 { margin-bottom: 8px; color: var(--deep); }
.automatic-poster-panel p { margin-bottom: 0; color: var(--muted); line-height: 1.8; }
.automatic-poster-panel form { display: flex; align-items: end; gap: 10px; }
.automatic-poster-panel label { margin: 0; min-width: 120px; }
.automatic-poster-panel input { background: #fff; }

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

.auth-panel {
    width: min(440px, 100%);
}

label {
    display: grid;
    gap: 8px;
    margin-top: 16px;
    font-weight: 700;
}

input {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
}

.actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-start;
}

button,
.preview-link,
.download-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: 6px;
    color: #fff;
    background: var(--accent);
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.download-link {
    color: var(--accent);
    background: #eef8f1;
    border: 1px solid #b9d8c3;
}

.alert {
    padding: 14px 16px;
    margin-bottom: 18px;
}

.alert p {
    margin-bottom: 6px;
}

.alert p:last-child {
    margin-bottom: 0;
}

.error {
    border-color: #d79393;
    color: #8a1e1e;
    background: #fff5f5;
}

.success {
    border-color: #9fcca9;
    color: #0f6829;
    background: #f1fbf3;
}

.entries {
    display: grid;
    gap: 14px;
}

.entry {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px;
}

.delete-form { margin: 0; }
.entry > .delete-form { order: 3; margin-inline-start: auto; }
.delete-icon { width: 38px; height: 38px; min-height: 38px; padding: 0; border: 1px solid #f0c8c4; border-radius: 10px; color: #b42318; background: #fff4f2; }
.delete-icon:hover { color: #fff; background: #b42318; border-color: #b42318; }
.delete-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.row-actions { display: inline-flex; flex-direction: row; flex-wrap: nowrap; align-items: center; justify-content: center; gap: 6px; width: max-content; }
.row-actions .delete-form { flex: 0 0 auto; }
.row-actions .edit-icon,
.row-actions .delete-icon { flex: 0 0 38px; }
.edit-icon { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 1px solid #bdd5ee; border-radius: 10px; color: #1d5f9e; background: #eff7ff; }
.edit-icon:hover { color: #fff; background: #1d5f9e; border-color: #1d5f9e; }
.edit-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.entry-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.print-summary { display: flex; justify-content: space-between; gap: 14px; margin-bottom: 16px; padding: 13px 16px; border: 1px solid #cbded1; border-radius: 10px; background: #f3faf5; }
.print-summary strong { color: var(--deep); }
.print-summary span { color: var(--muted); }
.entry-printed { opacity: .62; background: #f3f3f1; border-style: dashed; }
.entry-printed::before { content: 'چاپ‌شده'; position: absolute; top: 10px; left: 10px; padding: 4px 9px; border-radius: 999px; color: #fff; background: #68746d; font-size: 11px; font-weight: 800; }
.printed-form { margin: 0; }
.printed-button { min-height: 44px; color: #fff; background: #b7791f; }
.printed-button:hover { background: #925f17; }
.printed-button.is-printed { color: #2f4b39; background: #dce7df; }
.printed-button.is-printed:hover { color: #fff; background: #68746d; }

.entry-label {
    color: #b42318;
    font-weight: 700;
}

.entry p,
.empty {
    color: var(--muted);
    margin-bottom: 8px;
}

.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 16px;
    border-radius: 6px;
    color: #fff;
    background: var(--accent);
    font-weight: 700;
    text-decoration: none;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.search-bar input[type="search"] {
    flex: 1 1 260px;
}

.alpha-index {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 18px;
}

.alpha-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    font-weight: 700;
    text-decoration: none;
}

.alpha-btn:hover,
.alpha-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.results-count {
    color: var(--muted);
    margin: 0 0 14px;
}

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

.people-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.people-table th,
.people-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    text-align: right;
    white-space: nowrap;
}

.people-table thead th {
    background: #f4f3ef;
}

.people-table th a {
    color: var(--ink);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.people-table tbody tr:hover {
    background: #faf9f6;
}

.people-table tbody tr:last-child td {
    border-bottom: 0;
}

.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
    color: var(--muted);
}

.pager a,
.pager span.disabled {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    color: var(--ink);
    font-weight: 700;
}

.pager span.disabled {
    opacity: .4;
}

@media (max-width: 760px) {
    .form-grid,
    .entry,
    .topbar {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }

    .actions {
        justify-content: stretch;
    }

    .search-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .pager {
        flex-wrap: wrap;
    }

    .site-header { grid-template-columns: 1fr auto; gap: 10px; }
    .site-brand small, .user-menu { display: none; }
    .nav-toggle { display: inline-flex; }
    .primary-nav { display: none; grid-column: 1 / -1; flex-direction: column; align-items: stretch; padding-top: 8px; border-top: 1px solid var(--border); }
    .primary-nav.open { display: flex; }
    .nav-button { text-align: center; }
    .portal-hero { grid-template-columns: 1fr; min-height: 0; padding: 34px 24px; }
    .portal-emblem { display: none; }
    .portal-grid { grid-template-columns: 1fr; }
}
