:root {
    --bg: #0a0d14;
    --surface: #121826;
    --surface-2: #1a2233;
    --surface-3: #0f1625;
    --text: #e7edf7;
    --muted: #94a0b4;
    --primary: #5b8dff;
    --danger: #ea5d74;
    --border: #263148;
    --ok: #1ea978;
    --warn: #c8922a;
    --shadow: 0 14px 34px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, Segoe UI, sans-serif; background: radial-gradient(circle at top right, #16233f 0%, var(--bg) 35%); color: var(--text); }
a { color: inherit; text-decoration: none; }

.dark-body { background: var(--bg); }
.auth-body { display: grid; min-height: 100vh; place-items: center; }
.auth-card {
    width: min(420px, 92vw);
    background: linear-gradient(160deg, rgba(20,27,40,.95), rgba(13,18,28,.95));
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 26px;
    box-shadow: var(--shadow);
}

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 270px;
    background: linear-gradient(180deg, #141d2e 0%, #111a2a 100%);
    border-right: 1px solid var(--border);
    padding: 14px;
    transition: width .2s ease, transform .2s ease;
    position: sticky;
    top: 0;
    height: 100vh;
    box-shadow: var(--shadow);
    z-index: 32;
}
.sidebar.collapsed { width: 72px; }
.sidebar .brand { font-size: 1.08rem; font-weight: 700; letter-spacing: .06em; }
.sidebar.collapsed .label, .sidebar.collapsed .brand-wrap .brand { display: none; }
.brand-wrap { display: flex; align-items: center; gap: 10px; margin: 14px 6px 18px; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 16px rgba(91, 141, 255, .8); }
.sidebar-toggle {
    width: 100%;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    cursor: pointer;
}
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(3, 7, 12, .72);
    z-index: 31;
}
.menu { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px;
    border-radius: 12px;
    border: 1px solid transparent;
    color: #c7d3e8;
    transition: all .16s ease;
}
.menu-item:hover { background: rgba(255, 255, 255, .03); }
.menu-item.active { background: linear-gradient(90deg, rgba(91,141,255,.22), rgba(91,141,255,.06)); border-color: rgba(91,141,255,.35); color: #fff; }

.topbar-left { display: flex; align-items: center; gap: 10px; }
.btn-menu { display: none; }

.main-area { flex: 1; min-width: 0; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: rgba(10, 13, 20, .92);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(8px);
}
.topbar-title { font-weight: 600; font-size: 1.04rem; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.content-area { padding: 20px; display: grid; gap: 16px; }

.card {
    background: linear-gradient(180deg, rgba(18,24,38,.98) 0%, rgba(15,22,37,.98) 100%);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, .18);
}
h1, h2, h3, h4 { margin: 0 0 10px; }
.muted { color: var(--muted); }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat strong { font-size: 1.6rem; }
.dashboard-stats { gap: 8px; }
.dashboard-stats .card.stat { padding: 10px 12px; border-radius: 10px; }
.dashboard-stats .card.stat h3 { font-size: .82rem; margin-bottom: 6px; color: var(--muted); }
.dashboard-stats .card.stat strong { font-size: 1.2rem; line-height: 1.1; }
.two-cols { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.simple-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.simple-list li { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }

input, textarea, select {
    width: 100%;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #0f1726;
    color: var(--text);
    transition: border-color .14s ease, box-shadow .14s ease;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: rgba(91, 141, 255, .6); box-shadow: 0 0 0 3px rgba(91, 141, 255, .15); }
textarea { resize: vertical; }
label { display: block; margin: 0 0 6px; font-size: .92rem; color: var(--muted); }

.btn {
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    border-radius: 10px;
    padding: 9px 12px;
    cursor: pointer;
    transition: transform .12s ease, filter .12s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn-primary { background: var(--primary); border-color: transparent; color: #fff; }
.btn-danger { background: var(--danger); border-color: transparent; color: #fff; }
.alert { padding: 10px; background: #42212a; border: 1px solid #723646; border-radius: 10px; margin-bottom: 12px; }
.alert-ok { background: rgba(24, 94, 67, .32); border-color: rgba(35, 164, 118, .55); }

.grid-form { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.full-width { grid-column: 1 / -1; }
.stack-form { display: grid; gap: 10px; }
.filter-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.checkbox-inline { display: flex; align-items: center; gap: 8px; color: var(--text); }
.checkbox-inline input { width: auto; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; border-bottom: 1px solid var(--border); padding: 10px 6px; vertical-align: top; }
th { color: #c9d6ec; font-weight: 600; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.badge { padding: 4px 8px; border-radius: 999px; font-size: .78rem; }
.badge.ok { background: rgba(31, 157, 116, .15); color: #66d3ac; }
.badge.warn { background: rgba(198, 138, 35, .15); color: #ebb35d; }

.gallery-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.gallery-item img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px; cursor: zoom-in; }

.modal {
    position: fixed;
    inset: 0;
    background: rgba(4, 8, 12, .8);
    display: grid;
    place-items: center;
    padding: 20px;
    z-index: 20;
}
.modal[hidden] { display: none !important; }
.modal-panel {
    width: min(780px, 96vw);
    max-height: 88vh;
    overflow: auto;
    background: linear-gradient(180deg, rgba(18,24,38,.99), rgba(15,22,37,.99));
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.modal-body.scroll { max-height: 52vh; overflow-y: auto; white-space: pre-wrap; background: #101521; border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.modal-foot { margin-top: 10px; display: flex; justify-content: flex-end; }
.modal-image img { width: 100%; border-radius: 8px; }

.fab {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 40;
    padding: 12px 14px;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    border: 1px solid transparent;
    box-shadow: var(--shadow);
}

@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .gallery-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 768px) {
    .btn-menu { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; }
    .sidebar { position: fixed; z-index: 32; transform: translateX(-100%); width: 270px; }
    .sidebar.mobile-open { transform: translateX(0); }
    .sidebar.collapsed { width: 270px; }
    .sidebar.collapsed .label, .sidebar.collapsed .brand-wrap .brand { display: initial; }
    .main-area { margin-left: 0; }
    .content-area { padding: 14px; }
    .topbar { padding: 10px 12px; }
    .topbar-user > span { display: none; }
    .two-cols, .stats-grid, .grid-form, .gallery-grid { grid-template-columns: 1fr; }
    .dashboard-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .dashboard-stats .card.stat { padding: 9px 10px; }
    .dashboard-stats .card.stat h3 { font-size: .76rem; }
    .dashboard-stats .card.stat strong { font-size: 1.02rem; }
    .filter-form { grid-template-columns: 1fr; }
    .actions .btn { width: 100%; }
    .fab { right: 12px; bottom: 12px; }
}

@media (max-width: 430px) {
    .dashboard-stats { grid-template-columns: 1fr; }
}
