/* ===========================================================================
   Selfie 26 — accent-driven theme (admin can change --accent live).
   Gradient, glow and text-on-accent all derive from a single --accent.
   =========================================================================== */
:root {
  --accent: #c99a3b;                 /* overridden at runtime from /api/settings */
  --accent-ink: #3a2b0c;             /* text on accent; JS flips for dark accents */
  --grad: linear-gradient(135deg,
          color-mix(in srgb, var(--accent) 70%, #ffffff),
          var(--accent) 52%,
          color-mix(in srgb, var(--accent) 80%, #000000));
  --glow: 0 10px 28px -8px color-mix(in srgb, var(--accent) 55%, transparent);

  /* Bright, airy surfaces — FIXED values (NOT tied to --accent), so changing
     the color only repaints the accent elements (logo, active nav, buttons,
     hero, stats) and never the page/sidebar. */
  --bg: #f4f5fb;
  --bg-2: #ebecf7;
  --card: #ffffff;
  --card-2: #fbfbfe;
  --ink: #15131f;
  --muted: #6b6880;
  --line: #e9e8f2;
  --field: #f2f1f9;

  --ok: #15924f;
  --err: #d8443a;
  --warn: #d08a1a;

  --sidebar: #0d0b16;
  --sidebar-ink: #edeafb;
  --sidebar-muted: #8c87ab;

  --radius: 20px;
  --radius-sm: 13px;
  --shadow: 0 1px 2px rgba(16,30,50,.05), 0 12px 32px -12px rgba(20,80,140,.18);
  --shadow-lg: 0 24px 60px -18px rgba(14,110,190,.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
/* Original ambient glow — FIXED cool blue/teal (NOT --accent), so the page keeps
   its depth and never turns gold when the accent changes. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(42vw 42vw at 85% -8%, rgba(37,99,235,.16), transparent 60%),
    radial-gradient(38vw 38vw at -5% 8%, rgba(6,182,212,.16), transparent 60%),
    radial-gradient(45vw 40vw at 60% 110%, rgba(14,165,233,.12), transparent 60%);
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
h1, h2, .brand .name, .dropzone .title, .stat .n, .btn-primary { font-family: "Sora", "Inter", sans-serif; letter-spacing: -.01em; }

.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  width: 250px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; height: 100dvh;
  background: var(--sidebar); color: var(--sidebar-ink);
  display: flex; flex-direction: column; padding: 24px 16px; overflow-y: auto;
  border-right: 1px solid rgba(255,255,255,.05);
}
.brand { display: flex; align-items: center; gap: 13px; padding: 4px 8px 26px; }
.brand .logo {
  width: 44px; height: 44px; border-radius: 14px; flex-shrink: 0; color: var(--accent-ink);
  background: var(--grad); display: grid; place-items: center; box-shadow: var(--glow);
}
.brand .logo svg { width: 26px; height: 26px; }
.brand .name { font-weight: 700; font-size: 20px; line-height: 1.05; }
.brand .name small { display: block; font-size: 11px; font-weight: 500; letter-spacing: .18em; color: var(--sidebar-muted); text-transform: uppercase; margin-top: 3px; font-family: "Inter"; }

.nav-group { margin-top: 6px; }
.nav-group .label { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--sidebar-muted); padding: 14px 14px 7px; font-weight: 600; }
.nav { display: flex; flex-direction: column; gap: 5px; }
.nav a {
  display: flex; align-items: center; gap: 13px; padding: 12px 14px; border-radius: 13px;
  color: var(--sidebar-muted); font-weight: 600; font-size: 15px; transition: color .18s, background .18s;
}
.nav a svg { width: 20px; height: 20px; }
.nav a:hover { color: var(--sidebar-ink); background: rgba(255,255,255,.05); }
.nav a.active { color: var(--accent-ink); background: var(--grad); box-shadow: var(--glow); }
.sidebar .foot { margin-top: auto; padding: 14px 10px 2px; color: var(--sidebar-muted); font-size: 12px; }
.sidebar .foot b { color: var(--sidebar-ink); font-weight: 600; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 26px 34px 12px; }
.topbar .ttl { display: flex; flex-direction: column; }
.topbar h1 { margin: 0; font-size: 29px; font-weight: 700; }
.topbar .crumb { color: var(--muted); font-size: 13px; font-weight: 500; margin-top: 2px; }
.topbar .right { display: flex; align-items: center; gap: 10px; }
.chip {
  display: flex; align-items: center; gap: 9px; padding: 7px 14px 7px 7px;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow);
  font-weight: 600; font-size: 14px;
}
.chip .av { width: 28px; height: 28px; border-radius: 50%; background: var(--grad); color: var(--accent-ink); display: grid; place-items: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.icon-btn { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--muted); display: grid; place-items: center; box-shadow: var(--shadow); transition: color .15s, transform .08s, border-color .15s; }
.icon-btn:hover { color: var(--ink); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 18px; height: 18px; }

.mobile-brand { display: none; align-items: center; gap: 10px; }
.mobile-brand .logo { width: 36px; height: 36px; border-radius: 11px; background: var(--grad); color: var(--accent-ink); display: grid; place-items: center; box-shadow: var(--glow); }
.mobile-brand .logo svg { width: 21px; height: 21px; }
.mobile-brand .name { font-family: "Sora"; font-weight: 700; font-size: 18px; }

.content { padding: 16px 34px 48px; }

/* ---------- Cards ---------- */
.grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 22px; align-items: start; }
.card { background: var(--card); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); border: 1px solid var(--line); position: relative; }
.card h2 { margin: 0 0 18px; font-size: 19px; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.card h2 .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--grad); box-shadow: var(--glow); }

/* ---------- Dropzone ---------- */
.dropzone { position: relative; border-radius: 18px; padding: 46px 22px; text-align: center; cursor: pointer; background: var(--card-2); transition: transform .15s, box-shadow .2s; overflow: hidden; }
.dropzone::before { content: ""; position: absolute; inset: 0; border-radius: 18px; padding: 2px; background: var(--grad); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; opacity: .5; transition: opacity .2s; }
.dropzone:hover { transform: translateY(-2px); }
.dropzone:hover::before, .dropzone.drag::before { opacity: 1; }
.dropzone.drag { box-shadow: var(--glow); }
.dropzone .up-ic { width: 64px; height: 64px; margin: 0 auto 15px; border-radius: 18px; background: color-mix(in srgb, var(--accent) 13%, var(--card)); display: grid; place-items: center; color: color-mix(in srgb, var(--accent) 80%, #000); }
.dropzone .up-ic svg { width: 30px; height: 30px; }
.dropzone .title { font-size: 21px; font-weight: 700; }
.dropzone .sub { color: var(--muted); margin-top: 6px; font-size: 14px; }
.dropzone .pill { display: inline-block; margin-top: 12px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--field); padding: 5px 12px; border-radius: 999px; }

.btn-primary { width: 100%; margin-top: 18px; border: none; border-radius: 15px; color: var(--accent-ink); background: var(--grad); padding: 16px; font-size: 16px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 10px; box-shadow: var(--glow); transition: filter .15s, transform .06s; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.05); transform: translateY(-1px); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn-primary svg { width: 19px; height: 19px; }

.hint { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13.5px; margin-top: 15px; justify-content: center; }
.hint svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ---------- Files ---------- */
.file-row { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 15px; padding: 13px 14px; margin-bottom: 11px; background: var(--card-2); transition: border-color .15s; }
.file-row:hover { border-color: color-mix(in srgb, var(--accent) 32%, var(--line)); }
.file-row .thumb { width: 42px; height: 42px; border-radius: 11px; flex-shrink: 0; background: color-mix(in srgb, var(--accent) 13%, var(--card)); color: color-mix(in srgb, var(--accent) 80%, #000); display: grid; place-items: center; position: relative; overflow: hidden; }
.file-row .thumb svg { width: 20px; height: 20px; }
.file-row .thumb .ring { position: absolute; inset: 0; }
.file-row .meta { min-width: 0; flex: 1; }
.file-row .fname { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .fsub { color: var(--muted); font-size: 12.5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .fsub.owner b { color: var(--ink); }
.file-row .actions { display: flex; gap: 7px; align-items: center; flex-shrink: 0; }

/* upload progress bar inside a row */
.uprog { height: 5px; border-radius: 999px; background: var(--field); overflow: hidden; margin-top: 7px; }
.uprog > i { display: block; height: 100%; width: 0; background: var(--grad); transition: width .15s; }

.badge { border: 1px solid var(--line); border-radius: 11px; padding: 8px 13px; font-size: 12.5px; font-weight: 700; background: var(--card); color: var(--ink); display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.badge svg { width: 14px; height: 14px; }
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); background: color-mix(in srgb, var(--ok) 8%, var(--card)); }
.badge.err { color: var(--err); border-color: color-mix(in srgb, var(--err) 35%, var(--line)); background: color-mix(in srgb, var(--err) 8%, var(--card)); }
.badge.wait { color: var(--muted); }
.badge.spin { color: color-mix(in srgb, var(--accent) 80%, #000); border-color: color-mix(in srgb, var(--accent) 32%, var(--line)); }
.badge.spin svg { animation: spin 1s linear infinite; }
.badge.dl { background: var(--grad); color: var(--accent-ink); border-color: transparent; cursor: pointer; box-shadow: var(--glow); }
.badge.dl:hover { filter: brightness(1.05); }
.mini-btn { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--muted); display: grid; place-items: center; }
.mini-btn:hover { color: var(--err); border-color: color-mix(in srgb, var(--err) 35%, var(--line)); }
.mini-btn.edit:hover { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.mini-btn svg { width: 16px; height: 16px; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 34px 10px; }
.empty .em-ic { width: 54px; height: 54px; margin: 0 auto 12px; border-radius: 16px; background: var(--field); display: grid; place-items: center; color: var(--muted); }
.empty .em-ic svg { width: 26px; height: 26px; }

/* ---------- Home / stats ---------- */
/* Welcome banner — light card that matches the stat cards; the name and button
   follow the accent so the color still pops. */
.hero {
  border-radius: var(--radius); padding: 24px 30px; margin-bottom: 20px;
  background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--shadow); position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: space-between; gap: 22px;
}
.hero::after {
  content: ""; position: absolute; right: -90px; top: 50%; transform: translateY(-50%);
  width: 320px; height: 320px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 13%, transparent), transparent 70%);
}
.hero h2 { margin: 0; font-size: 27px; color: var(--ink); position: relative; z-index: 1; }
.hero h2 .nm { color: var(--accent); }
.hero-btn {
  position: relative; z-index: 1; flex-shrink: 0; border: none;
  background: var(--grad); color: var(--accent-ink);
  padding: 14px 22px; border-radius: 13px; font-weight: 700; font-family: "Sora", sans-serif;
  font-size: 15px; display: inline-flex; align-items: center; gap: 9px; box-shadow: var(--glow);
  transition: filter .15s, transform .06s;
}
.hero-btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.hero-btn svg { width: 18px; height: 18px; }
@media (max-width: 600px) {
  .hero { flex-direction: column; align-items: flex-start; padding: 22px; }
  .hero h2 { font-size: 23px; }
  .hero-btn { width: 100%; justify-content: center; }
}
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 18px; box-shadow: var(--shadow); }
.stat .n { font-size: 27px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---------- Admin ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 6px; box-shadow: var(--shadow); }
.tabs button { border: none; background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; padding: 9px 15px; border-radius: 10px; display: inline-flex; align-items: center; gap: 8px; }
.tabs button svg { width: 16px; height: 16px; }
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--accent-ink); background: var(--grad); box-shadow: var(--glow); }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: var(--card); color: var(--ink); font-weight: 600; font-size: 14px; padding: 10px 16px; border-radius: 12px; display: inline-flex; align-items: center; gap: 8px; box-shadow: var(--shadow); }
.btn:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.btn svg { width: 16px; height: 16px; }
.btn.accent { background: var(--grad); color: var(--accent-ink); border-color: transparent; box-shadow: var(--glow); }
.btn.danger { color: var(--err); }
.btn.danger:hover { border-color: color-mix(in srgb, var(--err) 40%, var(--line)); }

.tbl-wrap { overflow-x: auto; border-radius: 14px; border: 1px solid var(--line); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 520px; }
table.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 12px 14px; background: var(--card-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tr:hover td { background: var(--card-2); }
.role-pill { font-size: 12px; font-weight: 700; padding: 4px 11px; border-radius: 999px; display: inline-block; }
.role-pill.admin { color: var(--accent-ink); background: var(--grad); }
.role-pill.user { color: var(--muted); background: var(--field); }
.dot-state { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: 13px; }
.dot-state i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot-state.on i { background: var(--ok); }
.dot-state.off i { background: var(--err); }
.act-s { color: var(--ok); } .act-s.err { color: var(--err); } .act-s.wait { color: var(--muted); } .act-s.run { color: var(--accent); }
.log-act { font-weight: 700; font-size: 12px; padding: 3px 9px; border-radius: 8px; background: var(--field); color: var(--ink); }

/* forms / modal */
.modal-bg { position: fixed; inset: 0; background: rgba(20,16,8,.5); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 70; padding: 18px; }
.modal { width: 100%; max-width: 420px; background: var(--card); border-radius: 18px; padding: 24px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); }
.modal h3 { margin: 0 0 18px; font-family: "Sora"; font-size: 19px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 7px; }
.field input, .field select { width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--field); color: var(--ink); font-size: 15px; transition: border-color .15s, box-shadow .15s; }
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; justify-content: center; }
.form-err { color: var(--err); font-size: 13px; font-weight: 500; min-height: 16px; margin-top: 2px; }

/* color field */
.color-field { display: flex; align-items: center; gap: 12px; }
.color-field input[type=color] { width: 54px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: none; cursor: pointer; }
.color-field input[type=text] { flex: 1; }
.swatches { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.swatches button { width: 30px; height: 30px; border-radius: 9px; border: 2px solid var(--line); cursor: pointer; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 400px; }
.login-card .brand { flex-direction: column; text-align: center; gap: 14px; padding: 6px 0 18px; }
.login-card .brand .logo { width: 58px; height: 58px; border-radius: 18px; }
.login-card .brand .logo svg { width: 34px; height: 34px; }
.login-card .brand .name { font-size: 26px; }
.login-card h2 { justify-content: center; margin: 0 0 20px; font-size: 18px; color: var(--muted); font-weight: 600; }
.login-card .field:last-of-type { margin-bottom: 8px; }
.login-err { color: var(--err); font-size: 13.5px; min-height: 18px; margin: 6px 2px 10px; font-weight: 500; }
.login-card .btn-primary { margin-top: 4px; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(10px); background: var(--ink); color: var(--card); padding: 13px 20px; border-radius: 13px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 80; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--err); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }

.page { max-width: 640px; }

/* ---------- Mobile bottom nav ---------- */
.bottomnav { display: none; }

@media (max-width: 920px) { .grid { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .sidebar { display: none; }
  .mobile-brand { display: flex; }
  .topbar { padding: 14px 16px 8px; position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px); }
  .topbar .ttl { display: none; }
  .content { padding: 14px 16px calc(96px + env(safe-area-inset-bottom)); }
  .card { padding: 18px; border-radius: 18px; }
  .dropzone { padding: 36px 16px; }
  .hero { padding: 24px; }
  .bottomnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(18px); border-top: 1px solid var(--line); padding: 8px 6px calc(8px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 2px; border-radius: 13px; color: var(--muted); font-size: 11px; font-weight: 600; transition: color .15s; max-width: 84px; }
  .bottomnav a svg { width: 22px; height: 22px; }
  .bottomnav a.active { color: color-mix(in srgb, var(--accent) 82%, #000); }
  .bottomnav a.active .ic { background: color-mix(in srgb, var(--accent) 16%, transparent); }
  .bottomnav a .ic { padding: 5px 15px; border-radius: 12px; display: grid; place-items: center; transition: background .15s; }
}
@media (max-width: 420px) { .chip .uname { display: none; } .chip { padding: 6px; } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .001ms !important; transition-duration: .001ms !important; } }
