:root {
    --navy: #182331;
    --navy-2: #223246;
    --blue: #2d6cdf;
    --blue-dark: #1e55b6;
    --bg: #f2f5f8;
    --paper: #fff;
    --ink: #1f2937;
    --muted: #718096;
    --line: #dfe5ec;
    --green: #137a52;
    --red: #c43d4b;
    --shadow: 0 10px 30px rgba(31, 42, 57, .07);
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--bg); font-family: Inter, "Segoe UI", Arial, sans-serif; font-size: 14px; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.login-page { min-height: 100vh; color: #fff; background: radial-gradient(circle at 18% 15%, #375b82, transparent 34%), linear-gradient(130deg, #101a26, #263c52); }
.login-shell { width: min(980px, calc(100% - 32px)); min-height: 100vh; margin: auto; display: grid; grid-template-columns: 1fr 430px; align-items: center; gap: 80px; }
.login-brand span, .kicker { color: #7ba9f5; font-size: 11px; font-weight: 850; letter-spacing: .18em; }
.login-brand h1 { margin: 10px 0 12px; font-size: clamp(40px, 6vw, 72px); line-height: 1; }
.login-brand p { max-width: 430px; color: #bac9d8; font-size: 17px; }
.login-card { display: grid; gap: 19px; padding: 38px; color: var(--ink); background: #fff; border-radius: 16px; box-shadow: 0 30px 80px rgba(0,0,0,.28); }
.login-card h2 { margin: 4px 0 0; font-size: 28px; }
.login-card label, .field-grid label, .side-panel label, .settings-panel label { display: grid; gap: 7px; color: #48566a; font-size: 12px; font-weight: 750; }
input, select, textarea { width: 100%; padding: 11px 12px; color: var(--ink); background: #fff; border: 1px solid #ccd5df; border-radius: 7px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: #6f9ce8; box-shadow: 0 0 0 3px rgba(45,108,223,.1); }
.back-link { justify-self: center; color: #607086; text-decoration: none; font-size: 13px; }

.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; padding: 9px 15px; border: 1px solid transparent; border-radius: 7px; font-weight: 750; text-decoration: none; cursor: pointer; }
.button-primary { color: #fff; background: var(--blue); }
.button-primary:hover { background: var(--blue-dark); }
.button-light { color: #44546a; background: #fff; border-color: #d7dfe8; }
.button-light:hover { background: #f6f8fa; }
.button-full { width: 100%; }
.text-button { padding: 0; color: #53647a; background: transparent; border: 0; cursor: pointer; }

.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; color: #dbe5ef; background: var(--navy); }
.admin-brand { display: grid; padding: 25px 22px; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); text-decoration: none; }
.admin-brand span { color: #7ca6dc; font-size: 10px; font-weight: 850; letter-spacing: .17em; }
.admin-brand strong { margin-top: 5px; overflow: hidden; font-size: 18px; text-overflow: ellipsis; white-space: nowrap; }
.sidebar nav { display: grid; gap: 5px; padding: 20px 12px; }
.sidebar nav a { display: flex; gap: 11px; align-items: center; padding: 11px 13px; color: #c3cfdb; border-radius: 7px; font-weight: 650; text-decoration: none; }
.sidebar nav a span { width: 18px; color: #7f9cba; text-align: center; }
.sidebar nav a:hover, .sidebar nav a.active { color: #fff; background: var(--navy-2); }
.sidebar nav a.active span { color: #80aef5; }
.sidebar-note { margin: auto 16px 20px; padding: 13px; color: #8fa5ba; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06); border-radius: 8px; font-size: 11px; }
.sidebar-note strong, .sidebar-note span { display: block; }
.sidebar-note strong { color: #d7e4ef; margin-bottom: 3px; }
.admin-main { min-width: 0; }
.topbar { min-height: 87px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 16px 28px; background: #fff; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 3px 0 0; font-size: 25px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.topbar-actions form { margin: 0; }
.admin-user { padding-left: 14px; color: #45546a; border-left: 1px solid var(--line); font-weight: 750; }
.admin-content { padding: 26px 28px 50px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.panel-head { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 17px 20px; border-bottom: 1px solid var(--line); }
.panel h2 { margin: 0; font-size: 17px; }
.panel p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.panel-actions { display: flex; align-items: center; gap: 10px; }
.admin-search { display: flex; }
.admin-search input { width: 210px; border-radius: 7px 0 0 7px; }
.admin-search button { padding-inline: 13px; color: #fff; background: #53657a; border: 0; border-radius: 0 7px 7px 0; cursor: pointer; }
.alert { margin-bottom: 18px; padding: 12px 15px; border: 1px solid; border-radius: 8px; font-weight: 650; }
.alert-success { color: #12613f; background: #e9f8f0; border-color: #b9e5cd; }
.alert-error { color: #9a2837; background: #fff0f2; border-color: #edc1c7; }

.table-wrap { overflow-x: auto; }
.posts-table { width: 100%; border-collapse: collapse; }
.posts-table th { padding: 12px 15px; color: #6e7b8c; background: #f8fafc; border-bottom: 1px solid var(--line); font-size: 11px; text-align: left; text-transform: uppercase; letter-spacing: .05em; }
.posts-table td { padding: 13px 15px; border-bottom: 1px solid #edf0f4; vertical-align: middle; }
.posts-table tr:last-child td { border-bottom: 0; }
.post-cell { min-width: 300px; display: flex; align-items: center; gap: 12px; }
.post-cell img { width: 64px; height: 45px; object-fit: cover; background: #e8edf2; border-radius: 5px; }
.post-cell strong, .post-cell span { display: block; }
.post-cell strong { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-cell span { margin-top: 3px; color: #93a0ae; font-size: 11px; }
.status { display: inline-block; padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.status.published { color: #116142; background: #def5e8; }
.status.hidden { color: #8a5b09; background: #fff0c9; }
.row-actions { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.row-actions a, .row-actions button { padding: 0; color: #386cc1; background: transparent; border: 0; font-size: 12px; text-decoration: none; cursor: pointer; }
.row-actions button { color: var(--red); }
.row-actions form { margin: 0; }
.table-empty { padding: 45px !important; color: var(--muted); text-align: center; }

.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; align-items: start; gap: 20px; }
.editor-main { min-width: 0; padding: 20px; }
.two-columns { grid-template-columns: minmax(0, 1.4fr) minmax(220px, .6fr); }
.field-grid { display: grid; gap: 17px; }
.field-grid.two-columns { display: grid; }
.editor-toolbar { display: grid; gap: 7px; margin-top: 20px; padding: 9px; background: #edf2f7; border: 1px solid #d5dee8; border-bottom: 0; border-radius: 8px 8px 0 0; }
.toolbar-group { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.toolbar-group + .toolbar-group { padding-top: 7px; border-top: 1px solid #d6dee7; }
.editor-toolbar button, .editor-toolbar select { width: auto; min-height: 34px; padding: 6px 9px; color: #425269; background: #fff; border: 1px solid #d1dbe5; border-radius: 5px; cursor: pointer; }
.editor-toolbar button:hover:not(:disabled) { color: var(--blue); border-color: #91b4eb; background: #f8fbff; }
.editor-toolbar button:disabled, .editor-toolbar select:disabled { color: #a8b1bd; background: #f2f4f6; cursor: not-allowed; opacity: .7; }
.toolbar-table { padding: 8px; background: #e4ebf2; border: 1px solid #d2dce7 !important; border-radius: 7px; }
.toolbar-table > button:first-child { color: #fff; background: #345f93; border-color: #345f93; }
.toolbar-color { width: auto !important; display: inline-flex !important; min-height: 34px; align-items: center; grid-template-columns: auto auto !important; gap: 6px !important; padding: 4px 7px; color: #526174 !important; background: #fff; border: 1px solid #d1dbe5; border-radius: 5px; font-size: 11px !important; }
.toolbar-color input[type=color] { width: 25px; height: 23px; padding: 0; border: 0; border-radius: 4px; cursor: pointer; }
.table-tool-status { margin-left: auto; color: #65758a; font-size: 11px; font-weight: 650; }
.rich-editor { min-height: 520px; max-height: 75vh; padding: 22px; overflow: auto; background: #fff; border: 1px solid #dbe2ea; border-radius: 0 0 8px 8px; outline: none; line-height: 1.65; }
.rich-editor:focus { border-color: #79a4e8; box-shadow: 0 0 0 3px rgba(45,108,223,.08); }
.rich-editor img { max-width: 100%; height: auto; }
.rich-editor table { width: 100%; max-width: 100%; margin: 16px 0; border-collapse: collapse; table-layout: auto; }
.rich-editor td, .rich-editor th { min-width: 70px; padding: 9px; border: 1px solid #9eabb9; vertical-align: top; }
.rich-editor th { color: #fff; background: #345f93; font-weight: 800; }
.rich-editor td.is-selected-cell, .rich-editor th.is-selected-cell { position: relative; outline: 3px solid #2d6cdf; outline-offset: -3px; box-shadow: inset 0 0 0 1px #fff; }
.rich-editor hr { height: 1px; margin: 24px 0; background: #c8d1dc; border: 0; }
.help-text { color: var(--muted) !important; font-size: 11px !important; }
.field-help { color: var(--muted); font-size: 11px; font-weight: 400; line-height: 1.4; }
.editor-side { display: grid; gap: 16px; }
.side-panel { display: grid; gap: 15px; padding: 18px; }
.switch-row { grid-template-columns: 1fr auto !important; align-items: center; gap: 15px !important; padding: 12px 0; border-top: 1px solid #edf0f4; border-bottom: 1px solid #edf0f4; }
.switch-row span, .switch-row strong, .switch-row small { display: block; }
.switch-row small { margin-top: 3px; color: var(--muted); font-weight: 400; }
.switch-row input { width: 19px; height: 19px; }
.poster-preview { width: 100%; height: 155px; object-fit: cover; background: #edf1f5; border: 1px solid var(--line); border-radius: 7px; }

.upload-panel { display: flex; align-items: center; justify-content: space-between; gap: 30px; margin-bottom: 20px; padding: 20px; }
.upload-panel form { display: flex; align-items: center; gap: 10px; }
.upload-panel input[type=file] { max-width: 340px; }
.media-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; padding: 18px; }
.media-item { min-width: 0; overflow: hidden; background: #f8fafc; border: 1px solid #dfe5eb; border-radius: 8px; }
.media-item > img { width: 100%; height: 155px; object-fit: cover; background: #e9edf1; }
.media-item > div { padding: 11px; }
.media-item strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-item span { display: block; margin: 3px 0 8px; color: var(--muted); font-size: 11px; }
.media-item input { padding: 7px 8px; color: #627086; background: #fff; font-size: 11px; }
.media-actions { display: flex; gap: 10px; align-items: center; margin-top: 9px; }
.media-actions button { padding: 0; color: #3568ba; background: transparent; border: 0; font-size: 11px; cursor: pointer; }
.media-actions form { margin: 0; }
.media-actions form button { color: var(--red); }

.settings-grid { display: grid; gap: 20px; }
.settings-panel .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 20px; }
.settings-submit { display: flex; justify-content: flex-end; }

@media (max-width: 1100px) {
    .editor-layout { grid-template-columns: 1fr; }
    .editor-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .media-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
    .login-shell { grid-template-columns: 1fr; gap: 20px; padding-block: 50px; }
    .login-brand { display: none; }
    .login-card { width: min(430px, 100%); margin: auto; }
    .admin-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; width: 100%; height: auto; }
    .sidebar nav { grid-template-columns: repeat(4, minmax(0, 1fr)); padding-block: 9px; }
    .sidebar nav a { justify-content: center; font-size: 12px; }
    .sidebar nav a span { display: none; }
    .sidebar-note { display: none; }
    .admin-brand { padding-block: 15px; }
    .topbar { align-items: flex-start; flex-direction: column; }
    .topbar-actions { width: 100%; flex-wrap: wrap; }
    .panel-head, .upload-panel { align-items: flex-start; flex-direction: column; }
    .panel-actions { width: 100%; flex-wrap: wrap; }
    .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
    .admin-content, .topbar { padding-inline: 13px; }
    .sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .two-columns, .settings-panel .field-grid, .editor-side { grid-template-columns: 1fr; }
    .table-tool-status { width: 100%; margin: 3px 0 0; }
    .panel-actions, .admin-search, .upload-panel form { width: 100%; }
    .admin-search input { width: 100%; }
    .media-grid { grid-template-columns: 1fr; }
    .media-item > img { height: 220px; }
    .login-card { padding: 25px 20px; }
}
