/* =========================================================
   InvestBoard — giao diện báo cáo nhà đầu tư
   ========================================================= */
:root {
  --bg: #f4f2ed;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --ink: #14171c;
  --ink-2: #3b404b;
  --muted: #747985;
  --line: #e6e1d7;
  --line-2: #efebe3;

  --side: #0f1318;
  --side-2: #1a1f27;
  --side-ink: #c6ccd6;
  --side-muted: #6f7787;

  --accent: #0f766e;
  --accent-2: #14b8a6;
  --accent-soft: #dff2ee;

  --live: #059669;
  --step1: #4f46e5;
  --pending: #d97706;
  --withdraw: #0284c7;
  --dead: #dc2626;
  --fund: #0f172a;
  --share: #7c3aed;
  --kycteam: #db2777;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 19, 24, .04), 0 10px 30px -18px rgba(15, 19, 24, .18);
  --shadow-lg: 0 2px 4px rgba(15, 19, 24, .05), 0 24px 50px -24px rgba(15, 19, 24, .28);
  --font: "Be Vietnam Pro", "Noto Sans KR", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
body.lang-ko { word-break: keep-all; --font: "Noto Sans KR", "Be Vietnam Pro", system-ui, -apple-system, "Malgun Gothic", sans-serif; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; line-height: 1.2; }
h1 { font-size: 28px; font-weight: 800; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
p { margin: 4px 0 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mt { margin-top: 20px; }
.ic { width: 18px; height: 18px; flex: none; }
[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 28px 36px 56px; width: 100%; max-width: 1480px; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 268px; flex: none;
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(20, 184, 166, .10), transparent 60%),
    var(--side);
  color: var(--side-ink);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  padding: 22px 14px 14px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 10px 18px; color: #fff; }
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(140deg, #2dd4bf, #0f766e 70%);
  box-shadow: 0 6px 18px -6px rgba(20, 184, 166, .7), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.brand-mark .ic { width: 20px; height: 20px; stroke-width: 2.4; }
.brand-mark.lg { width: 48px; height: 48px; border-radius: 14px; margin-bottom: 18px; }
.side-nav { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.nav-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--side-muted); padding: 18px 12px 6px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; margin: 2px 0; border-radius: 10px;
  color: var(--side-ink); font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--side-2); color: #fff; }
.nav-item.is-active { background: rgba(255, 255, 255, .08); color: #fff; box-shadow: inset 3px 0 0 var(--accent-2); }
.nav-folder .folder-dot { color: var(--c); display: grid; }
.nav-folder .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-folder.is-active { box-shadow: inset 3px 0 0 var(--c); }
.nav-empty { padding: 6px 12px; color: var(--side-muted); }
.side-foot { display: flex; align-items: center; gap: 8px; border-top: 1px solid rgba(255, 255, 255, .07); padding-top: 14px; }
.me { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 12px; }
.me:hover, .me.is-active { background: var(--side-2); }
.me-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.me-text strong { color: #fff; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text small { color: var(--side-muted); font-size: 12px; }
.avatar {
  width: 36px; height: 36px; border-radius: 11px; flex: none; display: grid; place-items: center;
  font-weight: 800; color: #fff; background: linear-gradient(140deg, #334155, #1e293b);
  border: 1px solid rgba(255, 255, 255, .08);
}
.avatar.light { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.avatar.xl { width: 64px; height: 64px; border-radius: 18px; font-size: 26px; background: linear-gradient(140deg, #2dd4bf, #0f766e); }
.scrim { display: none; }

/* folder management in sidebar */
.nav-label-row { display: flex; align-items: center; justify-content: space-between; padding-right: 6px; }
.nav-add, .nav-edit {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; flex: none;
  border: 0; background: transparent; color: var(--side-muted); cursor: pointer; transition: background .15s, color .15s, opacity .15s;
}
.nav-add .ic, .nav-edit .ic { width: 15px; height: 15px; }
.nav-add:hover, .nav-edit:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.nav-folder-row { position: relative; display: flex; align-items: center; }
.nav-folder-row .nav-item { flex: 1; min-width: 0; padding-right: 36px; }
.nav-folder-row .nav-edit { position: absolute; right: 6px; opacity: 0; }
.nav-folder-row:hover .nav-edit, .nav-folder-row .nav-edit:focus-visible, .nav-folder-row.is-active .nav-edit { opacity: 1; }
@media (hover: none) { .nav-folder-row .nav-edit { opacity: 1; } }
.nav-new { width: 100%; border: 1px dashed rgba(255, 255, 255, .14); background: transparent; font: inherit; color: var(--side-muted); cursor: pointer; margin-top: 6px; text-align: left; }
.nav-new:hover { border-color: rgba(255, 255, 255, .3); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: 62px; display: flex; align-items: center; gap: 12px;
  padding: 0 36px; border-bottom: 1px solid var(--line);
  background: rgba(244, 242, 237, .82); backdrop-filter: saturate(1.4) blur(10px);
}
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13.5px; min-width: 0; }
.crumbs .ic { width: 14px; height: 14px; }
.crumbs span { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar .menu-btn { display: none; }

.lang-switch {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px 3px 3px 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; color: var(--muted);
}
.lang-switch .ic { width: 15px; height: 15px; margin-right: 4px; }
.lang-switch a { padding: 5px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.lang-switch a.on { background: var(--ink); color: #fff; }
.lang-switch a:not(.on):hover { color: var(--ink); }
.lang-switch.big { padding: 4px; }
.lang-switch.big a { padding: 8px 16px; font-size: 13.5px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 11px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: transform .08s, background .15s, box-shadow .15s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn .ic { width: 17px; height: 17px; }
.btn-primary { background: var(--ink); color: #fff; box-shadow: 0 6px 16px -8px rgba(15, 19, 24, .6); }
.btn-primary:hover { background: #262b33; }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-soft:hover { background: #cdebe5; }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { border-color: #cfc8ba; }
.btn-block { width: 100%; height: 46px; }
.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { border-color: #cfc8ba; color: var(--ink); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 9px; }
.icon-btn.sm .ic { width: 16px; height: 16px; }
.icon-btn.danger:hover { color: var(--dead); border-color: #f5c2c2; background: #fff5f5; }
.icon-btn.ghost-dark { background: transparent; border-color: transparent; color: var(--side-muted); }
.icon-btn.ghost-dark:hover { background: var(--side-2); color: #fff; }

/* ---------- Page head ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-actions { display: flex; gap: 10px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 6px; margin-bottom: 6px;
  font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.eyebrow .ic { width: 14px; height: 14px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 32px 0 14px; }
.section-head h2 { display: flex; align-items: center; gap: 8px; }
.count { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--ink); color: #fff; }

.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); font-size: 13px; color: var(--ink-2);
}
.chip .ic { width: 15px; height: 15px; color: var(--muted); }
.chip.sm { padding: 3px 10px; font-size: 12px; }

/* ---------- Flash ---------- */
.flash {
  margin: 18px 36px 0; padding: 12px 16px; border-radius: 12px; font-weight: 500;
  display: flex; align-items: center; gap: 10px; transition: opacity .4s, transform .4s;
}
.flash.inline { margin: 0 0 16px; }
.flash-success { background: #e3f6ee; color: #05603f; border: 1px solid #bfe8d6; }
.flash-error { background: #fdecec; color: #a11b1b; border: 1px solid #f7c9c9; }
.flash.hide { opacity: 0; transform: translateY(-6px); }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi {
  --tone: var(--accent);
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px 14px; box-shadow: var(--shadow);
}
.kpi::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 120px; height: 120px; border-radius: 50%;
  background: var(--tone); opacity: .06;
}
.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.kpi-label { font-size: 12.5px; font-weight: 600; color: var(--muted); line-height: 1.35; }
.kpi-icon {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none;
  color: var(--tone); background: color-mix(in srgb, var(--tone) 12%, white);
}
.kpi-icon .ic { width: 16px; height: 16px; }
.kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -.03em; margin-top: 8px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-sub { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 2px; }
.delta { font-weight: 700; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--live); }
.delta.down { color: var(--dead); }
.delta.flat { color: var(--muted); }

.tone-live { --tone: var(--live); }
.tone-step1 { --tone: var(--step1); }
.tone-pending { --tone: var(--pending); }
.tone-withdraw { --tone: var(--withdraw); }
.tone-dead { --tone: var(--dead); }
.tone-fund { --tone: var(--fund); }
.tone-share { --tone: var(--share); }
.tone-kycteam { --tone: var(--kycteam); }
.tone-accent { --tone: var(--accent); }
.tone-neutral { --tone: #64748b; }

/* ---------- Folder cards (dashboard) ---------- */
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 22px; }
.folder-card { position: relative; padding-top: 14px; }
.folder-tab {
  position: absolute; top: 0; left: 0; width: 46%; height: 20px;
  background: var(--c); border-radius: 12px 6px 0 0;
  clip-path: polygon(0 0, 82% 0, 100% 100%, 0 100%);
}
.folder-body {
  position: relative; background: var(--surface);
  border: 1px solid var(--line); border-top: 4px solid var(--c);
  border-radius: 0 var(--radius) var(--radius) var(--radius);
  padding: 18px 18px 14px; box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s;
}
.folder-card:hover .folder-body { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.folder-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.folder-title { display: flex; gap: 12px; align-items: center; min-width: 0; }
.folder-title strong { display: block; font-size: 18px; letter-spacing: -.02em; }
.folder-title small { display: block; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-icon {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none;
  color: var(--c); background: color-mix(in srgb, var(--c) 13%, white);
}
.folder-icon .ic { width: 22px; height: 22px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-actions form { margin: 0; }

.mini-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 16px 0 12px; }
.mini {
  --tone: var(--accent);
  padding: 9px 10px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line-2);
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.mini span { font-size: 11px; color: var(--muted); line-height: 1.25; min-height: 2.5em; }
.mini strong { font-size: 19px; font-weight: 800; color: var(--tone); font-variant-numeric: tabular-nums; }

.folder-money {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 12px;
  padding: 12px 14px; border-radius: 12px; background: var(--side); color: #fff;
  background-image: radial-gradient(100% 140% at 100% 0%, color-mix(in srgb, var(--c) 45%, transparent), transparent 60%);
}
.folder-money .lbl { display: block; font-size: 11.5px; color: #9aa3b2; }
.folder-money .big { font-size: 22px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.folder-money .right { text-align: right; }
.folder-money .pos { color: #5eead4; font-variant-numeric: tabular-nums; }

.folder-links { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 12px 0; }
.folder-links a {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-2); border: 1px solid var(--line-2);
  transition: background .15s, border-color .15s, color .15s;
}
.folder-links a .ic { width: 15px; height: 15px; color: var(--c); }
.folder-links a:hover { background: color-mix(in srgb, var(--c) 7%, white); border-color: color-mix(in srgb, var(--c) 30%, white); color: var(--ink); }
.folder-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 10px; border-top: 1px dashed var(--line); }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.status .ic { width: 14px; height: 14px; }
.status.ok { background: #e3f6ee; color: #05603f; }
.status.warn { background: #fff4e0; color: #9a5a00; }
.status.off { background: #f1f1f1; color: #6b6b6b; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.card-head h3 .ic { color: var(--muted); }
.card-body { padding: 16px 20px 18px; }
.chart-box { position: relative; height: 320px; }
.chart-empty { height: 100%; display: grid; place-items: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; background: var(--surface-2); }
.chart-row { display: grid; grid-template-columns: 1fr; gap: 16px; }
.chart-row.with-pie { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.empty-state { padding: 40px; text-align: center; color: var(--muted); }
.empty-icon { width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-2); }

/* ---------- Folder page ---------- */
.folder-hero {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-bottom: 22px;
}
.hero-main { display: flex; align-items: center; gap: 16px; }
.hero-icon {
  width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(140deg, color-mix(in srgb, var(--c) 70%, white), var(--c));
  box-shadow: 0 12px 24px -12px var(--c);
}
.hero-icon .ic { width: 30px; height: 30px; }
.hero-main .eyebrow { margin-bottom: 2px; }
.hero-side { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.hero-side form { margin: 0; }
.kpi-hint { display: flex; align-items: center; gap: 7px; margin: 0 0 10px; font-size: 12.5px; color: var(--muted); }
.kpi-hint .ic { width: 14px; height: 14px; color: var(--accent); }
.kpi-edit { cursor: pointer; border-radius: var(--radius); outline: none; }
.kpi-edit .kpi { transition: border-color .15s, transform .15s, box-shadow .15s; }
.kpi-edit:hover .kpi, .kpi-edit:focus-visible .kpi { border-color: color-mix(in srgb, var(--tone) 45%, white); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.hint.hint-edit { background: #e6f4f1; color: #0b5d56; }

.subfolders { display: flex; gap: 4px; border-bottom: 2px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.subfolder {
  position: relative; display: flex; align-items: center; gap: 11px; padding: 12px 18px 12px 12px; min-width: max-content;
  border-radius: 14px 14px 0 0; color: var(--muted); border: 1px solid transparent; border-bottom: 0; margin-bottom: -2px;
  transition: background .15s, color .15s;
}
.subfolder:hover { color: var(--ink); background: rgba(255, 255, 255, .5); }
.subfolder.is-active { background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: inset 0 3px 0 var(--c); }
.subfolder.is-active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px; background: var(--surface); }
.sf-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--line-2); color: var(--muted); }
.subfolder.is-active .sf-icon { background: color-mix(in srgb, var(--c) 14%, white); color: var(--c); }
.sf-text strong { display: block; font-size: 14px; line-height: 1.25; }
.sf-text small { display: block; font-size: 12px; color: var(--muted); }

.pills { display: flex; gap: 8px; padding: 14px 0 0; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line);
}
.pill .ic { width: 15px; height: 15px; }
.pill.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.pill.on.danger { background: var(--dead); border-color: var(--dead); }

.toolbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin: 18px 0 18px; }
.range { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.range label { display: flex; flex-direction: column; gap: 4px; }
.range label span { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.range input { height: 40px; padding: 0 10px; width: auto; background: var(--surface); }
.presets { display: inline-flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); align-self: flex-end; flex-wrap: wrap; }
.preset { padding: 7px 11px; border-radius: 9px; font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.preset:hover { color: var(--ink); background: var(--surface-2); }
.preset.on { background: var(--ink); color: #fff; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  font-weight: 700; padding: 11px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); white-space: nowrap; vertical-align: middle; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover td { background: #fbfaf6; }
.table th.num, .table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.date { font-weight: 700; font-variant-numeric: tabular-nums; }
.table td.pos { color: var(--live); font-weight: 600; }
.table td.neg { color: #be123c; }
.table td.wrap { white-space: normal; }
.table tfoot td { font-weight: 800; background: var(--surface-2); border-top: 2px solid var(--line); border-bottom: 0; }
.table .actions-col { width: 1%; text-align: right; }
.note { display: inline-block; max-width: 280px; white-space: normal; color: var(--ink-2); }
.empty-row { text-align: center !important; color: var(--muted); padding: 40px 14px !important; }
.empty-row .ic { display: block; margin: 0 auto 8px; width: 28px; height: 28px; opacity: .5; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge-live { background: #d9f5ea; color: #047857; }
.badge-step1 { background: #e5e7ff; color: #4338ca; }
.badge-admin { background: #ffe4e0; color: #b42318; }
.badge-reporter { background: #fff1d6; color: #9a5a00; }
.badge-viewer { background: #e7eef7; color: #335a85; }
.folder-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px 3px 7px; margin: 2px 4px 2px 0; border-radius: 8px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  background: color-mix(in srgb, var(--c) 9%, white); border: 1px solid color-mix(in srgb, var(--c) 22%, white);
}
.folder-chip .ic { width: 14px; height: 14px; color: var(--c); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- Forms ---------- */
input, select, textarea {
  font: inherit; color: var(--ink); width: 100%;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2);
  outline: none; transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 4px var(--accent-soft); }
input[type=number] { font-variant-numeric: tabular-nums; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; padding: 20px 22px; }
.form-grid.one { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field > span em { font-weight: 400; color: var(--muted); font-style: normal; }
.field.full, .full { grid-column: 1 / -1; }
.hint { display: flex; align-items: center; gap: 8px; margin: 0 22px; padding: 10px 12px; border-radius: 10px; background: #fff8ea; color: #8a5a00; font-size: 12.5px; }
.hint .ic { width: 15px; height: 15px; }
.input-icon { position: relative; }
.input-icon .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 17px; height: 17px; }
.input-icon input { padding-left: 40px; height: 46px; }

.seg { display: flex; gap: 6px; }
.seg-opt { flex: 1; position: relative; cursor: pointer; }
.seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg-opt span {
  display: block; text-align: center; padding: 9px 10px; border-radius: 10px; font-weight: 700; font-size: 13px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); transition: all .15s;
}
.seg-opt.badge-live, .seg-opt.badge-step1 { background: none; padding: 0; border-radius: 0; }
.seg-opt.badge-live input:checked + span { background: #d9f5ea; color: #047857; border-color: #8fdcbc; }
.seg-opt.badge-step1 input:checked + span { background: #e5e7ff; color: #4338ca; border-color: #b4b9fb; }

.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; }
.swatch span { display: block; width: 30px; height: 30px; border-radius: 9px; background: var(--c); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .25); transition: transform .12s; }
.swatch input:checked + span { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--c); transform: scale(1.05); }

.role-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.role-opt { position: relative; cursor: pointer; }
.role-opt input { position: absolute; opacity: 0; }
.role-opt-body {
  display: flex; flex-direction: column; gap: 6px; height: 100%; padding: 10px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); transition: all .15s;
}
.role-opt-body small { font-size: 11.5px; color: var(--muted); line-height: 1.35; }
.role-opt input:checked + .role-opt-body { border-color: var(--ink); background: #fff; box-shadow: 0 0 0 1px var(--ink); }
.badge-admin, .badge-reporter, .badge-viewer { align-self: flex-start; }

.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.check { position: relative; cursor: pointer; }
.check input { position: absolute; opacity: 0; }
.check span {
  display: flex; align-items: center; gap: 7px; padding: 9px 11px; border-radius: 10px; font-weight: 600; font-size: 13px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); transition: all .15s;
}
.check span .ic { width: 16px; height: 16px; color: var(--c); }
.check input:checked + span { border-color: var(--c); background: color-mix(in srgb, var(--c) 10%, white); box-shadow: 0 0 0 1px var(--c); color: var(--ink); }
.check input:focus-visible + span, .role-opt input:focus-visible + .role-opt-body, .seg-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; font-size: 13.5px; }
.toggle input { position: absolute; opacity: 0; }
.track { width: 42px; height: 24px; border-radius: 999px; background: #d6d1c6; position: relative; transition: background .15s; flex: none; }
.thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .15s; }
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track .thumb { transform: translateX(18px); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 19, 24, .45); backdrop-filter: blur(4px); animation: fade .18s ease; }
.modal-card {
  position: relative; width: min(680px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: var(--surface); border-radius: 20px; box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .5);
  animation: pop .2s cubic-bezier(.2, .9, .3, 1.2);
}
.modal-card.narrow { width: min(480px, 100%); }
.modal-card.wide { width: min(860px, 100%); }
.import-help { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); color: #0b5d56; font-size: 13px; line-height: 1.55; }
.import-stats { font-style: normal; font-weight: 600; color: var(--accent); }
[data-import-text] { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; white-space: pre; overflow-x: auto; tab-size: 18; }
.import-preview { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.import-preview:empty { display: none; }
.import-preview .table td { padding: 7px 12px; font-size: 13px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 20px 22px 0; }
.modal-head h3 { font-size: 20px; }
.modal-head .eyebrow { color: var(--c, var(--muted)); margin-bottom: 2px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 22px 20px; border-top: 1px solid var(--line-2); margin-top: 16px; }
body.modal-open { overflow: hidden; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Users page ---------- */
.role-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
.role-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.role-top { display: flex; justify-content: space-between; align-items: center; }
.role-top strong { font-size: 26px; font-weight: 800; }
.role-card p { color: var(--muted); font-size: 13px; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell strong, .user-cell small { display: block; line-height: 1.3; }

/* ---------- Profile ---------- */
.profile-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.profile-card { padding: 22px; }
.profile-top { display: flex; gap: 16px; align-items: center; margin-bottom: 10px; }
.profile-top h2 { font-size: 20px; }
.profile-top .badge { margin-top: 6px; }
.divider { height: 1px; background: var(--line-2); margin: 18px 0; }

/* ---------- Login ---------- */
.auth-page {
  min-height: 100vh; margin: 0; color: #e8ecf2; background: #0b0f14;
  display: flex; flex-direction: column; position: relative; overflow-x: hidden;
}
.auth-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
  background-image:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000 30%, transparent 85%);
          mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000 30%, transparent 85%);
}
.orb { position: fixed; border-radius: 50%; filter: blur(90px); opacity: .55; z-index: 0; pointer-events: none; }
.orb-1 { width: 520px; height: 520px; background: #0f766e; top: -160px; left: -120px; animation: drift 18s ease-in-out infinite alternate; }
.orb-2 { width: 460px; height: 460px; background: #4338ca; bottom: -180px; right: -120px; opacity: .45; animation: drift 22s ease-in-out infinite alternate-reverse; }
.orb-3 { width: 280px; height: 280px; background: #14b8a6; top: 40%; left: 58%; opacity: .18; animation: drift 26s ease-in-out infinite alternate; }
@keyframes drift { to { transform: translate(60px, 40px) scale(1.08); } }
@media (prefers-reduced-motion: reduce) { .orb { animation: none; } }

.auth-top { position: relative; z-index: 2; display: flex; justify-content: space-between; align-items: center; padding: 24px 32px; }
.auth-top .brand { padding: 0; }
.auth-lang { display: inline-flex; align-items: center; gap: 2px; padding: 3px 3px 3px 10px; border-radius: 999px;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1); color: #8b94a5; backdrop-filter: blur(8px); }
.auth-lang .ic { width: 15px; height: 15px; margin-right: 4px; }
.auth-lang a { padding: 6px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 600; color: #a7b0bf; }
.auth-lang a.on { background: #fff; color: #0b0f14; }
.auth-lang a:not(.on):hover { color: #fff; }

.auth-main { position: relative; z-index: 2; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px 16px 40px; }
.auth-card {
  width: min(420px, 100%); padding: 36px 32px 30px; border-radius: 24px;
  background: linear-gradient(180deg, rgba(23, 29, 38, .88), rgba(15, 19, 25, .9));
  border: 1px solid rgba(255,255,255,.09);
  box-shadow: 0 1px 0 rgba(255,255,255,.06) inset, 0 40px 80px -30px rgba(0,0,0,.8), 0 0 0 1px rgba(0,0,0,.3);
  backdrop-filter: blur(16px);
  display: flex; flex-direction: column; gap: 18px;
  animation: pop .35s cubic-bezier(.2,.9,.3,1.1);
}
.auth-head { text-align: center; margin-bottom: 4px; }
.auth-logo {
  width: 56px; height: 56px; margin: 0 auto 18px; border-radius: 17px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(140deg, #2dd4bf, #0f766e 70%);
  box-shadow: 0 12px 30px -8px rgba(20,184,166,.6), inset 0 1px 0 rgba(255,255,255,.3);
}
.auth-logo .ic { width: 28px; height: 28px; stroke-width: 2.4; }
.auth-head h1 { font-size: 28px; color: #fff; }
.auth-head p { color: #8b94a5; font-size: 14px; margin-top: 8px; }

.auth-error { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 12px; font-size: 13.5px; font-weight: 500;
  background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.3); color: #fca5a5; }
.auth-error .ic { width: 17px; height: 17px; }

.auth-field { display: flex; flex-direction: column; gap: 7px; }
.auth-field > span { font-size: 12.5px; font-weight: 600; color: #b4bcc9; }
.auth-input { position: relative; }
.auth-input > .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: #6b7486; pointer-events: none; transition: color .15s; }
.auth-input input {
  height: 50px; padding: 0 46px 0 44px; border-radius: 13px; font-size: 15px;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.1); color: #fff;
}
.auth-input input::placeholder { color: #5d6575; }
.auth-input input:focus { background: rgba(255,255,255,.06); border-color: #2dd4bf; box-shadow: 0 0 0 4px rgba(45,212,191,.15); }
.auth-input:focus-within > .ic { color: #5eead4; }
.auth-input input:-webkit-autofill { -webkit-text-fill-color: #fff; -webkit-box-shadow: 0 0 0 1000px #18202a inset; caret-color: #fff; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; border: 0; border-radius: 10px;
  background: transparent; color: #6b7486; cursor: pointer; display: grid; place-items: center; }
.pw-toggle:hover { color: #fff; background: rgba(255,255,255,.06); }
.pw-toggle .eye-off { display: none; }
.pw-toggle.on .eye-open { display: none; }
.pw-toggle.on .eye-off { display: block; color: #5eead4; }

.auth-submit {
  margin-top: 6px; height: 52px; border: 0; border-radius: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 15.5px; font-weight: 700; color: #04201d;
  background: linear-gradient(180deg, #5eead4, #2dd4bf);
  box-shadow: 0 12px 28px -10px rgba(45,212,191,.7), inset 0 1px 0 rgba(255,255,255,.5);
  transition: transform .1s, filter .15s, box-shadow .15s;
}
.auth-submit .ic { width: 18px; height: 18px; stroke-width: 2.4; transition: transform .15s; }
.auth-submit:hover { filter: brightness(1.05); box-shadow: 0 16px 34px -10px rgba(45,212,191,.85), inset 0 1px 0 rgba(255,255,255,.5); }
.auth-submit:hover .ic { transform: translateX(3px); }
.auth-submit:active { transform: translateY(1px); }
.auth-submit:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.auth-card.busy .auth-submit { opacity: .7; pointer-events: none; }

.auth-note { display: flex; align-items: center; gap: 7px; margin-top: 22px; font-size: 12.5px; color: #6b7486; }
.auth-note .ic { width: 14px; height: 14px; }

@media (max-width: 520px) {
  .auth-top { padding: 16px; }
  .auth-top .brand-name { display: none; }
  .auth-card { padding: 28px 20px 24px; border-radius: 20px; }
  .auth-head h1 { font-size: 24px; }
}

/* ---------- Error ---------- */
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.error-box { padding: 40px; text-align: center; width: min(420px, 100%); }
.error-code { font-size: 64px; font-weight: 800; letter-spacing: -.04em; color: var(--accent); }
.error-box p { margin: 6px 0 22px; color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .chart-row.with-pie { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 80; transform: translateX(-100%); transition: transform .25s ease; }
  body.sidebar-open .sidebar { transform: none; box-shadow: 0 0 60px rgba(0, 0, 0, .4); }
  body.sidebar-open .scrim { display: block; position: fixed; inset: 0; z-index: 70; background: rgba(15, 19, 24, .4); }
  .topbar .menu-btn { display: inline-grid; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px 48px; }
  .flash { margin: 14px 16px 0; }
  .role-cards, .profile-grid { grid-template-columns: 1fr; }
  .mobile-only { display: grid; }
}
@media (max-width: 600px) {
  h1 { font-size: 23px; }
  .folder-grid { grid-template-columns: 1fr; }
  .mini-stats { grid-template-columns: repeat(2, 1fr); }
  .mini span { min-height: 0; }
  .form-grid { grid-template-columns: 1fr; padding: 18px 16px; }
  .modal-head, .modal-foot { padding-left: 16px; padding-right: 16px; }
  .hint { margin: 0 16px; }
  .role-pick { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 20px; }
  .crumbs a { display: none; }
  .crumbs > .ic:first-of-type { display: none; }
  .lang-switch > .ic { display: none; }
  .lang-switch { padding-left: 3px; }
  .toolbar, .range { width: 100%; }
  .range label { flex: 1; min-width: 130px; }
  .range input { width: 100%; }
  .chart-box { height: 260px; }
  .subfolder { padding: 10px 12px 10px 10px; }
  .sf-text small { display: none; }
}
