:root {
  --sidebar-w: 260px;
  --topbar-h: 64px;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e6e9f0;
  --text: #1e2533;
  --muted: #6b7385;
  --primary: #4f46e5;
  --primary-soft: #eef0ff;
  --side-bg: #111827;
  --side-text: #c7cbd6;
  --radius: 14px;
  --bs-primary: #4f46e5;
  --bs-primary-rgb: 79, 70, 229;
  --bs-link-color: #4f46e5;
  --bs-link-color-rgb: 79, 70, 229;
  --bs-link-hover-color: #3730a3;
  --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
body { background: var(--bg); color: var(--text); font-family: var(--bs-body-font-family); }
.btn-primary { --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: #4338ca; --bs-btn-hover-border-color: #4338ca; --bs-btn-active-bg: #3730a3; }
.btn-outline-primary { --bs-btn-color: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: var(--primary); --bs-btn-hover-border-color: var(--primary); }
.form-control:focus, .form-select:focus { border-color: #a5b4fc; box-shadow: 0 0 0 .2rem rgba(79,70,229,.15); }
.nav-pills .nav-link.active { background: var(--primary); }

/* ---------- auth pages ---------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(1200px 600px at 10% -10%, #4f46e5 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #0ea5e9 0%, transparent 55%), #0f172a; }
.auth-box { width: 100%; max-width: 420px; }
.auth-brand { color: #fff; font-weight: 700; font-size: 1.15rem; display: flex; align-items: center; gap: .6rem; justify-content: center; margin-bottom: 1.25rem; }
.auth-box .card { border-radius: var(--radius); border: 0; }

/* ---------- shell ---------- */
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: inline-grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #6366f1, #0ea5e9); font-size: 1rem; flex: none; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--side-bg); color: var(--side-text);
  flex-direction: column; z-index: 1030; overflow-y: auto; }
.sidebar-mobile { width: var(--sidebar-w) !important; display: flex; }
.brand { display: flex; align-items: center; gap: .7rem; padding: 18px 18px 14px; color: #fff; font-weight: 700; text-decoration: none; font-size: .98rem; }
.brand:hover { color: #fff; }
.side-nav { padding: 6px 12px; }
.side-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #6b7385; padding: 10px 10px 6px; font-weight: 600; }
.side-link { display: flex; align-items: center; gap: .7rem; padding: 9px 10px; border-radius: 10px; color: var(--side-text);
  text-decoration: none; font-size: .9rem; font-weight: 500; }
.side-link .bi { font-size: 1.05rem; width: 20px; text-align: center; }
.side-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-link.active { background: rgba(99,102,241,.22); color: #fff; }
.side-link .dot { width: 10px; height: 10px; border-radius: 50%; margin: 0 5px; flex: none; }
.side-count { margin-left: auto; font-size: .75rem; background: rgba(255,255,255,.08); padding: 1px 8px; border-radius: 20px; }
.side-user { margin-top: auto; display: flex; align-items: center; gap: .7rem; padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); color: #fff; }

.app-main { min-height: 100vh; }
@media (min-width: 992px) { .app-main { margin-left: var(--sidebar-w); } }
.topbar { position: sticky; top: 0; z-index: 1020; height: var(--topbar-h); display: flex; align-items: center; gap: 12px;
  padding: 0 24px; background: rgba(255,255,255,.85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topbar-title { font-weight: 600; font-size: 1rem; }
.site-jump { position: relative; width: 280px; max-width: 50vw; }
.site-jump .bi { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.site-jump input { padding-left: 34px; border-radius: 10px; background: var(--bg); border-color: transparent; }
.content { padding: 24px; max-width: 1400px; }
.content-fluid { max-width: none; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 18px 24px 0; }
.site-tabs { gap: .25rem; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.site-tabs .nav-link { color: var(--muted); font-weight: 500; font-size: .9rem; padding: .6rem .75rem; white-space: nowrap; }
.site-tabs .nav-link.active, .site-tabs .nav-link:hover { color: var(--primary); }
.site-tabs .nav-link.active { border-bottom-color: var(--primary); }

/* ---------- avatars ---------- */
.avatar { --hue: 240; width: 42px; height: 42px; border-radius: 12px; flex: none; display: inline-grid; place-items: center; overflow: hidden;
  font-weight: 700; color: hsl(var(--hue) 55% 35%); background: hsl(var(--hue) 70% 92%); font-size: 1.05rem; }
.avatar img { width: 70%; height: 70%; object-fit: contain; }
.avatar-sm { width: 34px; height: 34px; font-size: .9rem; border-radius: 10px; }
.avatar-lg { width: 52px; height: 52px; font-size: 1.3rem; border-radius: 14px; }

/* ---------- cards ---------- */
.card { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { border-bottom-color: var(--border); }
.card > .card-header:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.table > :not(caption) > * > * { padding: .7rem .9rem; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.5rem; font-weight: 700; margin: 0; }
.page-head p { color: var(--muted); margin: .25rem 0 0; }

.stat-card { padding: 18px; display: flex; flex-direction: row; align-items: center; gap: 14px; height: 100%; }
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; flex: none; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .85rem; }

/* ---------- dashboard ---------- */
.chips { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 30px; padding: .4rem .85rem; font-size: .85rem;
  font-weight: 500; color: var(--text); display: inline-flex; align-items: center; gap: .45rem; cursor: pointer; }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.chip .n { color: var(--muted); font-weight: 600; }
.chip.active { background: var(--text); color: #fff; border-color: var(--text); }
.chip.active .n { color: #cbd5e1; }

.site-section { margin-bottom: 1.75rem; }
.section-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .8rem; }
.section-head .dot { width: 12px; height: 12px; border-radius: 4px; }
.section-head h2 { font-size: 1.05rem; font-weight: 700; margin: 0; }
.section-head .count { font-size: .78rem; color: var(--muted); background: #e9ecf3; padding: 2px 10px; border-radius: 20px; font-weight: 600; }

.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.site-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 12px; height: 100%; transition: box-shadow .15s, border-color .15s, transform .15s; }
.site-card:hover { border-color: #c7d2fe; box-shadow: 0 8px 24px rgba(79,70,229,.10); transform: translateY(-1px); }
.site-card .top { display: flex; gap: 12px; align-items: center; min-width: 0; }
.site-card .name { font-weight: 600; font-size: .95rem; word-break: break-all; line-height: 1.25; }
.site-card .domain { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-card .tags { display: flex; gap: .3rem; flex-wrap: wrap; }
.site-card .tag { font-size: .7rem; padding: 1px 8px; border-radius: 20px; background: #f1f3f9; color: var(--muted); display: inline-flex; align-items: center; gap: .3rem; }
.site-card .tag i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.site-card .actions { display: flex; gap: 4px; margin-top: auto; position: relative; z-index: 2; }
.site-card .actions .btn { --bs-btn-padding-y: .3rem; --bs-btn-padding-x: .55rem; border-radius: 8px; color: var(--muted); background: #f5f6fa; border: 0; }
.site-card .actions .btn:hover { background: var(--primary-soft); color: var(--primary); }

.view-list .site-grid { grid-template-columns: 1fr; gap: 8px; }
.view-list .site-card { flex-direction: row; align-items: center; padding: 10px 14px; }
.view-list .site-card .top { flex: 1; }
.view-list .site-card .tags { flex: none; }
.view-list .site-card .actions { margin-top: 0; }

.activity-item { display: flex; gap: .75rem; padding: .75rem 1rem; border-bottom: 1px solid var(--border); font-size: .85rem; }
.activity-item:last-child { border-bottom: 0; }

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty-state .bi { font-size: 2.2rem; color: #c3c8d6; }

/* ---------- groups page ---------- */
.site-picker { max-height: 260px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; padding: .5rem .75rem;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .15rem .75rem; }
.site-chip { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; background: #f1f3f9; border-radius: 20px; padding: 2px 10px; margin: 0 .25rem .3rem 0; }
.swatches { display: flex; gap: .4rem; flex-wrap: wrap; }
.swatches label { width: 28px; height: 28px; border-radius: 8px; cursor: pointer; border: 2px solid transparent; }
.swatches input { display: none; }
.swatches input:checked + label { border-color: var(--text); box-shadow: inset 0 0 0 2px #fff; }

/* ---------- existing pages ---------- */
.file-table td, .file-table th { vertical-align: middle; }
.file-table .name { word-break: break-all; }
.file-table .actions { white-space: nowrap; }

.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1rem; }
.img-tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.img-tile .thumb { height: 130px; display: flex; align-items: center; justify-content: center; cursor: zoom-in;
  background: repeating-conic-gradient(#eef0f5 0% 25%, #fff 0% 50%) 50% / 16px 16px; }
.img-tile .thumb img { max-width: 100%; max-height: 130px; object-fit: contain; }
.img-tile .meta { padding: .5rem .6rem; font-size: .78rem; flex: 1; }
.img-tile .meta .fn { font-weight: 600; word-break: break-all; }

.CodeMirror { height: calc(100vh - 330px); min-height: 400px; border-radius: 10px; font-size: 14px; }
.editor-toolbar { position: sticky; top: var(--topbar-h); z-index: 5; background: var(--bg) !important; }

.match-line { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .8rem; white-space: pre-wrap; word-break: break-all; }
mark { padding: 0 .1em; background: #ffe066; }
code.id { font-size: .9rem; }

@media (max-width: 991px) {
  .topbar { padding: 0 16px; }
  .content { padding: 16px; }
  .site-header { padding: 14px 16px 0; }
  .site-jump { width: auto; flex: 1; max-width: none; }
  .topbar-title { display: none; }
}
@media (max-width: 575px) {
  .view-list .site-card { flex-wrap: wrap; }
  .view-list .site-card .actions { width: 100%; }
}
.page-filter { width: 260px; }
@media (max-width: 575px) { .page-filter { width: 100%; max-width: none; flex: 1 1 100%; } .page-head > .ms-auto { width: 100%; } }
.file-table a, .breadcrumb a, .activity-item a { text-decoration: none; }
