:root {
    --side: #222d32;
    --side-dark: #1a2226;
    --side-hover: #1e282c;
    --nav: #3c8dbc;
    --nav-dark: #367fa9;
    --text: #333;
    --muted: #777;
    --line: #d2d6de;
    --page: #ecf0f5;
    --aqua: #00c0ef;
    --green: #00a65a;
    --orange: #f39c12;
    --red: #dd4b39;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--text);
    background: var(--page);
    font-family: "Source Sans 3", "Source Sans Pro", "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.45;
}
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3 { font-weight: 600; letter-spacing: 0; }
:focus-visible { outline: 2px solid var(--nav); outline-offset: 2px; }
.ico { width: 1.15em; height: 1.15em; display: block; flex: none; }

.main-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 50px;
    display: flex;
    z-index: 40;
    color: #fff;
}
.logo {
    width: 230px;
    flex: none;
    display: flex;
    align-items: center;
    padding: 0 15px;
    background: var(--nav-dark);
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    letter-spacing: 0.06em;
}
.navbar {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--nav);
    min-width: 0;
}
.sidebar-toggle {
    width: 50px;
    height: 50px;
    border: 0;
    background: transparent;
    color: #fff;
    cursor: pointer;
    display: grid;
    place-items: center;
}
.sidebar-toggle .ico { width: 18px; height: 18px; }
.sidebar-toggle:hover { background: rgba(0,0,0,.1); }
.navbar-right { margin-left: auto; display: flex; align-items: center; height: 100%; }
.navbar-link, .navbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 100%;
    padding: 0 14px;
    color: #fff;
    text-decoration: none;
}
.navbar-link:hover { background: rgba(0,0,0,.1); }
.nav-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--red);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: inline-grid;
    place-items: center;
}

.main-sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: 230px;
    padding-top: 50px;
    background: var(--side);
    color: #b8c7ce;
    overflow: auto;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
}
body.sidebar-open .main-sidebar { transform: none; }
.content-wrapper {
    min-height: 100vh;
    padding: 66px 16px 28px;
    transition: margin-left 0.2s ease;
}
body.sidebar-open .content-wrapper { margin-left: 230px; }

.user-panel {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 14px 12px;
    border-bottom: 1px solid #1a2226;
}
.user-avatar {
    position: relative;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--nav);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    flex: none;
}
.presence {
    position: absolute;
    right: 0; bottom: 0;
    width: 11px; height: 11px;
    border-radius: 50%;
    background: #00a65a;
    border: 2px solid #222d32;
}
.user-panel strong { display: block; color: #fff; font-weight: 600; }
.online { display: flex; align-items: center; gap: 6px; color: #8aa4af; font-size: 12px; }
.online i { width: 8px; height: 8px; border-radius: 50%; background: #00a65a; display: inline-block; }
.sidebar-heading {
    margin: 0;
    padding: 12px 14px 6px;
    color: #6c7a82;
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.sidebar-menu { display: flex; flex-direction: column; padding-bottom: 20px; }
.side-link, .side-group summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    color: #b8c7ce;
    text-decoration: none;
    cursor: pointer;
    list-style: none;
}
.side-group summary::-webkit-details-marker { display: none; }
.side-link:hover, .side-group summary:hover { background: var(--side-hover); color: #fff; }
.side-link.is-on, .side-sub a[aria-current="page"] {
    background: var(--side-hover);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--nav);
}
.side-group summary::after {
    content: "›";
    margin-left: auto;
    font-size: 16px;
}
.side-group[open] summary::after { transform: rotate(90deg); }
.side-sub { background: #2c3b41; display: flex; flex-direction: column; }
.side-sub a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 14px 8px 42px;
    color: #b8c7ce;
    text-decoration: none;
}
.side-sub a:hover { color: #fff; }

.content-header h1, .main-bar h1 {
    margin: 0 0 14px;
    font-size: 24px;
    font-weight: 500;
    color: #333;
}
.content-header h1 small, .main-bar h1 small {
    font-size: 15px;
    color: #777;
    font-weight: 400;
    margin-left: 6px;
}
.main-bar { display: flex; justify-content: flex-start; align-items: center; gap: 12px; margin-bottom: 14px; }
.main-bar h1 { margin: 0; }
.main-bar > .btn,
.main-bar > a.btn { margin-left: auto; }
.back-btn {
    flex: 0 0 auto;
    border: 1px solid color-mix(in srgb, var(--nav) 35%, white);
    background: #fff;
    color: var(--nav-dark);
    border-radius: 3px;
    padding: 7px 14px;
    font-weight: 700;
    cursor: pointer;
}
.back-btn:hover { background: color-mix(in srgb, var(--nav) 12%, white); }

.dash-hello {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    background: #d9edf7;
    border: 1px solid #bce8f1;
    color: #31708f;
    padding: 10px 14px;
    margin-bottom: 16px;
}
.dash-hello p { margin: 0; }
.dash-hello a { color: #31708f; font-weight: 700; white-space: nowrap; }

.info-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 16px; }
.info-box {
    display: flex;
    min-height: 86px;
    background: #fff;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 1px 1px rgba(0,0,0,.1);
    overflow: hidden;
}
.info-icon {
    width: 86px;
    flex: none;
    display: grid;
    place-items: center;
    color: #fff;
}
.info-icon .ico { width: 38px; height: 38px; }
.tone-aqua { background: var(--aqua); }
.tone-green { background: var(--green); }
.tone-orange { background: var(--orange); }
.tone-red { background: var(--red); }
.info-text { display: flex; flex-direction: column; justify-content: center; padding: 8px 12px; min-width: 0; }
.info-text small { color: #888; letter-spacing: 0.04em; text-transform: uppercase; font-size: 12px; }
.info-text b { font-size: 28px; line-height: 1.1; font-weight: 600; }
.info-text em { color: var(--orange); font-style: normal; font-size: 12px; }

.dash-grid { display: grid; grid-template-columns: 1.45fr 0.9fr; gap: 16px; align-items: start; }
.widget, .panel, .form-card, .table-wrap, .theme-card, .media-card {
    background: #fff;
    border-top: 3px solid #d2d6de;
    box-shadow: 0 1px 1px rgba(0,0,0,.08);
}
.widget header, .panel h2, .form-card > h2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 0;
    padding: 10px 12px;
    border-bottom: 1px solid #f4f4f4;
    font-size: 16px;
}
.widget header h2, .panel h2, .form-card > h2 { border: 0; padding: 0; font-size: 16px; font-weight: 600; }
.widget-body, .panel, .form-card { padding: 12px; }
.panel h2, .form-card > h2 { margin: -12px -12px 12px; padding: 10px 12px; border-bottom: 1px solid #f4f4f4; }
.widget-tools { display: flex; }
.widget-tools button {
    width: 26px; height: 22px; border: 0; background: transparent; color: #97a0b3; cursor: pointer; font-size: 16px;
}
.widget.is-collapsed .widget-body { display: none; }
.hint { color: var(--muted); margin: 0 0 12px; }

.app-buttons { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.app-btn {
    position: relative;
    min-height: 86px;
    background: #f7f7f7;
    border: 1px solid #eee;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-decoration: none;
    color: #666;
    font-size: 12px;
}
.app-btn .ico { width: 28px; height: 28px; }
.app-btn:hover { background: #eee; color: #333; }
.app-badge {
    position: absolute;
    top: 6px; right: 6px;
    min-width: 16px; height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    color: #fff;
    font-size: 11px;
    display: grid;
    place-items: center;
}

.chart-wrap { display: flex; gap: 8px; }
.chart-y {
    width: 24px;
    height: 160px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    color: #999;
    font-size: 11px;
}
.chart-plot {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: stretch;
    gap: 4px;
}
.chart-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.chart-slot {
    width: 100%;
    height: 160px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    border-bottom: 1px solid #ddd;
    background-image: repeating-linear-gradient(to top, transparent, transparent 39px, #f3f3f3 40px);
}
.chart-bar { width: 14px; background: var(--nav); }
.chart-col span {
    margin-top: 6px;
    font-size: 10px;
    color: #888;
    white-space: nowrap;
}
.chart-legend { display: flex; align-items: center; gap: 6px; color: #666; font-size: 12px; margin: 18px 0 0; }
.chart-legend i { width: 12px; height: 12px; background: var(--nav); display: inline-block; }

.table-wrap { overflow-x: auto; border: 1px solid color-mix(in srgb, var(--nav) 35%, white); border-radius: 6px; background: #fff; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
    padding: 11px 14px;
    border: 1px solid color-mix(in srgb, var(--nav) 28%, white);
    vertical-align: middle;
}
.table th {
    background: var(--nav);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: center;
    border-color: var(--nav-dark);
}
.table th + th { border-left-color: rgba(255, 255, 255, 0.45); }
.table td { text-align: center; color: #243040; background: #fff; }
.table td:first-child { text-align: left; }
.table td.page-title {
    position: relative;
    padding-left: 32px;
    white-space: nowrap;
}
.page-toggle {
    position: absolute;
    left: 10px;
    top: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--nav);
    cursor: pointer;
    transform: translateY(-50%);
}
.page-toggle::before {
    content: "›";
    display: block;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    transform: rotate(90deg);
}
.page-toggle[aria-expanded="false"]::before { transform: none; }
.page-branch.is-sub { margin-left: 22px; }
tr.is-child-hidden { display: none; }
.table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--nav) 6%, white); }
.table tbody tr:hover td { background: color-mix(in srgb, var(--nav) 12%, white); }
.table td[colspan] { text-align: center; color: #5d6d7e; }
.row-actions { display: flex; gap: 10px; align-items: center; }
td.row-actions { justify-content: center; }
.row-actions form, .theme-actions form { margin: 0; }
.linkish { background: none; border: 0; padding: 0; color: var(--red); font-weight: 600; cursor: pointer; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 12px; background: #dff0d8; color: #3c763d; }
.badge-draf { background: #fcf8e3; color: #8a6d3b; }
.btn, .side-link.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    padding: 7px 12px;
    text-decoration: none;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    background: transparent;
    box-shadow: none;
}
.btn-primary { background: var(--nav); border-color: var(--nav-dark); color: #fff; }
.btn-primary:hover { background: var(--nav-dark); }
.btn-ghost { background: #fff; border-color: #ddd; color: #444; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-weight: 600; }
.field input[type="text"],
.field input[type="password"],
.field input[type="email"],
.field input[type="url"],
.field input[type="number"],
.field input[type="datetime-local"],
.field input[type="search"],
.field input[type="file"],
.field input:not([type]),
.field textarea,
.field select,
.table input[name="name"] {
    width: 100%;
    border: 1px solid #d2d6de;
    background: #fff;
    border-radius: 0;
    padding: 8px 10px;
    font-weight: 400;
}
.table input[name="name"] { min-width: 160px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.editor-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; align-items: center; }
.editor-bar button, .editor-bar select, .editor-bar .file-btn { border: 1px solid #d2d6de; background: #fff; border-radius: 2px; padding: 6px 8px; cursor: pointer; font-weight: 600; }
.editor-bar select { max-width: 150px; }
.yt-choice {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
    margin-bottom: 8px; padding: 8px 10px; background: #f4f8fc; border: 1px solid #d5e0ea;
}
.yt-choice[hidden] { display: none; }
.visual {
    min-height: 280px; border: 1px solid #d2d6de; background: #fff;
    padding: 12px 14px; line-height: 1.6; font-weight: 400;
}
.visual:focus { outline: 2px solid #2d5c88; outline-offset: 1px; }
.visual:empty::before { content: attr(data-placeholder); color: #8a94a0; }
.visual a { color: #1a66c2; }
.visual .yt-thumb,
.visual .embed-photo,
.visual .embed-audio { margin: 8px 0; }
.visual .embed-frame { position: relative; display: inline-block; max-width: 100%; vertical-align: top; }
.visual .yt-thumb .embed-frame,
.visual .embed-photo .embed-frame { max-width: 360px; }
.visual .yt-thumb img,
.visual .embed-photo img { width: 100%; height: auto; display: block; }
.visual .embed-audio .embed-frame { max-width: 456px; padding-right: 36px; }
.visual .embed-audio audio { width: 100%; display: block; }
.visual .media-x {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 2;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 50%;
    background: #c0392b;
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}
.visual .embed-audio .media-x { top: 50%; right: 0; margin-top: -14px; }
.editor-status { margin: 8px 0 0; color: #1f4a70; font-weight: 600; }
.form-card { max-width: 920px; }
.script-box { width: 100%; min-height: 280px; font-family: Consolas, monospace; font-size: 12px; }
.flash { padding: 10px 12px; margin-bottom: 14px; border: 1px solid transparent; }
.flash-ok { background: #dff0d8; color: #3c763d; border-color: #d6e9c6; }
.flash-err { background: #f2dede; color: #a94442; border-color: #ebccd1; }
.cover-preview { width: 160px; height: 100px; object-fit: cover; margin-bottom: 8px; }
.hero-list { display: flex; flex-wrap: wrap; gap: 12px; }
.hero-shot { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.media-card { padding: 10px; }
.media-card img { width: 100%; height: 120px; object-fit: cover; }
.media-card audio { width: 100%; }
.check { font-weight: 500; display: flex; gap: 8px; align-items: center; }
.message { white-space: pre-wrap; background: #fafafa; padding: 12px; border: 1px solid #eee; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin: 8px 0 24px; }
.theme-card { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.theme-card.is-on { border-top-color: var(--nav); box-shadow: 0 0 0 1px var(--nav), 0 1px 1px rgba(0,0,0,.08); }
.theme-card h2 { margin: 0; font-size: 18px; }
.theme-card p { margin: 0; color: var(--muted); }
.swatches { display: flex; gap: 6px; }
.swatches i { width: 22px; height: 22px; border-radius: 50%; display: block; border: 1px solid rgba(0,0,0,.08); }
.theme-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: auto; }
.tips { margin: 0; padding-left: 18px; }
.tips a { color: var(--nav); }

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: #d2d6de;
}
.login-card {
    width: min(380px, 100%);
    background: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,.15);
    overflow: hidden;
}
.login-card h1 {
    margin: 0;
    padding: 18px 16px;
    background: var(--nav);
    color: #fff;
    font-size: 18px;
    letter-spacing: 0.08em;
}
.login-inner { padding: 16px 16px 20px; }
.login-card p { margin: 0 0 12px; color: #666; }
.login-card .btn { width: 100%; }
.pass-line { display: flex; gap: 8px; align-items: stretch; }
.pass-line input { flex: 1; min-width: 0; }
.pass-toggle {
    border: 1px solid #d2d6de;
    background: #fff;
    padding: 8px 10px;
    cursor: pointer;
    font-weight: 600;
}

@media (max-width: 1100px) {
    .info-row, .dash-grid { grid-template-columns: 1fr 1fr; }
    .app-buttons { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
    .logo { width: auto; }
    .logo span { font-size: 13px; }
    body.sidebar-open .main-sidebar { transform: translateX(-100%); }
    body.sidebar-open .content-wrapper,
    body.menu-forced .content-wrapper { margin-left: 0; }
    body.menu-forced .main-sidebar { transform: none; }
    .navbar-user { display: none; }
    .info-row, .dash-grid, .split { grid-template-columns: 1fr; }
    .dash-hello { flex-direction: column; align-items: flex-start; }
    .content-wrapper { padding: 66px 12px 20px; }
}
@media (prefers-reduced-motion: reduce) {
    .main-sidebar, .content-wrapper { transition: none; }
}
