:root {
    --ink: #171918;
    --muted: #68706b;
    --paper: #f3f4f1;
    --white: #fff;
    --line: #dde1dc;
    --accent: #2f6545;
    --accent-soft: #e7f0e9;
    --danger: #9f392d;
    --sidebar: #171b19;
    --shadow: 0 12px 32px rgba(18, 25, 20, 0.08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.admin-body { min-height: 100vh; }

.admin-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    display: flex;
    width: 250px;
    flex-direction: column;
    background: var(--sidebar);
    color: rgba(255,255,255,.76);
}

.admin-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 76px;
    padding: 16px 22px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    color: #fff;
    text-decoration: none;
}

button.admin-logo,
.admin-nav button,
.quick-actions button,
.stat-grid button {
    width: 100%;
    border: 0;
    color: inherit;
    font: inherit;
    text-align: left;
}

button.admin-logo { background: transparent; cursor: pointer; }
.admin-nav button { display: flex; align-items: center; gap: 11px; min-height: 42px; padding: 8px 11px; border-radius: 7px; background: transparent; font-size: .9rem; font-weight: 650; cursor: pointer; }
.admin-nav button:hover, .admin-nav button.active { background: rgba(255,255,255,.09); color: #fff; }
.admin-nav button.active { box-shadow: inset 3px 0 var(--accent); }
.admin-nav button span { width: 20px; font-size: 1.05rem; text-align: center; }

.admin-logo > span {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 7px;
    background: #fff;
    color: var(--sidebar);
    font-weight: 900;
}

.admin-logo div, .sidebar-user div { display: grid; gap: 2px; min-width: 0; }
.admin-logo small, .sidebar-user a { color: rgba(255,255,255,.48); font-size: .75rem; }
.sidebar-user a { text-decoration: none; }

.admin-nav { flex: 1; overflow-y: auto; padding: 18px 12px; }
.admin-nav p { margin: 22px 11px 7px; color: rgba(255,255,255,.35); font-size: .68rem; font-weight: 800; text-transform: uppercase; }
.admin-nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 42px;
    padding: 8px 11px;
    border-radius: 7px;
    text-decoration: none;
    font-size: .9rem;
    font-weight: 650;
}
.admin-nav a:hover, .admin-nav a.active { background: rgba(255,255,255,.09); color: #fff; }
.admin-nav a.active { box-shadow: inset 3px 0 var(--accent); }
.admin-nav a span { width: 20px; font-size: 1.05rem; text-align: center; }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-user > span { display: grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 800; }
.sidebar-user strong { overflow: hidden; color: #fff; font-size: .85rem; text-overflow: ellipsis; white-space: nowrap; }

.admin-workspace { min-height: 100vh; margin-left: 250px; }
.admin-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 76px;
    padding: 12px 34px;
    border-bottom: 1px solid var(--line);
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(14px);
}
.admin-topbar div { display: grid; gap: 2px; }
.admin-topbar span { color: var(--muted); font-size: .72rem; }
.admin-topbar strong { font-size: .95rem; }
.view-site { color: var(--accent); font-size: .84rem; font-weight: 750; text-decoration: none; }
.menu-toggle { display: none; border: 0; background: none; font-size: 1.3rem; }

.admin-main { width: min(1480px, 100%); margin: 0 auto; padding: 36px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-heading h1 { margin: 3px 0 5px; font-size: clamp(2rem, 4vw, 3rem); line-height: 1; }
.page-heading p { margin: 0; color: var(--muted); }
.kicker { margin: 0; color: var(--accent); font-size: .72rem; font-weight: 850; text-transform: uppercase; }

.admin-button, button[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    border: 0;
    border-radius: 7px;
    background: var(--accent);
    color: #fff;
    font-weight: 750;
    text-decoration: none;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
    box-shadow: 0 1px 2px rgba(18,25,20,.03);
}
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.panel-heading h2, .panel > h2 { margin: 3px 0 0; font-size: 1.15rem; }
.panel-content { padding: 24px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-grid a { display: grid; min-height: 148px; padding: 20px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); text-decoration: none; transition: transform .2s ease, box-shadow .2s ease; }
.stat-grid button { display: grid; min-height: 148px; padding: 20px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); transition: transform .2s ease, box-shadow .2s ease; cursor: pointer; }
.stat-grid a:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-grid button:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-grid span, .stat-grid small { color: var(--muted); font-size: .78rem; }
.stat-grid strong { align-self: center; font-size: 2.5rem; line-height: 1; }
.stat-grid small { align-self: end; color: var(--accent); font-weight: 700; }

.dashboard-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 20px; }
.quick-actions { display: grid; }
.quick-actions a { display: grid; gap: 4px; padding: 18px 24px; border-bottom: 1px solid var(--line); text-decoration: none; }
.quick-actions button { display: grid; gap: 4px; padding: 18px 24px; border-bottom: 1px solid var(--line); background: transparent; cursor: pointer; }
.quick-actions a:last-child { border-bottom: 0; }
.quick-actions button:last-child { border-bottom: 0; }
.quick-actions a:hover { background: #fafbf9; }
.quick-actions button:hover { background: #fafbf9; }
.quick-actions span, .activity-list small { color: var(--muted); font-size: .8rem; }
.activity-list { padding: 10px 24px 20px; }
.activity-list > div { display: flex; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.activity-list > div > span { width: 8px; height: 8px; margin-top: 5px; flex: 0 0 auto; border-radius: 50%; background: var(--accent); }
.activity-list p { display: grid; gap: 4px; margin: 0; font-size: .86rem; }

.content-editor, .settings-layout { display: grid; gap: 18px; }
.editor-panel { scroll-margin-top: 96px; }
.collapse-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.editor-panel.collapsed .panel-content { display: none; }
.editor-panel.collapsed .collapse-button { transform: rotate(180deg); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: grid; gap: 7px; margin-bottom: 17px; color: #454b47; font-size: .82rem; font-weight: 700; }
input, textarea, select {
    width: 100%;
    border: 1px solid #ccd2cc;
    border-radius: 7px;
    background: #fff;
    padding: 11px 12px;
    color: var(--ink);
    outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,101,69,.12); }
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.file-field { padding: 14px; border: 1px dashed #bdc7be; border-radius: 7px; background: #fafbf9; }
.check-field { display: flex; grid-column: auto; align-items: center; gap: 9px; }
.check-field input { width: 18px; height: 18px; }
.field-help { margin: -8px 0 16px; color: var(--muted); font-size: .78rem; }
details { margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
summary { margin-bottom: 16px; cursor: pointer; color: var(--accent); font-weight: 750; }

.sticky-actions { position: sticky; bottom: 16px; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 20px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.96); box-shadow: var(--shadow); }
.sticky-actions span { color: var(--muted); font-size: .8rem; }

.table-panel { overflow: hidden; }
.data-table { overflow-x: auto; }
.table-row { display: grid; grid-template-columns: minmax(250px, 2fr) 1fr .6fr .8fr auto; min-width: 900px; align-items: center; gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--line); font-size: .84rem; }
.table-row:last-child { border-bottom: 0; }
.table-head { background: #f8f9f7; color: var(--muted); font-size: .72rem; font-weight: 800; text-transform: uppercase; }
.users-table .table-row { grid-template-columns: 1fr 1.4fr .7fr 1fr auto; }
.pages-table .table-row, .nav-table .table-row { grid-template-columns: 1.2fr .8fr .8fr 1.3fr auto; }
.table-meta { display: block; margin-top: 3px; color: var(--muted); font-size: .7rem; }
.wide-dialog { width: min(820px, calc(100vw - 28px)); }
.item-with-image { display: flex; align-items: center; gap: 12px; min-width: 0; }
.item-with-image img { width: 48px; height: 48px; flex: 0 0 auto; border-radius: 5px; object-fit: cover; }
.item-with-image strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: #b6bcb7; }
.status.on { background: #3b9b60; box-shadow: 0 0 0 3px #e1f2e6; }
.row-actions { display: flex; align-items: center; gap: 10px; }
.row-actions form, .media-card form { margin: 0; }
.row-actions button, .media-card button { padding: 0; border: 0; background: none; color: var(--accent); font-size: .78rem; font-weight: 750; }
.danger-link { color: var(--danger) !important; }

.upload-panel { max-width: 760px; margin-bottom: 24px; padding: 24px; }
.dropzone { place-items: center; padding: 32px; border: 1px dashed #aebbb0; border-radius: 7px; background: #fafbf9; text-align: center; }
.dropzone span { color: var(--muted); font-size: .78rem; font-weight: 400; }
.dropzone input { width: auto; border: 0; padding: 10px 0 0; background: none; }
.media-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.media-card { overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.media-card > img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.media-card > div { display: grid; grid-template-columns: 1fr auto; gap: 9px; padding: 13px; }
.media-card strong { grid-column: 1 / -1; overflow: hidden; font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }

.admin-dialog { width: min(620px, calc(100vw - 28px)); padding: 0; border: 0; border-radius: 8px; box-shadow: 0 24px 80px rgba(0,0,0,.22); }
.admin-dialog::backdrop { background: rgba(10,14,11,.55); backdrop-filter: blur(3px); }
.admin-dialog form { padding: 24px; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.dialog-heading h2 { margin: 0; }
.dialog-heading button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 7px; background: #fff; font-size: 1.3rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.secondary-button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 16px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); font-weight: 700; text-decoration: none; }
.inline-button { margin-top: 20px; }

.system-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.system-grid .panel { padding: 24px; }
dl { margin: 18px 0 0; }
dl div { display: flex; justify-content: space-between; gap: 20px; padding: 13px 0; border-bottom: 1px solid var(--line); }
dt { color: var(--muted); }
dd { margin: 0; font-weight: 700; }

.notice { margin-bottom: 20px; padding: 13px 15px; border: 1px solid; border-radius: 7px; font-size: .86rem; }
.notice.success { border-color: #b9d8c1; background: #edf7ef; color: #28633b; }
.notice.error, .alert { border-color: #e4bbb4; background: #fff0ed; color: #853327; }
.empty-state { padding: 20px 0; color: var(--muted); }

.login-body { display: grid; min-height: 100vh; place-items: center; padding: 20px; }
.login-panel { width: min(460px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: var(--shadow); }
.login-panel h1 { margin: 5px 0 12px; font-size: 2rem; }
.login-panel > p:not(.kicker):not(.notice):not(.alert) { color: var(--muted); line-height: 1.55; }

@media (max-width: 1100px) {
    .stat-grid, .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .admin-sidebar { transform: translateX(-100%); transition: transform .22s ease; }
    .admin-sidebar.open { transform: translateX(0); box-shadow: 20px 0 50px rgba(0,0,0,.2); }
    .admin-workspace { margin-left: 0; }
    .menu-toggle { display: block; }
    .admin-topbar { padding: 12px 18px; }
    .admin-topbar > div { flex: 1; margin-left: 10px; }
    .admin-main { padding: 26px 18px; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .form-grid, .system-grid { grid-template-columns: 1fr; }
    .form-grid .full { grid-column: auto; }
    .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sticky-actions { align-items: stretch; flex-direction: column; }
}

@media (max-width: 480px) {
    .stat-grid, .media-grid { grid-template-columns: 1fr; }
    .view-site { font-size: 0; }
    .view-site::after { content: "Website ↗"; font-size: .8rem; }
}
