/* Base */
:root {
    --bg: #e9f1f3;
    --bg-gradient: linear-gradient(140deg, #e6eff4 0%, #e9f4ef 55%, #eef4ea 100%);
    --surface: #ffffff;
    --surface-soft: #f1f7f6;
    --text: #1e2a33;
    --muted: #7c8894;
    --line: #e0e8ec;
    --primary: #2ba45c;
    --primary-dark: #22834a;
    --primary-soft: rgba(43, 164, 92, 0.12);
    --danger: #d1462f;
    --success: #2ba45c;
    --accent: #e8752a;
    --shadow: 0 16px 40px rgba(30, 60, 80, 0.08);

    /* Typography scale — 5 sizes only */
    --fs-xl: 30px;   /* page & hero titles */
    --fs-lg: 22px;   /* section / panel titles */
    --fs-md: 18px;   /* brand, sub-headings */
    --fs-base: 15px; /* body */
    --fs-sm: 13px;   /* labels, hints, table head */

    /* Fonts */
    --font-display: "Bricolage Grotesque", "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
    --font-body: "Plus Jakarta Sans", Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;

    /* Corner radius */
    --radius-sm: 10px;   /* inputs, small controls */
    --radius: 12px;      /* generic */
    --radius-lg: 20px;   /* cards, panels */
    --radius-pill: 999px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    background-image: var(--bg-gradient);
    background-attachment: fixed;
    font-family: var(--font-body);
    font-size: var(--fs-base);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

button,
input {
    font: inherit;
}

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

/* Display font for headings & brand */
h1,
h2,
h3,
.brand,
.login-intro h1 {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Buttons */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-weight: 700;
    font-size: var(--fs-sm);
    transition: transform 0.06s ease, border-color 0.15s ease, background 0.15s ease;
}

.button:active {
    transform: scale(0.98);
}

.button:hover {
    border-color: #b7c4d2;
}

.button-primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #ffffff;
}

.button-primary:hover {
    border-color: var(--primary-dark);
    background: var(--primary-dark);
}

.button-ghost {
    background: transparent;
}

.button-danger {
    border-color: #f5c2bd;
    color: var(--danger);
}

.button-small {
    min-height: 34px;
    padding: 0 12px;
    font-size: var(--fs-sm);
}

.button-full {
    width: 100%;
}

/* Auth */
.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: var(--bg);
    background-image: var(--bg-gradient);
}

.auth-wrap {
    width: min(100%, 420px);
}

.login-panel {
    padding: 32px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: var(--shadow);
}

.login-intro {
    display: grid;
    gap: 8px;
    margin-bottom: 28px;
}

.login-intro h1 {
    font-size: var(--fs-xl);
}

.login-intro p,
.eyebrow,
.metric-card span {
    color: var(--muted);
    font-size: var(--fs-sm);
}

.brand-mark {
    display: inline-grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: var(--radius);
    background: var(--primary);
    color: #ffffff;
    font-weight: 800;
    font-size: var(--fs-md);
}

/* App Layout */
.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px;
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-right: 1px solid var(--line);
    color: var(--text);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    font-size: var(--fs-md);
}

.nav {
    display: grid;
    gap: 8px;
    margin-top: 32px;
}

.nav-link {
    padding: 12px 14px;
    border-radius: var(--radius);
    color: #5c6874;
    font-weight: 700;
}

.nav-link:hover,
.nav-link.is-active {
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.workspace {
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 24px 32px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.topbar h1 {
    font-size: var(--fs-xl);
}

.content {
    display: grid;
    gap: 24px;
    padding: 32px;
}

/* Panels */
.panel,
.metric-card {
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: var(--shadow);
}

.panel {
    padding: 24px;
}

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

.panel-header h2 {
    margin-top: 4px;
    font-size: var(--fs-lg);
}

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

.metric-card {
    display: grid;
    gap: 8px;
    padding: 22px;
}

.metric-card strong {
    font-size: var(--fs-lg);
}

.alert {
    padding: 14px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface);
}

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

/* Forms */
.form {
    display: grid;
    gap: 18px;
}

.form-panel {
    max-width: 760px;
}

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

.field {
    display: grid;
    gap: 8px;
}

.field label,
.check {
    font-weight: 700;
    font-size: var(--fs-sm);
}

.field input {
    width: 100%;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
}

.field input:focus {
    outline: 3px solid var(--primary-soft);
    border-color: var(--primary);
}

.field-error {
    color: var(--danger);
    font-size: var(--fs-sm);
}

.check {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Tables */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
}

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

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

.table th {
    background: var(--surface-soft);
    color: var(--muted);
    font-size: var(--fs-sm);
    text-transform: uppercase;
}

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

.actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.actions-cell {
    text-align: right;
}

.pagination {
    margin-top: 18px;
}

.pagination nav {
    display: flex;
    gap: 8px;
}

/* Sidebar admin */
.nav-heading {
    margin: 18px 0 4px;
    padding: 0 14px;
    color: #7c8aa0;
    font-size: var(--fs-sm);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Dashboard */
.lead {
    color: var(--muted);
    max-width: 640px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.card {
    display: grid;
    gap: 8px;
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: var(--shadow);
    transition: transform 0.12s ease, border-color 0.15s ease;
}

.card-link:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.card-title {
    margin: 0;
    font-size: var(--fs-md);
    font-weight: 800;
}

.card-text {
    color: var(--muted);
    font-size: var(--fs-sm);
}

.card-cta {
    justify-self: start;
    margin-top: 4px;
    padding: 5px 14px;
    border-radius: var(--radius-pill);
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-weight: 700;
    font-size: var(--fs-sm);
}

/* Panels (content manager) */
.panel-title {
    margin-bottom: 20px;
    font-size: var(--fs-lg);
    font-weight: 800;
}

.panel-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
}

.panel + .panel {
    margin-top: 4px;
}

/* Fields (content manager) */
.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.field-label {
    font-weight: 700;
    font-size: var(--fs-sm);
}

.field-hint {
    color: var(--muted);
    font-size: var(--fs-sm);
}

.input {
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: var(--fs-base);
}

textarea.input {
    min-height: auto;
    resize: vertical;
    line-height: 1.5;
}

.input-code {
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: var(--fs-sm);
}

.input:focus {
    outline: 3px solid var(--primary-soft);
    border-color: var(--primary);
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: var(--fs-sm);
    font-weight: 700;
}

.media-thumb {
    max-width: 160px;
    max-height: 110px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    object-fit: cover;
}

.file-link {
    color: var(--primary);
    font-weight: 700;
    font-size: var(--fs-sm);
}

.alert-error {
    border-color: #f5c2bd;
    color: var(--danger);
    background: #fef3f2;
}

.alert-error ul {
    margin: 0;
    padding-left: 18px;
}

/* Collections */
.collection + .collection {
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--line);
}

.collection-title {
    margin-bottom: 16px;
    font-size: var(--fs-md);
    font-weight: 800;
}

.collection-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.collection-form {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
    flex: 1;
}

.collection-media,
.collection-fields {
    display: grid;
    gap: 8px;
}

.collection-actions {
    align-self: center;
}

.collection-add {
    padding: 14px;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
    grid-template-columns: 200px minmax(0, 1fr) auto;
    align-items: center;
}

.collection-add-label {
    grid-column: 1 / -1;
    font-weight: 800;
    font-size: var(--fs-sm);
    text-transform: uppercase;
    color: var(--muted);
}

.empty {
    color: var(--muted);
    font-size: var(--fs-sm);
    margin-bottom: 12px;
}

/* Responsive */
@media (max-width: 820px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
    }

    .topbar,
    .panel-header,
    .form-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .content,
    .topbar {
        padding: 22px;
    }

    .metrics-grid,
    .form-grid,
    .field-grid,
    .collection-form,
    .collection-add {
        grid-template-columns: 1fr;
    }

    .collection-item {
        flex-direction: column;
    }
}
