:root {
    --bg: #081120;
    --panel: #101b31;
    --panel-soft: #13213b;
    --line: rgba(255,255,255,.08);
    --text: #e8eefc;
    --muted: #8ea2c7;
    --primary: #4f7cff;
    --primary-soft: rgba(79,124,255,.18);
    --success: #16c47f;
    --warning: #f7b500;
    --danger: #ff5d73;
    --shadow: 0 20px 60px rgba(0,0,0,.26);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: "Segoe UI", "PingFang SC", sans-serif; background: linear-gradient(180deg, #09111f, #0d1730 45%, #0b1323); color: var(--text); line-height: 1.5; }
a { color: inherit; text-decoration: none; }
code, pre { font-family: Consolas, Monaco, monospace; }
button, input, select, textarea { font: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 280px minmax(0, 1fr); }
.sidebar { background: rgba(4,10,22,.92); border-right: 1px solid var(--line); padding: 24px 18px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px; z-index: 20; }
.sidebar-backdrop { display: none; }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-logo { width: 48px; height: 48px; flex: 0 0 48px; border-radius: 16px; display: grid; place-items: center; background: linear-gradient(135deg, var(--primary), #7f5cff); font-weight: 700; box-shadow: var(--shadow); }
.brand strong { display: block; word-break: break-word; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.menu { display: grid; gap: 8px; }
.menu-link { padding: 12px 14px; border-radius: 14px; color: var(--muted); transition: .2s ease; word-break: break-word; }
.menu-link.active, .menu-link:hover { background: var(--primary-soft); color: #fff; }
.sidebar-footer { margin-top: auto; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); }
.sidebar-footer p { margin: 0 0 14px; word-break: break-word; }
.main-shell { min-width: 0; }
.topbar { padding: 24px 28px 0; display: flex; align-items: flex-start; gap: 16px; }
.topbar h1 { margin: 0; font-size: 30px; line-height: 1.2; }
.topbar p { margin: 6px 0 0; color: var(--muted); }
.menu-toggle { display: none; align-items: center; justify-content: center; background: var(--panel); border: 1px solid var(--line); color: #fff; border-radius: 12px; width: 42px; height: 42px; cursor: pointer; flex: 0 0 42px; }
.page-content { padding: 24px 28px 32px; display: grid; gap: 20px; }
.page-content > * { min-width: 0; }
.panel-card, .stat-card { background: rgba(16,27,49,.88); border: 1px solid var(--line); border-radius: 22px; padding: 22px; box-shadow: var(--shadow); backdrop-filter: blur(12px); min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.panel-head.wrap { flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 20px; line-height: 1.3; }
.panel-head span { color: var(--muted); font-size: 13px; }
.stats-grid { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 16px; }
.stat-card span { color: var(--muted); font-size: 14px; }
.stat-card strong { display: block; font-size: 34px; margin: 10px 0 8px; line-height: 1.1; }
.stat-card p { margin: 0; color: var(--muted); line-height: 1.65; }
.stat-card.success { border-color: rgba(22,196,127,.35); }
.stat-card.warning { border-color: rgba(247,181,0,.35); }
.stat-card.danger { border-color: rgba(255,93,115,.35); }
.stat-card.accent { border-color: rgba(79,124,255,.35); }
.stat-card.accent-soft { border-color: rgba(127,92,255,.35); }
.content-grid { display: grid; gap: 20px; }
.two-columns { grid-template-columns: repeat(2, minmax(0,1fr)); }
.table-wrap { overflow: auto; border-radius: 18px; }
.responsive-table { width: 100%; border-collapse: collapse; min-width: 720px; }
.responsive-table th, .responsive-table td { padding: 14px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.responsive-table th { color: var(--muted); font-size: 13px; font-weight: 600; }
.muted { color: var(--muted); margin: 4px 0 0; }
.text-break { word-break: break-all; }
.table-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.table-actions form { margin: 0; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; width: 100%; }
.inline-form > * { flex: 1 1 180px; min-width: 0; }
.inline-form .btn { flex: 0 0 auto; }
.stack-form { display: grid; gap: 14px; }
.form-grid { display: grid; gap: 14px; }
label { display: block; min-width: 0; }
label span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 14px; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.03); color: #fff; padding: 12px 14px; min-height: 46px; }
textarea { resize: vertical; min-height: 120px; }
.checkbox-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.03); }
.checkbox-row span { margin: 0; }
.checkbox-row input { width: auto; min-height: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 14px; padding: 11px 16px; cursor: pointer; color: #fff; background: rgba(255,255,255,.07); text-align: center; min-height: 44px; }
.btn-block { width: 100%; }
.btn-primary { background: linear-gradient(135deg, var(--primary), #6a5bff); }
.btn-secondary { background: linear-gradient(135deg, #19b8ff, #0f8cff); }
.btn-danger { background: rgba(255,93,115,.18); border-color: rgba(255,93,115,.25); }
.btn-ghost { background: rgba(255,255,255,.04); border-color: var(--line); }
.alert { padding: 14px 16px; border-radius: 16px; border: 1px solid var(--line); word-break: break-word; }
.alert-success { background: rgba(22,196,127,.15); }
.alert-warning { background: rgba(247,181,0,.16); }
.alert-error, .alert-danger { background: rgba(255,93,115,.18); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: rgba(255,255,255,.08); color: #fff; font-size: 12px; max-width: 100%; }
.status-active { background: rgba(22,196,127,.14); }
.status-warning { background: rgba(247,181,0,.16); }
.status-failed, .status-rejected { background: rgba(255,93,115,.18); }
.timeline-list { display: grid; gap: 12px; }
.timeline-item { padding: 14px 16px; border-radius: 16px; background: rgba(255,255,255,.03); border: 1px solid var(--line); min-width: 0; }
.timeline-item strong { display: block; line-height: 1.5; }
.timeline-item p { margin: 6px 0; color: var(--muted); word-break: break-word; }
.timeline-item span { color: var(--muted); font-size: 13px; word-break: break-word; }
.max-height { max-height: 700px; overflow: auto; }
.preview-card { margin-top: 16px; padding: 16px; border-radius: 16px; background: rgba(255,255,255,.04); border: 1px solid var(--line); }
.preview-card code { display: block; margin-top: 8px; white-space: pre-wrap; word-break: break-all; }
.code-preview { margin: 0; max-height: 420px; overflow: auto; white-space: pre-wrap; word-break: break-word; background: rgba(0,0,0,.25); border-radius: 16px; padding: 18px; border: 1px solid var(--line); }
.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.mini-stats div, .kv-list div { padding: 14px; border-radius: 16px; background: rgba(255,255,255,.03); border: 1px solid var(--line); min-width: 0; }
.mini-stats span, .kv-list span { color: var(--muted); word-break: break-word; }
.mini-stats strong { display: block; font-size: 24px; line-height: 1.1; margin-bottom: 6px; }
.kv-list { display: grid; gap: 12px; }
.kv-list strong { display: block; margin-bottom: 8px; word-break: break-word; }
.guest-body { min-height: 100vh; background: radial-gradient(circle at top left, rgba(79,124,255,.25), transparent 30%), linear-gradient(180deg, #060d1a, #0b1730); }
.guest-wrapper { min-height: 100vh; display: grid; place-items: center; padding: 30px; }
.login-card { width: min(1180px, 100%); display: grid; grid-template-columns: 1.2fr .8fr; gap: 22px; align-items: stretch; }
.login-hero, .login-panel .panel-card { min-height: 100%; }
.login-hero { padding: 34px; border-radius: 28px; background: linear-gradient(145deg, rgba(79,124,255,.18), rgba(127,92,255,.12)); border: 1px solid rgba(255,255,255,.1); box-shadow: var(--shadow); }
.login-hero h1 { font-size: 42px; line-height: 1.2; margin: 18px 0 16px; }
.login-hero p, .login-hero li { color: #c7d6f7; line-height: 1.8; }
.login-hero ul { padding-left: 20px; }
.login-panel { display: grid; }

@media (max-width: 1200px) {
    .stats-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

@media (max-width: 1024px) {
    .page-content, .topbar { padding-left: 20px; padding-right: 20px; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .topbar h1 { font-size: 28px; }
}

@media (max-width: 960px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(82vw, 300px); height: auto; transform: translateX(-105%); transition: transform .25s ease; box-shadow: var(--shadow); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop { display: block; position: fixed; inset: 0; border: 0; padding: 0; background: rgba(3, 9, 20, .56); opacity: 0; pointer-events: none; transition: opacity .25s ease; z-index: 15; }
    body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
    body.sidebar-open { overflow: hidden; }
    .menu-toggle { display: inline-flex; }
    .two-columns, .login-card { grid-template-columns: 1fr; }
    .topbar { padding-top: 18px; }
    .panel-head { align-items: flex-start; }
}

@media (max-width: 768px) {
    .panel-card, .stat-card { padding: 18px; border-radius: 18px; }
    .panel-head { margin-bottom: 14px; }
    .responsive-table { min-width: 0; }
    .responsive-table thead { display: none; }
    .responsive-table, .responsive-table tbody, .responsive-table tr, .responsive-table td { display: block; width: 100%; }
    .responsive-table tr { padding: 14px 0; border-bottom: 1px solid var(--line); }
    .responsive-table tr:first-child { padding-top: 0; }
    .responsive-table tr:last-child { border-bottom: 0; padding-bottom: 0; }
    .responsive-table td { border: 0; padding: 8px 0; display: grid; grid-template-columns: minmax(78px, 108px) minmax(0, 1fr); gap: 12px; align-items: start; }
    .responsive-table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .02em; }
    .responsive-table td > * { min-width: 0; }
    .responsive-table td .btn { width: 100%; }
    .table-wrap { overflow: visible; }
    .table-actions { width: 100%; }
    .table-actions form { flex: 1 1 100%; }
    .inline-form { flex-direction: column; align-items: stretch; }
    .inline-form > * { flex: 1 1 auto; width: 100%; }
    .inline-form .btn { width: 100%; }
    .mini-stats { grid-template-columns: 1fr; }
    .guest-wrapper { padding: 18px; }
    .login-hero { padding: 24px; border-radius: 22px; }
    .login-hero h1 { font-size: 32px; }
}

@media (max-width: 680px) {
    .page-content, .topbar { padding-left: 16px; padding-right: 16px; }
    .stats-grid { grid-template-columns: 1fr; }
    .topbar { gap: 12px; }
    .topbar h1 { font-size: 24px; }
    .topbar p { font-size: 14px; }
    .panel-card, .stat-card { padding: 16px; border-radius: 16px; }
    .login-hero h1 { font-size: 28px; }
    .login-hero ul { padding-left: 18px; }
    .responsive-table td { grid-template-columns: 1fr; gap: 4px; }
    .responsive-table td::before { margin-bottom: 2px; }
}
