:root {
    --admin-bg: #f5f3ef;
    --admin-card: #ffffff;
    --admin-text: #1d1d1f;
    --admin-muted: #6b6b6b;
    --admin-primary: #22372b;
    --admin-primary-hover: #18271f;
    --admin-border: #ded8ce;
    --admin-error-bg: #fff1f1;
    --admin-error-text: #9f1d1d;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--admin-text);
    background: var(--admin-bg);
}

.admin-auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(100%, 420px);
    background: var(--admin-card);
    border: 1px solid var(--admin-border);
    border-radius: 28px;
    padding: 34px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.08);
}

.login-logo {
    width: 54px;
    height: 54px;
    border-radius: 18px;
    background: var(--admin-primary);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 24px;
    margin-bottom: 22px;
}

.login-card h1 {
    margin: 0;
    font-size: 30px;
    line-height: 1.1;
    letter-spacing: -0.04em;
}

.login-subtitle {
    margin: 12px 0 24px;
    color: var(--admin-muted);
    line-height: 1.5;
}

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

.login-form label {
    font-size: 14px;
    font-weight: 700;
}

.login-form input {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--admin-border);
    border-radius: 14px;
    padding: 0 14px;
    font-size: 16px;
    outline: none;
}

.login-form input:focus {
    border-color: var(--admin-primary);
    box-shadow: 0 0 0 4px rgba(34, 55, 43, 0.12);
}

.login-form button {
    margin-top: 10px;
    min-height: 48px;
    border: 0;
    border-radius: 999px;
    background: var(--admin-primary);
    color: #fff;
    font-weight: 800;
    font-size: 15px;
    cursor: pointer;
}

.login-form button:hover {
    background: var(--admin-primary-hover);
}

.alert {
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 18px;
    font-size: 14px;
}

.alert-error {
    background: var(--admin-error-bg);
    color: var(--admin-error-text);
    border: 1px solid rgba(159, 29, 29, 0.18);
}

.admin-body {
    min-height: 100vh;
}

.admin-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.admin-sidebar {
    background: #111914;
    color: #fff;
    padding: 24px;
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    font-size: 20px;
    margin-bottom: 34px;
}

.admin-brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 14px;
    background: #ffffff;
    color: var(--admin-primary);
    display: grid;
    place-items: center;
}

.admin-menu {
    display: grid;
    gap: 8px;
}

.admin-menu a {
    color: rgba(255, 255, 255, 0.72);
    text-decoration: none;
    padding: 12px 14px;
    border-radius: 14px;
    font-weight: 650;
}

.admin-menu a:hover,
.admin-menu a.active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.admin-main {
    min-width: 0;
}

.admin-topbar {
    min-height: 116px;
    padding: 26px 34px;
    background: var(--admin-card);
    border-bottom: 1px solid var(--admin-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.admin-kicker {
    margin: 0 0 4px;
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--admin-primary);
}

.admin-topbar h1 {
    margin: 0;
    font-size: 30px;
    letter-spacing: -0.04em;
}

.admin-user {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--admin-muted);
    font-size: 14px;
}

.admin-user a {
    color: var(--admin-primary);
    font-weight: 800;
    text-decoration: none;
}

.admin-content {
    padding: 34px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 22px;
}

.dashboard-card {
    background: var(--admin-card);
    border: 1px solid var(--admin-border);
    border-radius: 24px;
    padding: 26px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.04);
}

.card-label {
    margin: 0 0 10px;
    color: var(--admin-primary);
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 0.08em;
    font-size: 12px;
}

.dashboard-card h2 {
    margin: 0 0 12px;
    font-size: 25px;
    letter-spacing: -0.035em;
}

.dashboard-card p:last-child {
    margin-bottom: 0;
    color: var(--admin-muted);
    line-height: 1.55;
}

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

    .admin-sidebar {
        position: static;
    }

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

    .admin-topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.admin-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 26px;
}

.admin-page-header h2 {
    margin: 0 0 10px;
    font-size: 32px;
    letter-spacing: -0.045em;
}

.admin-page-header p:last-child {
    max-width: 760px;
    margin: 0;
    color: var(--admin-muted);
    line-height: 1.6;
}

.admin-actions {
    flex-shrink: 0;
}

.admin-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 800;
    text-decoration: none;
    border: 1px solid transparent;
}

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

.admin-button.primary:hover {
    background: var(--admin-primary-hover);
}

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

.stat-card {
    background: var(--admin-card);
    border: 1px solid var(--admin-border);
    border-radius: 22px;
    padding: 22px;
    box-shadow: 0 16px 45px rgba(0, 0, 0, 0.035);
}

.stat-label {
    display: block;
    color: var(--admin-muted);
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
}

.stat-card strong {
    display: block;
    font-size: 34px;
    line-height: 1;
    letter-spacing: -0.05em;
}

.admin-panel {
    background: var(--admin-card);
    border: 1px solid var(--admin-border);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.04);
}

.admin-panel-header {
    padding: 22px 24px;
    border-bottom: 1px solid var(--admin-border);
}

.admin-panel-header h3 {
    margin: 0;
    font-size: 20px;
    letter-spacing: -0.03em;
}

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

.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 920px;
}

.admin-table th,
.admin-table td {
    padding: 16px 18px;
    border-bottom: 1px solid var(--admin-border);
    text-align: left;
    vertical-align: middle;
    font-size: 14px;
}

.admin-table th {
    background: #faf9f6;
    color: var(--admin-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

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

.admin-table code {
    background: #f3f0ea;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    padding: 4px 7px;
    font-size: 13px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.status-badge.published {
    background: #e8f6ee;
    color: #1d6b3a;
}

.status-badge.draft {
    background: #fff6df;
    color: #8a5b00;
}

.text-right {
    text-align: right !important;
}

.table-action {
    display: inline-flex;
    margin-left: 10px;
    color: var(--admin-primary);
    font-weight: 800;
    text-decoration: none;
}

.table-action:hover {
    text-decoration: underline;
}

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

.empty-state {
    padding: 42px 24px;
    text-align: center;
}

.empty-state h3 {
    margin: 0 0 8px;
    font-size: 22px;
}

.empty-state p {
    margin: 0;
    color: var(--admin-muted);
}

@media (max-width: 900px) {
    .admin-page-header {
        flex-direction: column;
    }

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

.admin-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}

.admin-page-header h2 {
    margin: 0 0 10px;
    font-size: 34px;
    line-height: 1.05;
    letter-spacing: -0.045em;
}

.admin-page-header p:last-child {
    max-width: 760px;
    margin: 0;
    color: var(--admin-muted);
    line-height: 1.65;
    font-size: 16px;
}

.admin-actions {
    flex-shrink: 0;
}

.admin-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0 18px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 800;
    text-decoration: none;
    transition: 0.2s ease;
    border: 1px solid transparent;
}

.admin-button.primary {
    background: var(--admin-primary);
    color: #fff;
    box-shadow: 0 10px 20px rgba(34, 55, 43, 0.16);
}

.admin-button.primary:hover {
    background: var(--admin-primary-hover);
    transform: translateY(-1px);
}

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

.stat-card {
    background: var(--admin-card);
    border: 1px solid var(--admin-border);
    border-radius: 22px;
    padding: 22px;
    box-shadow: 0 16px 45px rgba(0, 0, 0, 0.035);
}

.stat-label {
    display: block;
    color: var(--admin-muted);
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 10px;
}

.stat-card strong {
    display: block;
    font-size: 36px;
    line-height: 1;
    letter-spacing: -0.05em;
    color: var(--admin-text);
}

.admin-panel {
    background: var(--admin-card);
    border: 1px solid var(--admin-border);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.04);
}

.admin-panel-header {
    padding: 22px 24px;
    border-bottom: 1px solid var(--admin-border);
    background: #fcfbf8;
}

.admin-panel-header h3 {
    margin: 0;
    font-size: 20px;
    letter-spacing: -0.03em;
}

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

.admin-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 980px;
}

.admin-table thead th {
    background: #f8f6f2;
    color: var(--admin-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 800;
    padding: 16px 18px;
    border-bottom: 1px solid var(--admin-border);
    text-align: left;
    white-space: nowrap;
}

.admin-table tbody td {
    padding: 18px;
    border-bottom: 1px solid #ece6dc;
    vertical-align: middle;
    font-size: 14px;
    background: #fff;
}

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

.admin-table tbody tr:hover td {
    background: #fcfbf8;
}

.admin-table td strong {
    font-size: 15px;
    letter-spacing: -0.02em;
}

.admin-table code {
    background: #f3efe8;
    border: 1px solid #e5ddd0;
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 13px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.status-badge.published {
    background: #e7f6ed;
    color: #17643a;
    border: 1px solid #cfead9;
}

.status-badge.draft {
    background: #fff6df;
    color: #8a5b00;
    border: 1px solid #f3e4ae;
}

.text-right {
    text-align: right !important;
    white-space: nowrap;
}

.table-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 12px;
    margin-left: 8px;
    border-radius: 999px;
    background: #f4f1eb;
    color: var(--admin-primary);
    font-weight: 800;
    text-decoration: none;
    border: 1px solid #e6ded2;
    transition: 0.2s ease;
}

.table-action:hover {
    background: #ebe6dc;
    text-decoration: none;
}

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

.empty-state {
    padding: 46px 24px;
    text-align: center;
}

.empty-state h3 {
    margin: 0 0 8px;
    font-size: 22px;
    letter-spacing: -0.03em;
}

.empty-state p {
    margin: 0;
    color: var(--admin-muted);
}

@media (max-width: 900px) {
    .admin-page-header {
        flex-direction: column;
    }

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

.notice {
    margin-bottom: 22px;
    padding: 14px 16px;
    border-radius: 16px;
    font-weight: 700;
    border: 1px solid transparent;
}

.notice-success {
    background: #e7f6ed;
    color: #17643a;
    border-color: #cfead9;
}

.notice-error {
    background: #fff1f1;
    color: #9f1d1d;
    border-color: rgba(159, 29, 29, 0.18);
}

.form-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 24px;
    align-items: start;
}

.form-main {
    display: grid;
    gap: 24px;
}

.form-sidebar {
    position: sticky;
    top: 24px;
}

.form-card {
    background: var(--admin-card);
    border: 1px solid var(--admin-border);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.04);
}

.form-card-header {
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--admin-border);
}

.form-card-header h3 {
    margin: 0 0 8px;
    font-size: 21px;
    letter-spacing: -0.03em;
}

.form-card-header p {
    margin: 0;
    color: var(--admin-muted);
    line-height: 1.55;
    font-size: 14px;
}

.form-field {
    display: grid;
    gap: 8px;
    margin-bottom: 20px;
}

.form-field:last-child {
    margin-bottom: 0;
}

.form-field label {
    font-size: 14px;
    font-weight: 800;
}

.form-field input[type="text"],
.form-field input[type="url"],
.form-field textarea,
.form-field select {
    width: 100%;
    border: 1px solid var(--admin-border);
    border-radius: 14px;
    padding: 12px 14px;
    font-size: 15px;
    font-family: inherit;
    color: var(--admin-text);
    background: #fff;
    outline: none;
}

.form-field input[type="text"],
.form-field input[type="url"],
.form-field select {
    min-height: 46px;
}

.form-field textarea {
    resize: vertical;
    line-height: 1.6;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
    border-color: var(--admin-primary);
    box-shadow: 0 0 0 4px rgba(34, 55, 43, 0.12);
}

.slug-row {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    border: 1px solid var(--admin-border);
    border-radius: 14px;
    background: #fff;
    overflow: hidden;
}

.slug-row span {
    padding: 0 0 0 14px;
    color: var(--admin-muted);
    font-weight: 800;
}

.slug-row input {
    border: 0 !important;
    box-shadow: none !important;
}

.field-help {
    margin: 0;
    color: var(--admin-muted);
    font-size: 13px;
    line-height: 1.5;
}

.field-error {
    margin: 0;
    color: #9f1d1d;
    font-size: 13px;
    font-weight: 700;
}

.checkbox-field label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: var(--admin-text);
}

.checkbox-field input {
    width: 18px;
    height: 18px;
    accent-color: var(--admin-primary);
}

.form-actions {
    display: grid;
    gap: 12px;
    margin-top: 22px;
}

.admin-button.secondary {
    background: #f4f1eb;
    color: var(--admin-primary);
    border-color: #e6ded2;
}

.admin-button.secondary:hover {
    background: #ebe6dc;
}

.admin-button.full-width {
    width: 100%;
}

button.admin-button {
    border: 1px solid transparent;
    cursor: pointer;
    font-family: inherit;
}

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

    .form-sidebar {
        position: static;
    }
}

.mini-card {
    margin-top: 18px;
}

.mini-card h3 {
    margin: 0 0 8px;
    font-size: 19px;
    letter-spacing: -0.03em;
}

.mini-card p {
    margin: 0 0 16px;
    color: var(--admin-muted);
    line-height: 1.5;
    font-size: 14px;
}

.sections-list {
    display: grid;
    gap: 14px;
    padding: 22px;
}

.section-admin-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 22px;
    padding: 22px;
    background: #fff;
    border: 1px solid var(--admin-border);
    border-radius: 18px;
}

.section-admin-card h3 {
    margin: 8px 0 8px;
    font-size: 22px;
    letter-spacing: -0.035em;
}

.section-admin-card p {
    margin: 0;
    color: var(--admin-muted);
    line-height: 1.55;
}

.section-type {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 9px;
    border-radius: 999px;
    background: #f3efe8;
    color: var(--admin-primary);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.section-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--admin-muted);
    font-size: 13px;
    white-space: nowrap;
}

@media (max-width: 900px) {
    .section-admin-card {
        flex-direction: column;
    }

    .section-meta {
        flex-wrap: wrap;
    }
}

.section-admin-card.is-disabled {
    opacity: 0.58;
}

.section-actions {
    display: grid;
    gap: 14px;
    justify-items: end;
}

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

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

button.table-action {
    font-family: inherit;
    cursor: pointer;
}

.table-action.danger {
    color: #9f1d1d;
    background: #fff1f1;
    border-color: rgba(159, 29, 29, 0.22);
}

.table-action.danger:hover {
    background: #ffe3e3;
}

.table-action.compact {
    padding-left: 10px;
    padding-right: 10px;
    min-height: 32px;
    font-size: 13px;
}

/* =========================================================
   Admin - Page Builder Sections
   ========================================================= */

.section-card {
    margin-top: 20px;
    padding: 24px;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.05);
}

.section-card + .section-card {
    margin-top: 24px;
}

.section-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
    padding-bottom: 16px;
    border-bottom: 1px solid #eef0f3;
}

.section-card-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-card-title strong {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
}

.section-type-label {
    display: inline-flex;
    align-items: center;
    padding: 4px 9px;
    border-radius: 999px;
    background: #f3f4f6;
    color: #6b7280;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
}

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

.section-card textarea {
    min-height: 180px;
    resize: vertical;
}

.section-card .admin-button.danger {
    border-color: #fecaca;
    background: #fff1f2;
    color: #b91c1c;
}

.section-card .admin-button.danger:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
}

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

    .section-card-header {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* Allineamento campi nelle sezioni modulari */
.section-card .form-row {
    align-items: start;
}

.section-card .form-row .form-field {
    margin-top: 0;
    display: flex;
    flex-direction: column;
}

.section-card .form-row .form-field label {
    margin-bottom: 10px;
}

.section-card .form-row select {
    height: 58px;
}

.section-add-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* Allineamento uniforme input/select nelle sezioni modulari */
.section-card .form-row {
    align-items: start;
}

.section-card .form-row .form-field {
    margin: 0 !important;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.section-card .form-row .form-field label {
    margin: 0 0 10px 0 !important;
    line-height: 1.2;
}

.section-card .form-row input,
.section-card .form-row select {
    height: 58px;
    margin: 0 !important;
    box-sizing: border-box;
}

.section-card .form-row textarea {
    margin: 0 !important;
    box-sizing: border-box;
}

.section-card .form-row {
    margin-bottom: 35px;
}

/* =========================================================
   Admin - Template Guide
   ========================================================= */

.template-guide {
    margin-top: 14px;
}

.template-guide-inner {
    display: none;
    padding: 18px;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    background: #f9fafb;
    margin-bottom: 35px;
}

.template-guide-inner.is-active {
    display: block;
}

.template-guide-inner h4 {
    margin: 0 0 8px;
    font-size: 0.98rem;
    font-weight: 700;
    color: #111827;
}

.template-guide-inner p {
    margin: 0 0 14px;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #6b7280;
}

.template-guide-inner ul {
    margin: 0;
    padding-left: 18px;
}

.template-guide-inner li {
    margin-bottom: 6px;
    font-size: 0.9rem;
    line-height: 1.45;
    color: #374151;
}

.template-guide-inner li:last-child {
    margin-bottom: 0;
}

.template-actions {
    margin-top: 14px;
}

.template-actions .field-help {
    margin-top: 8px;
}

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

.feature-card-admin {
    padding: 18px;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    background: #f9fafb;
}

.feature-card-admin h4 {
    margin: 0 0 14px;
    font-size: 0.95rem;
    color: #111827;
}

@media (max-width: 1100px) {
    .feature-cards-admin-grid {
        grid-template-columns: 1fr;
    }
}