* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    color: #1f2933;
    background: #f4f7f9;
    font-family: "Inter", "Segoe UI", Arial, sans-serif;
}

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

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

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 80% 12%, rgba(249, 165, 26, .22), transparent 28%),
        linear-gradient(135deg, #ffffff, #edf8fb);
}

.login-card {
    width: min(440px, 100%);
    padding: 34px;
    border: 1px solid rgba(31, 41, 51, .1);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 28px 80px rgba(31, 41, 51, .14);
}

.login-card img {
    width: 210px;
    margin-bottom: 24px;
}

.login-card h1 {
    margin: 0 0 8px;
    font-size: 34px;
}

.login-card p,
.dashboard-header p,
.intro-panel p {
    color: #66727f;
}

label {
    display: grid;
    gap: 8px;
    color: #3b4753;
    font-weight: 800;
}

input,
textarea,
select {
    min-width: 0;
    width: 100%;
    border: 1px solid rgba(31, 41, 51, .16);
    border-radius: 8px;
    color: #1f2933;
    background: #fff;
    font: inherit;
}

textarea.has-error {
    border-color: #f15a24;
    box-shadow: 0 0 0 3px rgba(241, 90, 36, .12);
}

input,
select {
    min-height: 46px;
    padding: 0 14px;
}

textarea {
    min-height: 380px;
    padding: 16px;
    resize: vertical;
    font-family: "Cascadia Code", Consolas, monospace;
    font-size: 13px;
    line-height: 1.55;
}

form {
    display: grid;
    gap: 18px;
}

button,
.header-actions a,
.logout,
.format-btn,
.secondary-btn,
.danger-btn,
.icon-btn {
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    padding: 11px 16px;
    font-weight: 900;
    cursor: pointer;
}

button,
.header-actions a {
    color: #fff;
    background: #008fc7;
}

.secondary-btn {
    color: #001e60;
    background: #e9f4f8;
}

.danger-btn {
    color: #fff;
    background: #f15a24;
}

.icon-btn {
    min-width: 42px;
    color: #1f2933;
    background: #eef3f6;
}

.header-actions a {
    display: inline-flex;
    align-items: center;
}

.format-btn {
    color: #1f2933;
    background: #eef3f6;
}

.alert,
.status {
    padding: 14px 16px;
    border-radius: 8px;
    font-weight: 800;
}

.alert,
.status.error {
    color: #8a2a12;
    background: #fff0ea;
}

.status.success {
    color: #075d35;
    background: #e8f8ef;
}

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

.sidebar {
    width: 280px;
    min-width: 0;
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    top: 0;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 24px;
    color: rgba(255, 255, 255, .82);
    background: #111820;
    overflow-y: auto;
}

.admin-brand img {
    width: 195px;
    margin-bottom: 26px;
}

.sidebar nav {
    display: grid;
    gap: 6px;
}

.sidebar nav a,
.logout {
    padding: 10px 12px;
    border-radius: 8px;
}

.sidebar nav a {
    display: grid;
    gap: 2px;
}

.sidebar nav a span {
    color: rgba(255, 255, 255, .52);
    font-size: 12px;
    font-weight: 700;
}

.sidebar nav a:hover,
.sidebar nav a.is-active {
    color: #fff;
    background: rgba(255, 255, 255, .08);
}

.sidebar nav a.is-active {
    box-shadow: inset 4px 0 0 #f15a24;
}

.logout {
    margin-top: auto;
    color: #fff;
    background: rgba(241, 90, 36, .9);
    text-align: center;
}

.dashboard {
    grid-column: 2;
    min-width: 0;
    max-width: 100%;
    width: min(1240px, calc(100% - 42px));
    margin: 0 auto;
    padding: 34px 0 70px;
}

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

.dashboard-header h1 {
    margin: 0;
    font-size: 42px;
}

.dashboard-stats,
.admin-hub,
.quick-strip,
.recent-grid,
.media-library {
    display: grid;
    gap: 16px;
}

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

.dashboard-stats article,
.admin-hub a,
.quick-strip a,
.recent-panel,
.media-library article,
.empty-state {
    border: 1px solid rgba(31, 41, 51, .1);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 18px 40px rgba(31, 41, 51, .06);
}

.dashboard-stats article {
    padding: 22px;
}

.dashboard-stats span,
.admin-hub span,
.quick-strip span {
    color: #66727f;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.dashboard-stats strong {
    display: block;
    margin: 8px 0 12px;
    color: #001e60;
    font-size: 42px;
}

.dashboard-stats a,
.admin-hub em,
.quick-strip strong,
.recent-grid a,
.media-library a {
    color: #001e60;
    font-weight: 900;
}

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

.admin-hub a,
.quick-strip a {
    display: grid;
    gap: 8px;
    padding: 22px;
}

.admin-hub strong {
    color: #001e60;
    font-size: 24px;
}

.admin-hub em {
    font-style: normal;
}

.quick-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 16px;
}

.section-tabs {
    position: sticky;
    top: 0;
    z-index: 4;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    padding: 10px;
    border: 1px solid rgba(31, 41, 51, .1);
    border-radius: 8px;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(14px);
}

.section-tabs a {
    padding: 9px 12px;
    border-radius: 8px;
    color: #001e60;
    background: #edf6fa;
    font-weight: 900;
}

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

.recent-grid div {
    display: grid;
    gap: 10px;
}

.recent-grid h3 {
    margin: 0;
}

.media-library {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.media-library article,
.empty-state {
    padding: 16px;
}

.media-library img,
.file-tile {
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 8px;
    background: #eef3f6;
    object-fit: cover;
}

.file-tile {
    display: grid;
    place-items: center;
    color: #001e60;
    font-size: 24px;
    font-weight: 900;
}

.media-library strong {
    display: block;
    min-height: 44px;
    margin: 12px 0;
    word-break: break-word;
}

.media-library input {
    margin-bottom: 10px;
    font-size: 12px;
}

.kicker {
    margin: 0 0 8px;
    color: #f15a24;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.panel {
    min-width: 0;
    margin-bottom: 18px;
    padding: 24px;
    border: 1px solid rgba(31, 41, 51, .1);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 18px 40px rgba(31, 41, 51, .06);
}

.cms-app {
    display: grid;
    gap: 18px;
}

.intro-panel,
.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.panel h2 {
    margin: 0;
}

.core-grid {
    width: min(520px, 100%);
    display: grid;
    grid-template-columns: 1fr 170px;
    gap: 14px;
}

.form-grid,
.localized-grid,
.color-grid,
.media-row {
    display: grid;
    gap: 14px;
}

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

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

.localized,
.media-field,
.list-editor,
.field.wide {
    grid-column: 1 / -1;
}

.localized {
    display: grid;
    gap: 10px;
}

.localized > strong,
.media-field > strong,
.file-field > strong,
.list-editor > strong {
    color: #3b4753;
    font-weight: 900;
}

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

.cms-card {
    min-width: 0;
    margin-top: 16px;
    padding: 18px;
    border: 1px solid rgba(31, 41, 51, .1);
    border-radius: 8px;
    background: #fbfdfe;
}

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

.card-title h3 {
    margin: 0;
    color: #001e60;
}

.card-tools,
.panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.collection + .collection {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid rgba(31, 41, 51, .1);
}

.collection-items {
    display: grid;
    gap: 14px;
}

.media-row {
    grid-template-columns: minmax(0, 1fr) minmax(180px, .6fr) auto;
    align-items: center;
    margin-top: 10px;
}

.media-preview {
    max-width: 240px;
    max-height: 140px;
    margin-top: 12px;
    padding: 8px;
    border: 1px solid rgba(31, 41, 51, .12);
    border-radius: 8px;
    background: #fff;
    object-fit: contain;
}

.file-preview {
    display: inline-flex;
    width: fit-content;
    margin-top: 10px;
    color: #001e60;
    font-weight: 900;
}

.attachment-editor {
    min-width: 0;
    padding: 16px;
    border: 1px dashed rgba(0, 143, 199, .35);
    border-radius: 8px;
    background: #f6fbfd;
}

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

.attachment-heading p {
    margin: 4px 0 0;
    color: #66727f;
    font-size: 13px;
}

.attachment-items {
    display: grid;
    gap: 12px;
}

.attachment-items .cms-card {
    background: #fff;
}

.list-editor p {
    margin: 4px 0 10px;
    color: #66727f;
    font-size: 13px;
}

.json-editor {
    min-height: 520px;
    margin-bottom: 12px;
    font-family: "Cascadia Code", Consolas, monospace;
}

.field input[type="checkbox"] {
    width: 22px;
    min-height: 22px;
}

.field:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status {
    position: sticky;
    top: 14px;
    z-index: 5;
    margin-bottom: 18px;
}

@media (max-width: 900px) {
    .admin-page {
        display: block;
    }

    .sidebar {
        position: static;
        width: 100%;
        max-width: 100%;
        height: auto;
        padding: 16px 14px;
        overflow: hidden;
    }

    .admin-brand img {
        width: min(170px, 58vw);
        margin-bottom: 14px;
    }

    .sidebar nav {
        display: flex;
        gap: 8px;
        margin-inline: -4px;
        padding: 0 4px 8px;
        overflow-x: auto;
        overscroll-behavior-inline: contain;
        scrollbar-width: thin;
        scroll-snap-type: x proximity;
    }

    .sidebar nav a {
        flex: 0 0 150px;
        min-width: 0;
        scroll-snap-align: start;
        background: rgba(255, 255, 255, .05);
    }

    .sidebar nav a span {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .sidebar nav a.is-active {
        box-shadow: inset 0 -4px 0 #f15a24;
    }

    .logout {
        width: 100%;
        margin-top: 10px;
    }

    .dashboard-stats,
    .admin-hub,
    .quick-strip,
    .recent-grid,
    .media-library {
        grid-template-columns: 1fr;
    }

    .dashboard-header,
    .intro-panel,
    .panel-heading {
        display: block;
    }

    .dashboard {
        width: 100%;
        padding: 20px 12px 54px;
    }

    .dashboard-header h1 {
        font-size: clamp(30px, 9vw, 40px);
        overflow-wrap: anywhere;
    }

    .dashboard-header p,
    .panel-heading p,
    .intro-panel p {
        overflow-wrap: anywhere;
    }

    .header-actions,
    .core-grid,
    .form-grid,
    .localized-grid,
    .color-grid,
    .media-row {
        grid-template-columns: 1fr;
        margin-top: 16px;
    }

    .header-actions {
        display: grid;
    }

    .section-tabs {
        top: 0;
        flex-wrap: nowrap;
        margin-inline: -4px;
        overflow-x: auto;
        overscroll-behavior-inline: contain;
        scrollbar-width: thin;
    }

    .section-tabs a {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .panel {
        padding: 16px;
    }

    .cms-card {
        padding: 14px;
        overflow: hidden;
    }

    .card-title,
    .attachment-heading {
        display: grid;
        align-items: start;
        gap: 12px;
    }

    .card-tools,
    .panel-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .card-tools button,
    .panel-actions button {
        width: 100%;
        padding-inline: 10px;
        white-space: nowrap;
    }

    textarea {
        min-height: 260px;
    }
}

@media (max-width: 380px) {
    .sidebar {
        padding-inline: 12px;
    }

    .sidebar nav a {
        flex-basis: 132px;
    }

    .dashboard {
        padding-inline: 10px;
    }

    .panel {
        padding: 14px;
    }

    .card-tools,
    .panel-actions {
        grid-template-columns: 1fr;
    }
}
