:root {
    --navy: #13315c;
    --navy-2: #1b426c;
    --accent: #1fa67a;
    --gold: #f2b33d;
    --bg: #f3f6fb;
    --card: #fff;
    --text: #1d2939;
    --muted: #667085;
    --line: #e4e9f2;
    --radius: 14px;
    --sidebar-w: 268px;
}

body.admin, body.auth-body {
    font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14.5px;
}

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
    background: linear-gradient(180deg, #0f2747 0%, var(--navy) 55%, #102a4c 100%);
    color: #c9d6ea; overflow-y: auto; z-index: 1040; transition: transform .25s ease;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent;
}
.sidebar .brand {
    display: flex; align-items: center; gap: 12px; padding: 20px 22px; text-decoration: none; color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .brand img { width: 42px; height: 42px; border-radius: 10px; background: #fff; padding: 3px; }
.sidebar .brand b { display: block; font-size: 18px; letter-spacing: .5px; }
.sidebar .brand small { display: block; font-size: 11.5px; color: var(--gold); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
.side-nav { padding: 12px 12px 30px; }
.side-nav a {
    display: flex; align-items: center; gap: 11px; padding: 9px 12px; margin: 2px 0; border-radius: 10px;
    color: #c9d6ea; text-decoration: none; font-weight: 500; font-size: 14px;
}
.side-nav a i { font-size: 16px; width: 18px; text-align: center; opacity: .9; }
.side-nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.side-nav a.active { background: linear-gradient(90deg, var(--accent), #23b98a); color: #fff; box-shadow: 0 6px 18px rgba(31,166,122,.35); }
.side-nav a.sub { padding: 7px 12px 7px 40px; font-size: 13.2px; }
.side-nav a.sub.active { background: rgba(255,255,255,.12); box-shadow: none; }
.side-nav a.sub em { color: #f88; font-style: normal; font-size: 11px; }
.side-nav .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.side-nav .chev { font-size: 12px; transition: transform .2s; }
.side-nav .side-toggle:not(.collapsed) .chev { transform: rotate(180deg); }
.side-label { text-transform: uppercase; font-size: 11px; letter-spacing: 1.1px; color: #7f97bb; padding: 16px 12px 6px; font-weight: 700; }

/* ---------- Main ---------- */
.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: 12px;
    padding: 12px 28px; background: rgba(243,246,251,.85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.page-title { font-size: 20px; font-weight: 700; margin: 0; }
.user-chip { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); background: #fff; border-radius: 40px; padding: 5px 14px 5px 5px; }
.user-chip small { color: var(--muted); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--navy-2); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.btn-icon { border: 1px solid var(--line); background: #fff; border-radius: 10px; }
.content { padding: 24px 28px; flex: 1; }
.admin-foot { padding: 16px 28px; color: var(--muted); font-size: 12.5px; border-top: 1px solid var(--line); }

/* ---------- Unit context bar ---------- */
.unit-bar {
    margin: 20px 28px 0; border-radius: var(--radius); color: #fff; padding: 18px 20px 0;
    background: linear-gradient(120deg, var(--uc) 0%, color-mix(in srgb, var(--uc) 70%, #0b1f3a) 100%);
    box-shadow: 0 10px 30px -12px color-mix(in srgb, var(--uc) 70%, transparent);
}
.unit-logo { width: 52px; height: 52px; border-radius: 12px; background: #fff; object-fit: contain; padding: 4px; }
.unit-tabs { display: flex; gap: 4px; overflow-x: auto; margin-top: 16px; scrollbar-width: none; }
.unit-tabs a { color: rgba(255,255,255,.82); text-decoration: none; padding: 10px 14px; border-radius: 10px 10px 0 0; white-space: nowrap; font-weight: 600; font-size: 13.5px; }
.unit-tabs a:hover { color: #fff; background: rgba(255,255,255,.1); }
.unit-tabs a.active { background: var(--bg); color: var(--text); }

/* ---------- Cards / UI ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0 !important; padding: 14px 18px; font-weight: 700; }
.stat {
    border-radius: var(--radius); padding: 18px; background: #fff; border: 1px solid var(--line); height: 100%;
    display: flex; gap: 14px; align-items: center; position: relative; overflow: hidden;
}
.stat .ico { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; color: #fff; flex: 0 0 48px; }
.stat .num { font-size: 26px; font-weight: 800; line-height: 1; }
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 4px; }
.mod-card { display: block; text-decoration: none; color: inherit; transition: .2s; }
.mod-card:hover { transform: translateY(-3px); box-shadow: 0 12px 28px -12px rgba(16,24,40,.25); }
.mod-card .ico { background: color-mix(in srgb, var(--uc, #1b426c) 12%, #fff); color: var(--uc, #1b426c); }
.table { --bs-table-bg: transparent; margin: 0; }
.table > :not(caption) > * > * { padding: 11px 14px; border-color: var(--line); vertical-align: middle; }
.table thead th { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); background: #f8fafc; font-weight: 700; }
.thumb { width: 54px; height: 42px; object-fit: cover; border-radius: 8px; background: #eef2f7; }
.thumb-round { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
.badge-status { font-weight: 600; letter-spacing: .2px; }
.btn { border-radius: 10px; font-weight: 600; }
.btn-primary { background: var(--navy-2); border-color: var(--navy-2); }
.btn-primary:hover { background: var(--navy); border-color: var(--navy); }
.btn-success { background: var(--accent); border-color: var(--accent); }
.form-control, .form-select { border-radius: 10px; border-color: #d6dde8; padding: .55rem .8rem; }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 .2rem rgba(31,166,122,.15); }
.form-label { font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.req::after { content: " *"; color: #d92d20; }
.filters { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty i { font-size: 42px; display: block; margin-bottom: 10px; opacity: .5; }
.gallery-edit { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.gallery-edit label { position: relative; cursor: pointer; }
.gallery-edit img { width: 100%; height: 95px; object-fit: cover; border-radius: 10px; border: 2px solid transparent; }
.gallery-edit input:checked + img { border-color: #d92d20; opacity: .45; }
.gallery-edit .rm { position: absolute; top: 6px; right: 6px; background: #fff; border-radius: 6px; font-size: 11px; padding: 1px 6px; color: #d92d20; font-weight: 700; }
.preview-grid { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.preview-grid img { width: 80px; height: 64px; object-fit: cover; border-radius: 8px; }
.drop {
    border: 2px dashed #c8d3e3; border-radius: 12px; padding: 18px; text-align: center; background: #fafcff; color: var(--muted); cursor: pointer; transition: .2s;
}
.drop:hover, .drop.drag { border-color: var(--accent); background: #f1fbf7; }
.form-section { font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--navy-2); margin: 6px 0 12px; }
.perm-table th, .perm-table td { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; position: sticky; left: 0; background: #fff; z-index: 1; }
.log-details { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: #f6f8fb; border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; margin: 6px 0 0; max-width: 620px; }
.timeline-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.timeline-item:last-child { border-bottom: 0; }
.timeline-item .ico { width: 34px; height: 34px; border-radius: 50%; background: #eef4ff; color: var(--navy-2); display: flex; align-items: center; justify-content: center; flex: 0 0 34px; }
.team-card { text-align: center; padding: 18px 12px; }
.team-card img { width: 92px; height: 92px; border-radius: 50%; object-fit: cover; border: 3px solid #fff; box-shadow: 0 4px 14px rgba(0,0,0,.12); }
.switch-lg .form-check-input { width: 2.6em; height: 1.4em; }

/* ---------- Auth ---------- */
.auth-body {
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
    background: radial-gradient(1200px 600px at 10% 10%, rgba(31,166,122,.18), transparent 60%),
                radial-gradient(900px 500px at 90% 90%, rgba(242,179,61,.18), transparent 60%),
                linear-gradient(135deg, #0f2747, #1b426c);
}
.auth-card { width: 100%; max-width: 430px; background: #fff; border-radius: 20px; padding: 36px 34px; box-shadow: 0 30px 80px -20px rgba(0,0,0,.45); }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1035; }
    .main { margin-left: 0; }
    .content { padding: 18px 14px; }
    .topbar { padding: 10px 14px; }
    .unit-bar { margin: 14px 14px 0; }
}
