:root {
    --green: #0e3e2d;
    --green-2: #1f6b4a;
    --bg: #f4f7f5;
    --card: #ffffff;
    --line: #dce6e0;
    --text: #1a1f1c;
    --muted: #4d5a63;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

.admin-shell { display: flex; min-height: 100vh; position: relative; }
.mobile-bar { display: none; }
.nav-backdrop { display: none; }
.nav-close { display: none; }

.admin-nav {
    width: 268px;
    background: #fff;
    color: var(--text);
    border-right: 1px solid var(--line);
    padding: 20px 14px 16px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.admin-nav .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 8px 16px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--line);
    position: relative;
}
.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(145deg, var(--green-2), var(--green));
    color: #fff;
    font-weight: 800;
    font-size: 13px;
    letter-spacing: .02em;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.brand-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.brand-text strong {
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
}
.brand-text small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}
.admin-nav .nav-menu {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group-title {
    margin: 0 0 4px;
    padding: 0 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #7a8a82;
}
.admin-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #2c3a34;
    padding: 9px 10px;
    border-radius: 10px;
    text-decoration: none !important;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.25;
    transition: background .15s ease, color .15s ease;
}
.admin-nav .nav-link:hover {
    background: #eef5f1;
    color: var(--green);
}
.admin-nav .nav-link.active {
    background: #e4f2ea;
    color: var(--green);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--green-2);
}
.nav-ico {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: #6d7f76;
    display: grid;
    place-items: center;
}
.nav-ico svg { width: 18px; height: 18px; display: block; }
.admin-nav .nav-link:hover .nav-ico,
.admin-nav .nav-link.active .nav-ico { color: var(--green); }
.nav-label { min-width: 0; }

.nav-foot {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.nav-foot-link { color: var(--muted) !important; font-size: 13px !important; }
.nav-foot-link:hover { color: var(--green) !important; }

.admin-main { flex: 1; padding: 24px 28px; min-width: 0; }
.admin-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 12px; }
.admin-top h1 { margin: 0; font-size: 24px; }
.user { color: var(--muted); font-size: 14px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 18px;
}
.card .num { font-size: 28px; font-weight: 700; color: var(--green); }
.card .lbl { color: var(--muted); font-size: 13px; margin-top: 4px; }

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 18px;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

.btn {
    display: inline-block;
    background: var(--green);
    color: #fff !important;
    border: 0;
    border-radius: 8px;
    padding: 9px 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none !important;
    font-size: 14px;
}
.btn:hover { background: var(--green-2); }
.btn-secondary { background: #e8eee9; color: var(--text) !important; }
.btn-danger { background: #a33; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }

label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=datetime-local], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
    background: #fff;
}
textarea { min-height: 160px; resize: vertical; }
.grid-2, .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { min-width: 0; }
input[type=file] { width: 100%; font: inherit; }

.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.panel > table,
.admin-main > table { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 900px) {
    body.nav-lock { overflow: hidden; }

    .mobile-bar {
        display: flex;
        align-items: center;
        gap: 12px;
        position: sticky;
        top: 0;
        z-index: 40;
        background: #fff;
        border-bottom: 1px solid var(--line);
        padding: 10px 14px;
        min-height: 56px;
    }
    .mobile-bar-brand {
        display: flex;
        align-items: center;
        gap: 10px;
        min-width: 0;
    }
    .mobile-bar-brand .brand-mark {
        width: 34px;
        height: 34px;
        border-radius: 10px;
        font-size: 11px;
    }
    .mobile-bar-brand strong {
        font-size: 14px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .nav-toggle {
        width: 42px;
        height: 42px;
        border: 1px solid var(--line);
        border-radius: 10px;
        background: #fff;
        display: inline-flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 5px;
        padding: 0;
        cursor: pointer;
        flex-shrink: 0;
    }
    .nav-toggle span {
        display: block;
        width: 18px;
        height: 2px;
        background: var(--green);
        border-radius: 2px;
        transition: transform .2s ease, opacity .2s ease;
    }
    .admin-shell.nav-open .nav-toggle span:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }
    .admin-shell.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
    .admin-shell.nav-open .nav-toggle span:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    .nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(14, 30, 24, .45);
        z-index: 50;
        border: 0;
        padding: 0;
        margin: 0;
        cursor: pointer;
    }
    .nav-backdrop[hidden] { display: none !important; }

    .admin-shell { flex-direction: column; }
    .admin-nav {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(300px, 86vw);
        z-index: 60;
        border-right: 1px solid var(--line);
        box-shadow: 8px 0 28px rgba(0,0,0,.12);
        transform: translateX(-105%);
        transition: transform .22s ease;
        padding-top: 14px;
    }
    .admin-shell.nav-open .admin-nav { transform: translateX(0); }

    .nav-close {
        display: grid;
        place-items: center;
        margin-left: auto;
        width: 36px;
        height: 36px;
        border: 0;
        border-radius: 8px;
        background: #eef3f0;
        color: var(--text);
        font-size: 24px;
        line-height: 1;
        cursor: pointer;
        flex-shrink: 0;
    }
    .nav-close:hover { background: #e4f2ea; color: var(--green); }

    .admin-nav .brand { padding-right: 4px; }
    .admin-nav .nav-menu { padding-bottom: 20px; }
    .admin-nav .nav-link { min-height: 44px; padding: 11px 12px; }

    .admin-main { padding: 16px 14px 28px; }
    .admin-top {
        flex-wrap: wrap;
        align-items: flex-start;
        margin-bottom: 14px;
    }
    .admin-top h1 { font-size: 20px; line-height: 1.25; }
    .user { font-size: 13px; }

    .grid-2, .form-grid { grid-template-columns: 1fr; }
    .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
    .card { padding: 14px; }
    .card .num { font-size: 22px; }

    .panel { padding: 14px; }
    .toolbar { gap: 8px; }
    .btn { min-height: 42px; }
    .content-editor-actions {
        position: sticky;
        bottom: 0;
        background: rgba(244, 247, 245, .96);
        backdrop-filter: blur(6px);
        margin-left: -14px;
        margin-right: -14px;
        padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
        border-top: 1px solid var(--line);
    }
    .content-editor-actions .btn { flex: 1 1 auto; text-align: center; }
    .field-image .image-field { grid-template-columns: 1fr; }
    .image-actions { grid-column: 1; }
    .image-preview { width: 100%; max-width: 220px; height: 140px; }
    table { min-width: 560px; }
}

@media (max-width: 520px) {
    .cards { grid-template-columns: 1fr; }
    .mobile-bar-brand small { display: none; }
}

.flash { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; }
.flash-success { background: #e7f6ee; color: var(--green); }
.flash-error { background: #fde8e8; color: #8a1f1f; }

.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-published, .badge-new { background: #e7f6ee; color: var(--green); }
.badge-draft, .badge-contacted { background: #fff4d6; color: #8a6a00; }
.badge-closed { background: #ececec; color: #555; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 28px; }
.login-box h1 { margin: 0 0 8px; font-size: 22px; }
.muted { color: var(--muted); font-size: 14px; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.media-item { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.media-item img { width: 100%; height: 110px; object-fit: cover; display: block; background: #eee; }
.media-item .meta { padding: 8px; font-size: 11px; word-break: break-all; color: var(--muted); }

.field-block { margin-bottom: 16px; }
.field-help {
    margin: -4px 0 8px;
    font-size: 13px;
    color: var(--muted);
}

.editor-intro {
    margin-bottom: 16px;
    max-width: 720px;
}
.editor-intro p { margin: 0 0 8px; font-size: 15px; line-height: 1.45; }
.editor-intro .tip { font-size: 13px; }

.content-editor-form { max-width: 860px; }

.editor-section {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
}
.editor-section > summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    font-weight: 600;
    user-select: none;
    background: #f7faf8;
}
.editor-section > summary::-webkit-details-marker { display: none; }
.editor-section > summary::after {
    content: '';
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(-45deg);
    transition: transform .2s ease;
    flex-shrink: 0;
}
.editor-section[open] > summary::after { transform: rotate(45deg); }
.editor-section[open] > summary { border-bottom: 1px solid var(--line); background: #fff; }
.editor-section-title { font-size: 15px; }
.editor-section-count {
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    margin-left: auto;
    margin-right: 10px;
}
.editor-section-body {
    border: 0 !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 8px 18px 18px;
}

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

.content-editor-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
    align-items: center;
}
.content-editor-actions.sticky-bottom {
    position: sticky;
    bottom: 0;
    background: #fff;
    padding: 14px 0 4px;
    margin-top: 20px;
    border-top: 1px solid var(--line);
    z-index: 2;
}

.field-image .image-field {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 12px;
    align-items: start;
}
.image-preview {
    width: 120px;
    height: 120px;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    background: #eef3f1;
}
.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.image-actions {
    grid-column: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.file-btn { cursor: pointer; margin: 0; }
.media-picker { width: 100%; }
.media-picker summary {
    cursor: pointer;
    color: var(--green);
    font-size: 13px;
    font-weight: 600;
}
.media-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 8px;
    margin-top: 10px;
    max-height: 220px;
    overflow: auto;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fafcfb;
}
.media-pick {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0;
    overflow: hidden;
    background: #fff;
    cursor: pointer;
    height: 72px;
}
.media-pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-pick:hover { outline: 2px solid var(--green); }

@media (max-width: 700px) {
    .field-image .image-field { grid-template-columns: 1fr; }
    .image-actions { grid-column: 1; }
}
.btn-outline {
    background: #fff !important;
    color: var(--green) !important;
    border: 1px solid var(--green) !important;
}
.btn-outline:hover { background: #e8eee9 !important; }
textarea { min-height: 90px; }
