:root {
    --a-bg: #f2f0e8;
    --a-panel: #ffffff;
    --a-ink: #1c2620;
    --a-muted: #6b7568;
    --a-line: #e2ded0;
    --a-forest: #1c4136;
    --a-forest-dark: #142e26;
    --a-gold: #d9a22a;
    --a-clay: #b0492c;
    --a-radius: 12px;
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font-body); background: var(--a-bg); color: var(--a-ink); overflow-x: hidden; max-width: 100%; }
a { color: inherit; text-decoration: none; }
h1,h2,h3,h4 { font-family: var(--font-display); margin: 0 0 8px; }
img { max-width: 100%; }

/* Login page */
.login-wrap {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: var(--a-forest-dark);
    background-image: radial-gradient(circle at 20% 20%, rgba(217,162,42,0.18), transparent 45%), radial-gradient(circle at 80% 80%, rgba(143,181,106,0.12), transparent 45%);
    padding: 24px;
}
.login-card {
    background: var(--a-panel);
    border-radius: 20px;
    padding: 44px;
    width: 100%; max-width: 400px;
    box-shadow: 0 30px 60px -20px rgba(0,0,0,0.5);
}
.login-card .brand-mark { width: 46px; margin-bottom: 18px; }
.login-card p.sub { color: var(--a-muted); margin-bottom: 26px; font-size: 0.92rem; }
.login-card .field { margin-bottom: 16px; }
.login-card label { display: block; font-size: 0.78rem; font-weight: 600; margin-bottom: 6px; color: var(--a-muted); text-transform: uppercase; letter-spacing: 0.05em; font-family: var(--font-mono); }
.login-card input {
    width: 100%; padding: 13px 14px; border-radius: 10px; border: 1.5px solid var(--a-line);
    font-size: 1rem; background: #fafaf6;
}
.login-card input:focus { outline: none; border-color: var(--a-gold); box-shadow: 0 0 0 3px rgba(217,162,42,0.2); }
.login-hint { margin-top: 18px; font-size: 0.78rem; color: var(--a-muted); background: #f7f5ec; border: 1px dashed var(--a-line); border-radius: 10px; padding: 12px 14px; }

/* Shell layout */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
    width: 250px; flex-shrink: 0;
    background: var(--a-forest-dark);
    color: #e8e4d3;
    padding: 22px 16px;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.admin-sidebar .brand { display: flex; gap: 10px; align-items: center; padding: 6px 10px 22px; }
.admin-sidebar .brand strong { font-family: var(--font-display); font-size: 1rem; display: block; }
.admin-sidebar .brand span { font-family: var(--font-mono); font-size: 0.62rem; color: var(--a-gold); text-transform: uppercase; letter-spacing: 0.08em; }
.admin-nav-group { margin-bottom: 18px; }
.admin-nav-group .group-label { font-family: var(--font-mono); font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em; color: #7c8a7a; padding: 8px 12px 4px; display: block; }
.admin-nav-group a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 10px; font-size: 0.88rem; color: #d9d5c1;
    margin-bottom: 2px;
}
.admin-nav-group a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.admin-nav-group a.active { background: var(--a-gold); color: #142e26; font-weight: 600; }
.admin-nav-group a svg { flex-shrink: 0; }
.sidebar-foot { margin-top: 20px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,0.1); }
.sidebar-foot a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: #d9d5c1; font-size: 0.85rem; }
.sidebar-foot a:hover { background: rgba(255,255,255,0.06); color: #fff; }

.admin-main { flex-grow: 1; min-width: 0; }
.admin-topbar {
    background: var(--a-panel); border-bottom: 1px solid var(--a-line);
    padding: 18px 32px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.admin-topbar h1 { font-size: 1.3rem; }
.admin-topbar .breadcrumb { font-family: var(--font-mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--a-muted); }
.view-site-link { display: inline-flex; align-items: center; gap: 8px; font-size: 0.85rem; padding: 9px 16px; border-radius: 999px; border: 1.5px solid var(--a-line); }
.view-site-link:hover { border-color: var(--a-forest); }

.admin-body { padding: 28px 32px 60px; }

.flash { padding: 14px 18px; border-radius: 10px; margin-bottom: 22px; font-size: 0.9rem; }
.flash.ok { background: #e8f2df; color: #3e6a25; border: 1px solid #c3dbae; }
.flash.err { background: #fbe6e0; color: #8a3018; border: 1px solid #f0bda9; }

.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 30px; }
.stat-card { background: var(--a-panel); border: 1px solid var(--a-line); border-radius: var(--a-radius); padding: 20px 22px; }
.stat-card .num { font-family: var(--font-display); font-size: 1.9rem; }
.stat-card .lbl { font-family: var(--font-mono); font-size: 0.7rem; text-transform: uppercase; color: var(--a-muted); letter-spacing: 0.05em; }
.stat-card.accent-gold .num { color: var(--a-gold); }
.stat-card.accent-clay .num { color: var(--a-clay); }
.stat-card.accent-forest .num { color: var(--a-forest); }

.panel { background: var(--a-panel); border: 1px solid var(--a-line); border-radius: var(--a-radius); padding: 26px; margin-bottom: 24px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.panel-head p { color: var(--a-muted); font-size: 0.86rem; margin: 4px 0 0; }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--a-line); vertical-align: top; }
th { font-family: var(--font-mono); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--a-muted); }
tr:last-child td { border-bottom: none; }
.badge { display: inline-block; padding: 4px 11px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; }
.badge.pending { background: #fbf0d6; color: #8a6111; }
.badge.confirmed { background: #dcefd0; color: #3e6a25; }
.badge.done { background: #dbe7f4; color: #2b567f; }
.badge.rejected { background: #fbe0da; color: #92341a; }

.btn { display: inline-flex; align-items: center; gap: 7px; padding: 10px 16px; border-radius: 9px; border: 1.5px solid var(--a-line); background: #fff; font-size: 0.85rem; font-weight: 600; color: var(--a-ink); }
.btn:hover { border-color: var(--a-forest); }
.btn-primary { background: var(--a-forest); border-color: var(--a-forest); color: #fff; }
.btn-primary:hover { background: var(--a-forest-dark); }
.btn-gold { background: var(--a-gold); border-color: var(--a-gold); color: #23230c; }
.btn-danger { background: #fff; border-color: #e6b7a6; color: var(--a-clay); }
.btn-danger:hover { background: #fbe6e0; }
.btn-xs { padding: 6px 11px; font-size: 0.75rem; }

.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 4px; }
.form-row.one { grid-template-columns: 1fr; }
.f { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.f.full { grid-column: 1 / -1; }
.f label { font-size: 0.78rem; font-weight: 600; color: var(--a-muted); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.04em; }
.f input, .f select, .f textarea {
    padding: 11px 13px; border-radius: 8px; border: 1.5px solid var(--a-line); background: #fafaf6; font-size: 0.94rem;
}
.f input:focus, .f select:focus, .f textarea:focus { outline: none; border-color: var(--a-gold); box-shadow: 0 0 0 3px rgba(217,162,42,0.18); }
.f textarea { min-height: 90px; resize: vertical; }
.f .hint { font-size: 0.76rem; color: var(--a-muted); font-weight: 400; text-transform: none; font-family: var(--font-body); }

.list-editor { border: 1px solid var(--a-line); border-radius: 10px; padding: 14px; background: #fafaf6; }
.list-editor .row { display: flex; gap: 10px; margin-bottom: 10px; align-items: flex-start; }
.list-editor .row input, .list-editor .row textarea { flex-grow: 1; }
.list-editor .remove-row { flex-shrink: 0; width: 38px; height: 38px; border-radius: 8px; border: 1.5px solid var(--a-line); background: #fff; }

.thumb-sm { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; background: #eee; }
.item-row { display: flex; gap: 14px; align-items: flex-start; padding: 14px 0; border-bottom: 1px solid var(--a-line); }
.item-row:last-child { border-bottom: none; }
.item-row .grow { flex-grow: 1; }
.item-row .actions { display: flex; gap: 6px; flex-shrink: 0; }
.item-row h4 { font-size: 0.98rem; margin: 0 0 4px; }
.item-row p { margin: 0; font-size: 0.84rem; color: var(--a-muted); }
.tag-mini { font-family: var(--font-mono); font-size: 0.68rem; background: #eee; padding: 2px 8px; border-radius: 999px; color: var(--a-muted); }

.upload-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; margin-top: 16px; }
.upload-tile { position: relative; border-radius: 10px; overflow: hidden; aspect-ratio: 1/1; background: #eee; }
.upload-tile img { width: 100%; height: 100%; object-fit: cover; }
.upload-tile form { position: absolute; top: 6px; right: 6px; }
.upload-tile button { width: 30px; height: 30px; border-radius: 50%; border: none; background: rgba(0,0,0,0.55); color: #fff; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
.table-scroll table { min-width: 640px; }

.sidebar-toggle {
    display: none;
    width: 42px; height: 42px;
    border-radius: 10px;
    border: 1.5px solid var(--a-line);
    background: #fff;
    align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sidebar-overlay { display: none; }

@media (max-width: 960px) {
    .admin-shell { position: relative; }
    .admin-sidebar {
        position: fixed; top: 0; left: 0; height: 100vh; z-index: 210;
        width: 270px; max-width: 82vw;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 20px 0 40px -20px rgba(0,0,0,0.4);
    }
    .admin-sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: flex; }
    .sidebar-overlay {
        display: none;
        position: fixed; inset: 0; z-index: 205;
        background: rgba(14,20,17,0.5);
    }
    .sidebar-overlay.open { display: block; }
    .admin-topbar { padding: 14px 16px; }
    .admin-topbar h1 { font-size: 1.05rem; }
    .admin-topbar > div:last-child { gap: 8px !important; }
    .admin-topbar .breadcrumb { display: none; }
    .view-site-link span { display: none; }
    .admin-body { padding: 18px 16px 50px; }
    .stat-cards { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .form-row, .two-col { grid-template-columns: 1fr; }
    .panel { padding: 18px; }
    .panel-head { flex-direction: column; align-items: flex-start; }
    .item-row { flex-wrap: wrap; }
    .item-row .actions { width: 100%; justify-content: flex-start; margin-top: 8px; }
    .login-card { padding: 30px 24px; }
}
