/* ============================================================
   CCHPS Dashboard — modern UI  (v4 — premium, colorful, glassy, dark-mode)
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Sora:wght@600;700;800&display=swap');

:root {
  --font-body: "Manrope", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --font-display: "Sora", "Manrope", "Segoe UI", system-ui, sans-serif;
  --shadow-glow: 0 10px 30px -8px color-mix(in srgb, var(--brand-3) 45%, transparent);
  --brand-1: #0b3d52;
  --brand-2: #12657f;
  --brand-3: #2ba8c4;
  --accent:  #ff9f1c;
  --accent-2:#ff5d73;
  --violet:  #7c5cff;
  --green:   #16b982;
  --bg:      #eef3f7;
  --card:    #ffffff;
  --panel2:  #f4f8fb;
  --text:    #16232b;
  --muted:   #6b7f8c;
  --line:    #e4ecf1;
  --danger:  #e0344b;
  --ok:      #10a074;
  --radius:  16px;
  --shadow:  0 4px 18px rgba(11,61,82,.09);
  --shadow-lg: 0 14px 40px rgba(11,61,82,.20);
  --proj-1:  var(--brand-2);
  --proj-2:  var(--brand-3);
}
html[data-theme="dark"] {
  --bg:      #0a121b;
  --card:    #101c28;
  --panel2:  #142230;
  --text:    #e8f1f6;
  --muted:   #8fa6b3;
  --line:    #1e3040;
  --shadow:  0 4px 18px rgba(0,0,0,.35);
  --shadow-lg: 0 14px 40px rgba(0,0,0,.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--text);
  min-height: 100vh;
  background:
    radial-gradient(1200px 480px at 108% -8%, rgba(43,168,196,.16), transparent 60%),
    radial-gradient(900px 420px at -10% 4%, rgba(124,92,255,.12), transparent 55%),
    var(--bg);
  transition: background-color .2s ease, color .2s ease;
}
h1, h2, h3, .tbtitle, .page-title, .sectitle, .stat .big, .glass h1, .rootnode { font-family: var(--font-display); letter-spacing: -.01em; }
a { color: var(--brand-2); text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }
html[data-theme="dark"] a { color: #6fd0e8; }
.muted { color: var(--muted); }
.grow { flex: 1; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ================= LOGIN ================= */
#gate { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; overflow: hidden; padding: 20px;
  background: radial-gradient(900px 500px at 15% 10%, rgba(124,92,255,.35), transparent 55%),
              radial-gradient(1000px 560px at 90% 90%, rgba(255,93,115,.32), transparent 55%),
              linear-gradient(135deg, #072a39 0%, #0b3d52 45%, #12657f 100%); }
#gate .aurora { position: absolute; inset: -30%; background: conic-gradient(from 0deg, var(--brand-3), var(--violet), var(--accent-2), var(--brand-3)); filter: blur(110px); opacity: .35; animation: spin 24s linear infinite; }
.glass { position: relative; width: min(93vw, 430px); background: rgba(255,255,255,.97); border: 1px solid rgba(255,255,255,.6); border-radius: 22px; padding: 36px 34px; box-shadow: 0 30px 70px rgba(0,0,0,.42); animation: pop .45s ease both; }
.glass .brand { display: flex; align-items: center; gap: 12px; }
.glass .mark { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; font-size: 26px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 10px 26px rgba(255,93,115,.45); animation: pop .5s cubic-bezier(.2,.9,.3,1.4) both; }
.glass h1 { font-size: 21px; margin: 18px 0 4px; color: var(--brand-1); font-weight: 800; }
.glass p { color: var(--muted); margin: 0 0 16px; font-size: 13px; }
.glass label { font-size: 12.5px; color: var(--muted); font-weight: 700; display: block; margin: 12px 0 6px; }
.glass input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1.5px solid #cdd9e0; background: #fbfdfe; color: var(--text); font-size: 14.5px; outline: none; transition: border-color .15s ease, box-shadow .15s ease; }
.glass input:focus { border-color: var(--brand-3); box-shadow: 0 0 0 3px rgba(43,168,196,.2); }
.roles-note { margin-top: 20px; background: linear-gradient(135deg, #f2f9fb, #eef4ff); border: 1px solid #dce9f0; padding: 13px 15px; border-radius: 12px; font-size: 12.5px; color: #35525e; line-height: 1.7; }
.err { color: #e11d48; font-size: 13px; min-height: 16px; margin-top: 10px; }
.tiny { margin-top: 12px; font-size: 12px; color: var(--muted); text-align: center; }

/* ================= TOP BAR ================= */
@keyframes topbarSheen { 0% { background-position: 0% 50%; } 100% { background-position: 200% 50%; } }
.topbar {
  background: linear-gradient(115deg, #082e3e 0%, var(--brand-1) 30%, var(--brand-2) 60%, var(--brand-3) 90%, var(--brand-2) 120%);
  background-size: 220% 100%;
  animation: topbarSheen 18s ease-in-out infinite alternate;
  color: #fff; padding: 0 24px; display: flex; align-items: center; gap: 18px; height: 64px;
  box-shadow: 0 6px 22px rgba(8,46,62,.32); position: sticky; top: 0; z-index: 60;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brandmini { display: flex; align-items: center; gap: 11px; color: #fff; }
.brandmini:hover { text-decoration: none; }
.brandmini .mark { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: flex; align-items: center; justify-content: center; font-size: 19px; box-shadow: 0 4px 14px rgba(255,93,115,.5); flex-shrink: 0; }
.tbtitle { font-weight: 800; font-size: 16.5px; line-height: 1.2; }
.brandmini small { color: #dcf0f6; }
.topnav { display: flex; gap: 3px; margin-left: 8px; flex-wrap: wrap; }
.topnav a { color: #dcf0f6; padding: 9px 14px; border-radius: 10px; font-size: 14px; font-weight: 600; transition: background .16s ease, transform .16s ease; }
.topnav a:hover { background: rgba(255,255,255,.16); text-decoration: none; transform: translateY(-1px); }
.topnav a.active { background: rgba(255,255,255,.24); color: #fff; box-shadow: inset 0 -2px 0 var(--accent); }
.userchip { position: relative; display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: #eaf6fa; cursor: pointer; padding: 5px 10px 5px 5px; border-radius: 30px; transition: background .15s ease; }
.userchip:hover { background: rgba(255,255,255,.12); }
/* .ava is used both inside the top-bar user chip AND standalone (e.g. the
   member avatar bubble on admin_users.php) — base look lives on .ava itself
   so it works everywhere; .userchip .ava only adds the chip-specific size/glow. */
.ava { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: 0 0 0 2px rgba(255,255,255,.35); }
.userchip .ava { box-shadow: 0 3px 12px rgba(255,93,115,.45), 0 0 0 2px rgba(255,255,255,.35); transition: box-shadow .18s ease; }
.userchip:hover .ava { box-shadow: 0 3px 14px rgba(255,93,115,.55), 0 0 0 3px rgba(255,255,255,.55); }
html[data-theme="dark"] .ava { box-shadow: 0 0 0 2px rgba(255,255,255,.12); }
.userchip .role { color: #ffe3b0; text-transform: capitalize; }
.userchip .menu { display: none; position: absolute; right: 0; top: 48px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); min-width: 190px; overflow: hidden; z-index: 70; }
.userchip .menu.open { display: block; animation: pop .15s ease both; }
.userchip .menu a { display: block; padding: 11px 15px; font-size: 13.5px; color: var(--text); }
.userchip .menu a:hover { background: var(--panel2); text-decoration: none; }

/* ================= FLASHBOX ================= */
@keyframes flashIn { from { opacity: 0; transform: translateY(-14px) scale(.98); } to { opacity: 1; transform: none; } }
.flash {
  margin: 14px 24px 0; padding: 14px 18px 14px 16px; border-radius: 14px; font-size: 14px; font-weight: 600;
  animation: flashIn .35s cubic-bezier(.2,.8,.2,1) both;
  border-left: 4px solid var(--ok);
  background: linear-gradient(120deg, color-mix(in srgb, var(--ok) 12%, var(--card)), var(--card));
  backdrop-filter: blur(6px);
  color: #06603f; display: flex; gap: 12px; align-items: center;
  box-shadow: 0 8px 24px -8px color-mix(in srgb, var(--ok) 45%, transparent), 0 1px 0 rgba(255,255,255,.4) inset;
}
.flash::before { content: "✓"; display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--ok); color: #fff; font-size: 12px; font-weight: 800; flex-shrink: 0; }
.flash.error { border-color: var(--danger); background: linear-gradient(120deg, color-mix(in srgb, var(--danger) 12%, var(--card)), var(--card)); color: #93132a; box-shadow: 0 8px 24px -8px color-mix(in srgb, var(--danger) 45%, transparent), 0 1px 0 rgba(255,255,255,.4) inset; }
.flash.error::before { content: "!"; background: var(--danger); }
.flash.warn { border-color: var(--accent); background: linear-gradient(120deg, color-mix(in srgb, var(--accent) 14%, var(--card)), var(--card)); color: #8a5a00; box-shadow: 0 8px 24px -8px color-mix(in srgb, var(--accent) 45%, transparent), 0 1px 0 rgba(255,255,255,.4) inset; }
.flash.warn::before { content: "⚠"; background: var(--accent); }
.flash span { margin-left: auto; cursor: pointer; opacity: .6; font-weight: 800; transition: opacity .15s ease, transform .15s ease; }
.flash span:hover { opacity: 1; transform: scale(1.15); }
html[data-theme="dark"] .flash { color: #7fe0bd; box-shadow: 0 8px 24px -8px rgba(16,160,116,.35), 0 1px 0 rgba(255,255,255,.05) inset; }
html[data-theme="dark"] .flash.error { color: #ff9fae; box-shadow: 0 8px 24px -8px rgba(224,52,75,.35), 0 1px 0 rgba(255,255,255,.05) inset; }
html[data-theme="dark"] .flash.warn { color: #ffd08a; box-shadow: 0 8px 24px -8px rgba(255,159,28,.3), 0 1px 0 rgba(255,255,255,.05) inset; }

/* ================= LAYOUT ================= */
.pagewrap { max-width: 1320px; margin: 24px auto 60px; padding: 0 24px; animation: fadeUp .35s ease both; }
main.pagewrap { display: block; }
.grid { display: grid; gap: 18px; }
.grid.cols-4 { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; border: 1px solid var(--line); animation: pop .35s ease both; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--brand-3) 30%, var(--line)); }
.card h3 { color: var(--brand-1); margin-bottom: 6px; font-size: 16px; }
html[data-theme="dark"] .card h3 { color: #7fd6ec; }

.page-title { margin: 4px 0 20px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-title h1 { font-size: 23px; color: var(--brand-1); font-weight: 800; }
html[data-theme="dark"] .page-title h1 { color: #a9e6f7; }
.page-title .sub { color: var(--muted); font-size: 14px; }
.sectitle { margin: 30px 0 12px; color: var(--brand-1); font-size: 18px; font-weight: 800; }
html[data-theme="dark"] .sectitle { color: #a9e6f7; }

/* ================= PROJECT BAR ================= */
.projectbar {
  background: rgba(255,255,255,.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); padding: 13px 24px; display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap; position: sticky; top: 64px; z-index: 55;
}
html[data-theme="dark"] .projectbar { background: rgba(16,28,40,.85); }
.projectbar label { font-weight: 700; color: var(--brand-1); font-size: 14px; }
html[data-theme="dark"] .projectbar label { color: #a9e6f7; }
.projectbar .selwrap { position: relative; }
.projectbar select {
  appearance: none; padding: 10px 40px 10px 16px; border: none; border-radius: 12px; font-size: 14.5px; font-weight: 700;
  color: #fff; cursor: pointer; min-width: 230px;
  background: linear-gradient(120deg, var(--proj-1), var(--proj-2));
  box-shadow: 0 6px 16px rgba(18,101,127,.28);
}
/* The <select> itself is styled with a colored gradient + white text for
   the closed pill look, but the native dropdown OPTION LIST always renders
   on the OS/browser's own white(ish) popup background — so options must be
   given their own dark-on-light colors explicitly, or white-on-white makes
   them unreadable when the list opens. */
.projectbar select option {
  color: #0f2733;
  background: #ffffff;
  font-weight: 600;
}
html[data-theme="dark"] .projectbar select option {
  color: #eaf6fa;
  background: #16303f;
}
.projectbar .selwrap::after { content: "▾"; position: absolute; right: 15px; top: 50%; transform: translateY(-50%); color: #fff; pointer-events: none; font-size: 13px; }
.projectbar .proj-desc { color: var(--muted); font-size: 12.5px; max-width: 300px; }
.projectbar .pb-search { flex: 1; min-width: 200px; }
.projectbar .pb-search input { width: 100%; padding: 10px 14px; border: 1.5px solid var(--line); border-radius: 11px; font-size: 13.5px; background: var(--card); color: var(--text); }
.projectbar .pb-search input:focus { outline: none; border-color: var(--proj-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--proj-2) 20%, transparent); }
.projectbar .proj-chip { font-size: 11.5px; font-weight: 700; color: var(--brand-1); background: linear-gradient(135deg, rgba(43,168,196,.16), rgba(124,92,255,.14)); padding: 6px 13px; border-radius: 999px; border: 1px solid rgba(43,168,196,.3); white-space: nowrap; }
html[data-theme="dark"] .projectbar .proj-chip { color: #a9e6f7; }
.btn-upload-top { white-space: nowrap; }

/* ================= APP SHELL ================= */
.wrap-app { display: grid; grid-template-columns: 280px 1fr; gap: 20px; align-items: start; margin-top: 20px; }
@media (max-width: 900px) { .wrap-app { grid-template-columns: 1fr; } }
.sidebar { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; position: sticky; top: 150px; border: 1px solid var(--line); max-height: calc(100vh - 176px); overflow-y: auto; }
.sidebar .sb-head { font-size: 12px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); padding: 6px 12px 12px; }
.sb-sep { height: 1px; background: var(--line); margin: 8px 4px 10px; }
.sb-item { display: flex; align-items: center; gap: 11px; padding: 11px 12px; border-radius: 12px; color: var(--text); font-weight: 600; font-size: 13.8px; cursor: pointer; margin-bottom: 3px; transition: background .14s ease, transform .14s ease; position: relative; }
.sb-item:hover { background: var(--panel2); transform: translateX(2px); }
.sb-item.active { background: color-mix(in srgb, var(--c, var(--brand-3)) 16%, transparent); box-shadow: 0 4px 14px -6px color-mix(in srgb, var(--c, var(--brand-3)) 60%, transparent); }
.sb-item.active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 4px; border-radius: 4px; background: var(--c, var(--brand-3)); }
.sb-item .ic { width: 32px; height: 32px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; background: color-mix(in srgb, var(--c, var(--brand-3)) 16%, transparent); }
.sb-item .ic.mono { color: #fff; font-weight: 800; font-size: 10.5px; }
.sb-item .nm { flex: 1; line-height: 1.25; }
.sb-item .nm small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; }
.sb-item .cnt { font-size: 11.5px; font-weight: 800; color: #fff; background: var(--c, var(--brand-3)); min-width: 22px; text-align: center; padding: 2px 7px; border-radius: 999px; }
.sb-item .cnt.zero { background: #cbd8df; }
.sb-lock { margin-left: 4px; font-size: 11px; }
.content-panel { min-width: 0; }

/* ================= BUTTONS ================= */
.btn, .btn-sm { position: relative; overflow: hidden; display: inline-block; padding: 10px 19px; border-radius: 11px; border: none; background: linear-gradient(135deg, var(--brand-2), var(--brand-3)); color: #fff; font-weight: 700; font-size: 14px; cursor: pointer; box-shadow: 0 5px 14px rgba(18,101,127,.26); transition: transform .15s ease, box-shadow .15s ease, filter .15s ease; }
.btn::after, .btn-sm::after { content: ""; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,.35) 48%, transparent 66%); transform: translateX(-120%); transition: transform .5s ease; }
.btn:hover, .btn-sm:hover { transform: translateY(-2px); filter: brightness(1.06); text-decoration: none; color: #fff; box-shadow: 0 8px 20px rgba(18,101,127,.34); }
.btn:hover::after, .btn-sm:hover::after { transform: translateX(120%); }
.btn:active, .btn-sm:active { transform: translateY(0); }
.btn.small, .btn-sm { padding: 6px 13px; font-size: 12.5px; border-radius: 9px; }
.btn.accent, .btn-sm.accent { background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 5px 14px rgba(255,93,115,.32); }
.btn.danger { background: linear-gradient(135deg, #e0344b, #ff6b6b); box-shadow: 0 5px 14px rgba(224,52,75,.3); }
.btn.ghost, .btn-sm.ghost { background: var(--panel2); color: var(--brand-1); box-shadow: none; }
.btn.ghost:hover, .btn-sm.ghost:hover { background: var(--line); filter: none; }
html[data-theme="dark"] .btn.ghost, html[data-theme="dark"] .btn-sm.ghost { color: #a9e6f7; }
button.btn, button.btn-sm { font-family: inherit; }

/* ================= TABLES ================= */
table.files, table.utable { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); margin-bottom: 6px; }
table.files th, table.utable th { background: linear-gradient(120deg, var(--brand-1), var(--brand-2)); color: #fff; text-align: left; font-size: 12px; letter-spacing: .5px; padding: 12px 15px; text-transform: uppercase; font-weight: 700; }
table.files td, table.utable td { padding: 12px 15px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
table.files tr:last-child td, table.utable tr:last-child td { border-bottom: none; }
table.files tbody tr:hover td, table.utable tbody tr:hover td { background: var(--panel2); }
.fname { font-weight: 600; color: var(--text); }
.sub { color: var(--muted); font-size: 12.5px; }

/* ================= FORMS / PANEL ================= */
form.panel, .panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; border: 1px solid var(--line); animation: pop .3s ease both; }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 700; font-size: 13.5px; color: var(--brand-1); margin-bottom: 6px; }
html[data-theme="dark"] .field label { color: #a9e6f7; }
.field input[type=text], .field input[type=password], .field input[type=email], .field input[type=search],
.field select, .field textarea, .field input[type=file],
#uploadForm input, #uploadForm select, #credForm input, #credForm select {
  width: 100%; padding: 10px 13px; border: 1.5px solid var(--line); border-radius: 11px; font-size: 14px;
  background: var(--panel2); color: var(--text); transition: border-color .15s ease, box-shadow .15s ease; margin-bottom: 2px;
}
.field input:focus, .field select:focus, .field textarea:focus,
#uploadForm input:focus, #uploadForm select:focus, #credForm input:focus, #credForm select:focus {
  outline: none; border-color: var(--brand-3); box-shadow: 0 0 0 3px rgba(43,168,196,.2);
}
#uploadForm label, #credForm label { display: block; font-weight: 700; font-size: 12.5px; color: var(--brand-1); margin: 12px 0 6px; }
html[data-theme="dark"] #uploadForm label, html[data-theme="dark"] #credForm label { color: #a9e6f7; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; line-height: 1.5; }

/* ================= PILLS / BADGES / CHIPS ================= */
.pill { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: 11px; font-weight: 800; letter-spacing: .2px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.pill.admin, .pill.r-admin { background: linear-gradient(135deg,#ffe6c2,#ffd0a6); color: #9a3412; }
.pill.superadmin, .pill.r-superadmin { background: linear-gradient(135deg,#e4d4ff,#cdb8ff); color: #4c1d95; }
.pill.member, .pill.r-member { background: #dcefff; color: #075985; }
.pill.restricted { background: #ffe0e4; color: #93132a; }
.pill.open { background: #d5f6e8; color: #06603f; }
.pill.v { background: #ece7ff; color: #5b21b6; }
.badge { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; font-size: 10.5px; color: var(--muted); }
.badge.tagup { background: color-mix(in srgb, var(--ok) 18%, var(--panel2)); border-color: transparent; color: var(--ok); font-weight: 700; }

.chip { display: inline-block; border: 1px solid var(--line); background: var(--card); color: var(--muted); border-radius: 20px; padding: 6px 13px; cursor: pointer; font-size: 12px; font-weight: 600; transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; }
.chip:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--brand-3) 40%, var(--line)); }
.chip.active { background: color-mix(in srgb, var(--brand-3) 18%, var(--card)); color: var(--text); border-color: var(--brand-3); box-shadow: 0 3px 10px -4px color-mix(in srgb, var(--brand-3) 60%, transparent); }
.chip.contrib { cursor: default; font-weight: 700; padding: 4px 11px 4px 9px; }
.chip.contrib.r-creator { background: color-mix(in srgb, #f59e0b 20%, var(--card)); border-color: #f59e0b; color: #9a5b00; }
.chip.contrib.r-uploader { background: color-mix(in srgb, #10b981 20%, var(--card)); border-color: #10b981; color: #05603f; }
.chip.contrib.r-editor { background: color-mix(in srgb, #4f8bff 20%, var(--card)); border-color: #4f8bff; color: #1c3f8c; }
.chip.contrib.r-reviewer { background: color-mix(in srgb, #8b5cf6 20%, var(--card)); border-color: #8b5cf6; color: #4c1d95; }
.chip.contrib.r-other { background: color-mix(in srgb, #64748b 20%, var(--card)); border-color: #64748b; color: #334155; }
html[data-theme="dark"] .chip.contrib { color: var(--text); }

/* ================= SEARCH HERO / TOOLBAR ================= */
.searchhero { background: linear-gradient(120deg, var(--proj-1), var(--proj-2)); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; color: #fff; box-shadow: var(--shadow); }
.searchhero .sh-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.searchhero .sh-title { font-size: 18px; font-weight: 800; }
.searchhero .sh-sub { font-size: 13px; opacity: .9; margin-left: auto; }
.searchhero .sh-searching { margin-top: 10px; font-size: 13px; background: rgba(255,255,255,.16); display: inline-block; padding: 6px 12px; border-radius: 20px; }
.searchhero .sh-searching a { color: #fff; font-weight: 700; margin-left: 6px; text-decoration: underline; }
.folder-credits { margin-top: 13px; background: rgba(255,255,255,.14); border-radius: 12px; padding: 10px 13px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.folder-credits .fc-label, .pvcredits .fc-label { font-weight: 700; font-size: 12.5px; }
.folder-credits .chip.contrib { background: rgba(255,255,255,.9); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.sortlabel { font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; }
.sortlabel select { padding: 7px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: 12.5px; }
.view-toggle { display: inline-flex; gap: 4px; background: var(--panel2); border-radius: 10px; padding: 3px; }
.view-toggle a { padding: 6px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 700; color: var(--brand-1); cursor: pointer; }
html[data-theme="dark"] .view-toggle a { color: #a9e6f7; }
.view-toggle a.on { background: var(--card); box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.view-toggle a:hover { text-decoration: none; }

/* ================= FILE GRID / CARDS ================= */
.folder-group { margin-bottom: 24px; }
.folder-group .fg-head { display: flex; align-items: center; gap: 9px; font-size: 13.5px; font-weight: 800; color: var(--brand-1); padding: 4px 2px 10px; border-bottom: 2px solid var(--line); margin-bottom: 10px; }
html[data-theme="dark"] .folder-group .fg-head { color: #a9e6f7; }
.folder-group .fg-head .chip { font-size: 11px; font-weight: 700; cursor: default; }

.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.file-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 15px; display: flex; gap: 12px; align-items: flex-start; transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease; animation: pop .25s ease both; }
.file-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--brand-3) 40%, var(--line)); }
.file-card .fico { width: 44px; height: 44px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 10.5px; font-weight: 800; flex-shrink: 0; cursor: pointer; border: 1px solid transparent; }
.file-card .fmeta { flex: 1; min-width: 0; }
.file-card .fnm { font-weight: 700; font-size: 14px; word-break: break-word; line-height: 1.35; cursor: pointer; }
.file-card .fnm:hover { text-decoration: underline; }
.file-card .fsub { color: var(--muted); font-size: 12px; margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.file-card .credrow-mini { gap: 5px; }
.file-card .facts { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.extdot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 2px; }
.cred-mini { margin-top: 8px; font-size: 11px; color: var(--muted); font-weight: 700; }

/* ================= STATS / CATEGORY CARDS ================= */
.stats { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 24px; }
.stat { position: relative; overflow: hidden; border-radius: var(--radius); padding: 20px 22px; color: #fff; box-shadow: var(--shadow); animation: pop .35s ease both; transition: transform .18s ease, box-shadow .18s ease; }
.stat:hover { transform: translateY(-4px) scale(1.015); box-shadow: 0 16px 34px -10px rgba(0,0,0,.35); }
.stat .lab { font-size: 13px; font-weight: 600; opacity: .95; letter-spacing: .3px; }
.stat .big { font-size: 30px; font-weight: 800; margin-top: 4px; line-height: 1.1; }
.stat .ico { position: absolute; right: 14px; top: 12px; font-size: 38px; opacity: .28; }
.stat.s1 { background: linear-gradient(135deg, #12657f, #2ba8c4); }
.stat.s2 { background: linear-gradient(135deg, #7c5cff, #a48bff); }
.stat.s3 { background: linear-gradient(135deg, #ff9f1c, #ff5d73); }
.stat.s4 { background: linear-gradient(135deg, #10a074, #43d19e); }

.cat-card { position: relative; overflow: hidden; cursor: pointer; border: none; transition: transform .18s ease, box-shadow .18s ease; border-top: 4px solid var(--c, var(--brand-3)); }
.cat-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); }
.cat-card .cat-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; color: #fff; margin-bottom: 10px; }
.cat-card h3 { font-size: 15px; }
.cat-card .count { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.cat-card .lock { position: absolute; top: 16px; right: 16px; font-size: 14px; }
.cat-card .bar { height: 5px; border-radius: 6px; background: var(--panel2); margin-top: 12px; overflow: hidden; }
.cat-card .bar > span { display: block; height: 100%; border-radius: 6px; }

/* ================= TREE ================= */
.treewrap { background: radial-gradient(600px 300px at 12% -10%, color-mix(in srgb, var(--brand-3) 10%, transparent), transparent), var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 20px 22px; overflow: auto; box-shadow: var(--shadow); }
.treebar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.small-note { font-size: 12.5px; }
.rootnode { display: inline-flex; align-items: center; gap: 12px; color: #fff; font-weight: 800; padding: 12px 18px; border-radius: 14px; box-shadow: var(--shadow); margin-bottom: 8px; }
.rootnode .mark { background: rgba(255,255,255,.22); display: flex; align-items: center; justify-content: center; }
.rootnode .rc { font-weight: 600; font-size: 12px; opacity: .9; background: rgba(255,255,255,.22); padding: 2px 9px; border-radius: 20px; }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; } .tree { margin-top: 6px; }
.tree li { position: relative; padding-left: 26px; }
.tree li::before { content: ""; position: absolute; left: 10px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.tree li:last-child::before { bottom: auto; height: 20px; }
.tree li::after { content: ""; position: absolute; left: 10px; top: 20px; width: 15px; height: 2px; background: var(--line); }
.tnode { display: flex; align-items: center; gap: 10px; padding: 9px 12px; margin: 5px 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel2); cursor: pointer; }
.tnode:hover { border-color: var(--brand-3); transform: translateX(2px); }
.tnode .tw { width: 14px; text-align: center; color: var(--muted); transition: transform .2s; font-size: 11px; }
.tnode.open .tw { transform: rotate(90deg); }
.tnode .dot { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.tnode .dot.mono-dot { width: auto; height: 22px; padding: 0 6px; border-radius: 7px; color: #fff; font-size: 9.5px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.tnode .tt { font-weight: 700; font-size: 13.5px; }
.tnode .tc { margin-left: auto; font-size: 11px; color: var(--muted); background: var(--card); border: 1px solid var(--line); padding: 1px 9px; border-radius: 20px; }
.tchildren { overflow: hidden; max-height: 0; transition: max-height .35s ease; } .tchildren.open { max-height: 60000px; }
.tleaf { display: flex; align-items: center; gap: 10px; padding: 8px 11px; margin: 4px 0; border-radius: 10px; cursor: pointer; border: 1px solid transparent; }
.tleaf:hover { background: var(--panel2); border-color: var(--line); }
.tleaf .fi { width: 30px; height: 30px; border-radius: 8px; font-size: 9px; font-weight: 800; color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tleaf .ln { font-size: 12.8px; word-break: break-word; }
.tleaf .ls { margin-left: auto; font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ================= MODALS ================= */
.modal { display: none; position: fixed; inset: 0; z-index: 80; background: rgba(9,20,32,.5); backdrop-filter: blur(3px); padding: 40px 16px; overflow: auto; }
.modal.open { display: block; }
.modal .sheet { max-width: 540px; margin: 0 auto; background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 22px 24px; animation: pop .2s ease; }
.modal.wide .sheet { max-width: min(1080px, 94vw); }
.sheet-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; font-size: 15.5px; }
.sheet-h span { cursor: pointer; }
.pvbody { min-height: 58vh; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--panel2); display: grid; place-items: center; }
.pvbody iframe { width: 100%; height: 72vh; border: 0; background: #fff; }
.pvbody img { max-width: 100%; max-height: 72vh; object-fit: contain; }
.pvmsg { padding: 50px 24px; text-align: center; color: var(--muted); }
.pvpre { padding: 16px; white-space: pre-wrap; font-size: 12.5px; align-self: start; width: 100%; }
.pvtable { width: 100%; border-collapse: collapse; font-size: 12.5px; align-self: start; }
.pvtable td, .pvtable th { border: 1px solid var(--line); padding: 6px 9px; text-align: left; white-space: nowrap; }
.pvtable tr:nth-child(even) { background: var(--panel2); }
.pvcredits { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Credits modal specifics */
.credlist { max-height: 220px; overflow-y: auto; margin-bottom: 14px; }
.credrow { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: 12.8px; }
.credrow:last-child { border-bottom: none; }
.cr-role { color: var(--muted); font-weight: 600; }
.cr-note { color: var(--muted); font-style: italic; flex: 1; }
.cr-del { margin-left: auto; cursor: pointer; color: var(--danger); font-weight: 800; padding: 2px 6px; }
.cr-del:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); border-radius: 6px; }

/* Upload progress */
.progresswrap { height: 8px; background: var(--panel2); border-radius: 20px; overflow: hidden; margin: 12px 0 4px; }
.progress { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .2s ease; }

/* ================= TOAST ================= */
.toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px); background: var(--brand-1); color: #fff; padding: 12px 20px; border-radius: 12px; font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-lg); opacity: 0; transition: opacity .25s ease, transform .25s ease; z-index: 100; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ================= EMPTY / FOOTER ================= */
.empty { text-align: center; color: var(--muted); padding: 54px 12px; background: var(--card); border-radius: var(--radius); border: 2px dashed var(--line); transition: border-color .2s ease; }
.empty:hover { border-color: color-mix(in srgb, var(--brand-3) 45%, var(--line)); }
.empty .big-ico { font-size: 44px; display: block; margin-bottom: 10px; filter: drop-shadow(0 4px 10px rgba(0,0,0,.12)); }

/* ================= FOCUS / ACCESSIBILITY ================= */
a:focus-visible, button:focus-visible, .btn:focus-visible, .btn-sm:focus-visible,
.sb-item:focus-visible, .cat-card:focus-visible, .chip:focus-visible, .tnode:focus-visible, .tleaf:focus-visible {
  outline: 2px solid var(--brand-3); outline-offset: 2px; border-radius: 8px;
}
.sitefooter { text-align: center; color: var(--muted); font-size: 12.5px; padding: 30px 20px 40px; max-width: 1320px; margin: 0 auto; }

/* ================= RESPONSIVE ================= */
@media (max-width: 860px) {
  .topnav { display: none; }
  .userchip .uname { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .projectbar .pb-search { order: 3; width: 100%; }
  table.files th:nth-child(4), table.files td:nth-child(4) { display: none; }
}
