:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --text: #1c2430;
    --muted: #667085;
    --border: #dbe2ea;
    --primary: #2457ff;
    --primary-dark: #1d46cc;
    --danger: #d92d20;
    --success: #067647;
    --shadow: 0 20px 45px rgba(15, 23, 42, 0.08);
    --radius: 22px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    background: radial-gradient(circle at top, #ffffff 0, #f7f9fc 40%, var(--bg) 100%);
    color: var(--text);
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    line-height: 1.5;
}

body.page-admin,
body.page-login {
    background: #f5f6f8;
}

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

.page-shell,
.admin-shell,
.login-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 32px auto;
}

.hero,
.admin-topbar,
.section-head,
.stats-grid,
.search-form,
.form-actions,
.header-actions,
.admin-actions,
.row-actions {
    display: flex;
    gap: 12px;
}

.hero,
.admin-topbar,
.section-head {
    justify-content: space-between;
    align-items: center;
}

.hero,
.admin-topbar {
    margin-bottom: 18px;
}

.admin-topbar {
    background: linear-gradient(135deg, #2563eb 0%, #4f46e5 48%, #8b5cf6 100%);
    color: #fff;
    border: 0;
    border-radius: 22px;
    padding: 28px 32px;
    box-shadow: 0 18px 40px rgba(37, 99, 235, 0.18);
    align-items: flex-start;
}

.admin-topbar .eyebrow {
    color: rgba(255, 255, 255, 0.88);
}

.admin-topbar h1 {
    margin-bottom: 0;
    color: #fff;
}

.admin-actions a,
.admin-actions .text-button {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.admin-actions a:hover,
.admin-actions .text-button:hover {
    background: rgba(255, 255, 255, 0.22);
}

.eyebrow {
    margin: 0 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.75rem;
    color: var(--muted);
}

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

h1 {
    margin-bottom: 8px;
    font-size: clamp(2rem, 4vw, 3rem);
}

h2 {
    margin-bottom: 4px;
    font-size: 1.5rem;
}

.hero-text {
    max-width: 720px;
    margin-bottom: 0;
    color: var(--muted);
}

.ghost-link,
.ghost-button,
.secondary-button,
.primary-button,
.danger-button,
.text-button,
.action-link {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.85rem 1.2rem;
    font: inherit;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
}

.ghost-link,
.ghost-button {
    background: rgba(255, 255, 255, 0.8);
}

.secondary-button,
.action-link {
    background: #eef3ff;
    color: var(--primary-dark);
    border-color: #d6e0ff;
}

.primary-button {
    background: linear-gradient(180deg, var(--primary), var(--primary-dark));
    color: #fff;
    border-color: transparent;
}

.danger-button {
    background: #fff2f0;
    color: var(--danger);
    border-color: #ffd6d3;
}

.text-button {
    background: transparent;
    color: var(--text);
}

.ghost-link:hover,
.ghost-button:hover,
.secondary-button:hover,
.primary-button:hover,
.danger-button:hover,
.text-button:hover,
.action-link:hover {
    transform: translateY(-1px);
}

.card {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(219, 226, 234, 0.9);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    padding: 24px;
}

.card-form {
    padding: 28px;
}

.form {
    display: grid;
    gap: 20px;
}

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

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

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

.field label {
    font-weight: 600;
    font-size: 0.95rem;
}

.field input,
.field textarea,
.search-form input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 0.95rem 1rem;
    font: inherit;
    color: var(--text);
    background: #fff;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

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

.field input:focus,
.field textarea:focus,
.search-form input:focus {
    border-color: rgba(36, 87, 255, 0.5);
    box-shadow: 0 0 0 4px rgba(36, 87, 255, 0.12);
}

.field-error {
    color: #b42318;
    font-size: 0.9rem;
}

.form-note {
    margin: -6px 0 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.form-note-error {
    color: #b42318;
}

.form-actions {
    justify-content: flex-end;
}

.alert {
    border-radius: 16px;
    padding: 14px 16px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

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

.alert-error {
    background: #fef3f2;
    border-color: #fecdca;
    color: #b42318;
}

.alert-info {
    background: #eff8ff;
    border-color: #b2ddff;
    color: #175cd3;
}

.admin-actions,
.header-actions,
.row-actions {
    flex-wrap: wrap;
    align-items: center;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

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

.stat-card {
    background: linear-gradient(180deg, #ffffff, #f8fbff);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.stat-card span {
    display: block;
    color: var(--muted);
    margin-bottom: 8px;
}

.stat-card strong {
    font-size: 2rem;
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 14px 16px;
    border-bottom: 1px solid #edf1f5;
    vertical-align: top;
}

.data-table th {
    background: #f8fbff;
    color: #475467;
    font-weight: 600;
}

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

.search-form {
    margin: 18px 0 20px;
    flex-wrap: wrap;
    align-items: center;
}

.search-form input {
    flex: 1 1 260px;
}

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

.detail-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 18px;
    box-shadow: var(--shadow);
}

.detail-card span {
    display: block;
    color: var(--muted);
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.detail-card strong {
    font-size: 1rem;
    word-break: break-word;
}

.login-shell {
    width: min(560px, calc(100% - 32px));
    min-height: calc(100vh - 64px);
    display: grid;
    place-items: center;
}

.login-card {
    width: 100%;
    overflow: hidden;
    padding: 0;
}

.login-banner {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 28px 28px 26px;
    background: linear-gradient(135deg, #2563eb 0%, #4f46e5 48%, #8b5cf6 100%);
    color: #fff;
}

.login-banner .eyebrow {
    color: rgba(255, 255, 255, 0.88);
}

.login-banner h1 {
    color: #fff;
}

.login-banner .hero-text {
    color: rgba(255, 255, 255, 0.88);
}

.login-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.18);
    flex: 0 0 auto;
}

.login-icon svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.login-card .alert,
.login-card .auth-form {
    margin-left: 28px;
    margin-right: 28px;
}

.login-card .alert {
    margin-top: 22px;
}

.login-card .auth-form {
    margin-top: 18px;
    margin-bottom: 28px;
}

body.page-public {
    background: #f5f6f8;
}

.public-page {
    min-height: 100vh;
    padding: 28px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.public-card {
    width: min(760px, 100%);
    background: #fff;
    border: 1px solid #e2e6ec;
    border-radius: 20px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
    padding: 32px;
}

.public-header {
    margin-bottom: 24px;
}

.public-header h1 {
    margin: 0 0 8px;
    font-size: clamp(1.8rem, 3vw, 2.2rem);
    line-height: 1.2;
    letter-spacing: -0.03em;
}

.public-header p {
    margin: 0;
    color: #6b7280;
    font-size: 0.98rem;
}

.public-form {
    display: grid;
    gap: 20px;
}

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

.public-form-row {
    display: grid;
    gap: 16px;
}

.public-form-row-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.public-form-row-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.public-form .field {
    gap: 6px;
}

.public-form .field label {
    font-size: 0.92rem;
    font-weight: 600;
    color: #344054;
}

.field-required {
    color: #2563eb;
}

.public-form .field input,
.public-form .field textarea {
    border: 1px solid #d9dde3;
    border-radius: 8px;
    padding: 0.85rem 0.95rem;
    font-size: 0.96rem;
    background: #fff;
    min-height: 46px;
    box-shadow: none;
}

.public-form .field textarea {
    min-height: 112px;
    line-height: 1.5;
}

.public-form .field input:focus,
.public-form .field textarea:focus {
    border-color: #b7c2d0;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.field input.is-invalid,
.field textarea.is-invalid {
    border-color: #b42318;
    box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.08);
}

.field input.is-invalid:focus,
.field textarea.is-invalid:focus {
    border-color: #b42318;
    box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.12);
}

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

.public-textarea-field {
    align-self: stretch;
}

.public-form .field-error {
    color: #b42318;
    font-size: 0.85rem;
}

.public-form .form-note {
    margin-top: -4px;
}

.public-form-actions {
    margin-top: 4px;
}

.public-submit-button {
    width: 100%;
    min-height: 50px;
    border-radius: 10px;
    background: #1f4ed8;
    border-color: #1f4ed8;
    font-size: 0.98rem;
    font-weight: 600;
}

.public-submit-button:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
    transform: translateY(-1px);
}

@media (max-width: 900px) {
    .hero,
    .admin-topbar,
    .section-head,
    .stats-grid,
    .search-form,
    .header-actions,
    .admin-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .form-grid,
    .stats-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }

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

    .form-actions {
        justify-content: stretch;
    }

    .primary-button,
    .secondary-button,
    .ghost-button,
    .ghost-link {
        width: 100%;
    }

    .public-card {
        padding: 24px;
        border-radius: 18px;
    }

    .public-form-grid,
    .public-form-row-2,
    .public-form-row-3 {
        grid-template-columns: 1fr;
    }

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

    .public-form .field input,
    .public-form .field textarea {
        min-height: 46px;
    }

    .public-form .field textarea {
        min-height: 108px;
    }
}
