:root {
    --bg: #f4f6f2;
    --panel: #ffffff;
    --panel-muted: #eef3eb;
    --text: #1f2a21;
    --muted: #68736b;
    --line: #d9e1da;
    --primary: #21543d;
    --primary-soft: #d9ebe2;
    --danger: #b33f3f;
    --danger-soft: #f6dddd;
    --success: #217046;
    --success-soft: #dff3e8;
    --shadow: 0 14px 34px rgba(31, 42, 33, 0.08);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text);
    overflow-x: hidden;
    background:
        radial-gradient(circle at top right, rgba(33, 84, 61, 0.08), transparent 28%),
        linear-gradient(180deg, #fbfcfa 0%, var(--bg) 100%);
}

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

code {
    padding: 0.15rem 0.4rem;
    border-radius: 8px;
    background: var(--panel-muted);
    font-size: 0.92em;
}

img {
    max-width: 100%;
    display: block;
}

h1,
h2,
h3,
p {
    margin: 0;
}

.admin-shell,
.content-shell,
.panel,
.subpanel,
.section-heading > *,
.form-grid > *,
.button-row > *,
.field,
.data-table td,
.data-table th {
    min-width: 0;
}

.admin-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
}

.sidebar {
    padding: 2rem 1.5rem;
    background: #173728;
    color: #f2f7f3;
}

.sidebar__brand {
    display: grid;
    gap: 0.35rem;
    margin-bottom: 2rem;
}

.sidebar__eyebrow {
    color: rgba(242, 247, 243, 0.72);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sidebar__nav {
    display: grid;
    gap: 0.6rem;
}

.nav-link {
    display: block;
    padding: 0.9rem 1rem;
    border-radius: 14px;
    color: rgba(242, 247, 243, 0.92);
    background: transparent;
    transition: background 0.2s ease, transform 0.2s ease;
}

.nav-link:hover,
.nav-link.is-active {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(2px);
}

.admin-shell {
    display: grid;
    grid-template-rows: auto 1fr;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    padding: 2rem;
}

.topbar__title {
    font-size: 2rem;
    line-height: 1.1;
}

.topbar__subtitle,
.table-muted,
.empty-state,
.auth-card__hint {
    color: var(--muted);
}

.topbar__meta {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar__user {
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.content-shell,
.login-shell {
    padding: 0 2rem 2rem;
}

.content-shell {
    width: 100%;
    max-width: 1380px;
    margin: 0 auto;
}

.stack-md,
.stack-lg,
.stack-xl {
    display: grid;
}

.stack-md {
    gap: 1rem;
}

.stack-lg {
    gap: 1.5rem;
}

.stack-xl {
    gap: 2rem;
}

.panel,
.subpanel,
.stat-card,
.shortcut-card,
.auth-card {
    background: var(--panel);
    border: 1px solid rgba(217, 225, 218, 0.85);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel,
.subpanel,
.auth-card {
    padding: 1.5rem;
}

.panel-error {
    border-color: rgba(179, 63, 63, 0.25);
    background: #fff8f8;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.section-heading p,
.subpanel__header,
.feature-preview__item p {
    color: var(--muted);
}

.section-heading h2,
.section-heading h3 {
    line-height: 1.18;
}

.grid-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1.4rem;
    display: grid;
    gap: 0.5rem;
}

.stat-card__label {
    color: var(--muted);
    font-size: 0.92rem;
}

.stat-card__value {
    font-size: 2.1rem;
}

.stat-card__meta {
    color: var(--primary);
    font-weight: 600;
}

.dashboard-links,
.feature-preview__grid,
.feature-grid {
    display: grid;
    gap: 1rem;
}

.dashboard-links {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.shortcut-card {
    padding: 1.25rem;
    display: grid;
    gap: 0.6rem;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.shortcut-card:hover {
    transform: translateY(-2px);
    border-color: rgba(33, 84, 61, 0.25);
}

.feature-preview__grid,
.feature-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.feature-preview__item {
    padding: 1rem;
    border-radius: 16px;
    background: var(--panel-muted);
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 880px;
}

.data-table th,
.data-table td {
    padding: 1rem 0.8rem;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
    text-align: left;
}

.data-table th {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.field {
    display: grid;
    gap: 0.5rem;
}

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

.field-checkbox {
    align-content: end;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
textarea,
input[type="file"] {
    width: 100%;
    padding: 0.85rem 0.95rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

textarea {
    resize: vertical;
    min-height: 110px;
}

input:focus,
textarea:focus {
    outline: 2px solid rgba(33, 84, 61, 0.18);
    border-color: rgba(33, 84, 61, 0.45);
}

.form-grid {
    display: grid;
    gap: 1rem;
}

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

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

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    align-items: center;
}

.button-row-spread {
    justify-content: space-between;
}

.btn {
    border: 0;
    border-radius: 999px;
    padding: 0.8rem 1.1rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

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

.btn-secondary {
    background: #dde6df;
    color: var(--text);
}

.btn-light {
    background: var(--panel-muted);
    color: var(--text);
}

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

.btn-sm {
    padding: 0.55rem 0.85rem;
    font-size: 0.9rem;
}

.btn-block {
    width: 100%;
}

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

.alert-success {
    background: var(--success-soft);
    border-color: rgba(33, 112, 70, 0.18);
    color: var(--success);
}

.alert-error {
    background: var(--danger-soft);
    border-color: rgba(179, 63, 63, 0.18);
    color: #8d2e2e;
}

.error-list {
    margin: 0;
    padding-left: 1.1rem;
}

.status,
.badge,
.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    font-size: 0.86rem;
    font-weight: 600;
}

.status-active,
.pill {
    background: var(--primary-soft);
    color: var(--primary);
}

.status-inactive {
    background: #ece9e9;
    color: #6f6666;
}

.badge {
    background: var(--panel-muted);
    color: var(--text);
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text);
    font-weight: 500;
}

.page-editor {
    gap: 1.5rem;
}

.page-editor__form {
    gap: 1.5rem;
}

.page-editor__panel {
    overflow: clip;
}

.page-editor__heading {
    gap: 1.25rem;
}

.page-editor__intro {
    display: grid;
    gap: 0.45rem;
}

.page-editor__actions {
    justify-content: flex-end;
}

.page-editor__blocks,
.page-editor__links {
    gap: 1rem;
}

.editor-variables {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
}

.editor-variables__label {
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 600;
}

.editor-variable-chip code {
    display: inline-flex;
    align-items: center;
}

.link-editor-form {
    gap: 1rem;
}

.link-editor-feedback {
    gap: 0.75rem;
}

.link-editor-form__footer {
    padding-top: 0.2rem;
}

.link-preview--stacked li,
.link-preview--stacked a,
.data-table a {
    overflow-wrap: anywhere;
}

.note-editor,
.note-editor.note-frame,
.page-editor textarea[data-editor="summernote"] {
    width: 100% !important;
    max-width: 100% !important;
}

.note-editor.note-frame {
    border-radius: 14px !important;
    overflow: hidden;
}

.note-editor .note-toolbar,
.note-editor .note-statusbar,
.note-editor .note-editing-area,
.note-editor .note-editable {
    max-width: 100%;
}

.note-editor .note-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.note-editor .note-btn-group {
    margin-right: 0.15rem;
}

.note-editor .note-editable {
    font-family: Segoe UI, Tahoma, sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

.note-editor .note-statusbar .note-resizebar {
    display: none !important;
}

.thumb {
    width: 72px;
    height: 48px;
    object-fit: contain;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #fff;
    padding: 0.35rem;
}

.thumb-large {
    width: 140px;
    height: 90px;
}

.image-preview {
    padding: 1rem;
    border: 1px dashed var(--line);
    border-radius: 14px;
    display: inline-flex;
    background: #fafcf9;
}

.link-preview {
    margin: 0;
    padding-left: 1rem;
    display: grid;
    gap: 0.6rem;
}

.login-layout {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.login-shell {
    width: min(100%, 480px);
}

.auth-card {
    padding: 2rem;
}

.auth-card__header {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.empty-state {
    padding: 1rem 0;
}

@media (max-width: 1080px) {
    .grid-cards,
    .dashboard-links,
    .feature-preview__grid,
    .feature-grid,
    .form-grid-3 {
        grid-template-columns: 1fr;
    }

    .form-grid-2 {
        grid-template-columns: 1fr;
    }
}

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

    .sidebar {
        padding: 1.25rem;
    }

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

    .topbar,
    .content-shell {
        padding: 1.25rem;
    }

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

    .panel,
    .subpanel,
    .auth-card {
        padding: 1.2rem;
    }

    .page-editor__actions {
        width: 100%;
        justify-content: flex-start;
    }

    .tox .tox-toolbar-overlord,
    .tox .tox-toolbar__primary,
    .tox .tox-toolbar {
        overflow-x: auto;
    }
}

@media (max-width: 640px) {
    .content-shell,
    .login-shell {
        padding: 0 0.9rem 1rem;
    }

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

    .section-heading,
    .button-row-spread,
    .topbar__meta {
        flex-direction: column;
        align-items: flex-start;
    }

    .btn,
    .button-row form,
    .button-row a {
        width: 100%;
    }

    .button-row {
        align-items: stretch;
    }

    .checkbox-inline {
        align-items: flex-start;
    }

    .topbar {
        padding: 1rem 0.9rem;
    }

    .topbar__title {
        font-size: 1.55rem;
    }

    .panel,
    .subpanel,
    .auth-card {
        padding: 1rem;
        border-radius: 16px;
    }

    .editor-variables {
        align-items: flex-start;
    }

    .data-table {
        min-width: 0;
    }

    .data-table thead {
        display: none;
    }

    .data-table,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block;
        width: 100%;
    }

    .data-table tbody {
        display: grid;
        gap: 0.9rem;
    }

    .data-table tr {
        padding: 1rem;
        border: 1px solid var(--line);
        border-radius: 16px;
        background: var(--panel);
        box-shadow: var(--shadow);
    }

    .data-table td {
        display: grid;
        gap: 0.35rem;
        padding: 0.75rem 0;
    }

    .data-table td:first-child {
        padding-top: 0;
    }

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

    .data-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 0.78rem;
        font-weight: 700;
        letter-spacing: 0.06em;
        text-transform: uppercase;
    }
}
