/* ==========================================================================
   Next Digit Learner – DRM Portal
   Light design system
   ========================================================================== */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #f2f4f7;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #344054;
  --text-3: #667085;
  --text-4: #98a2b3;

  --brand: #4f46e5;
  --brand-hover: #4338ca;
  --brand-50: #eef2ff;
  --brand-100: #e0e7ff;

  --success: #067647;  --success-bg: #ecfdf3;  --success-border: #abefc6;
  --warning: #b54708;  --warning-bg: #fffaeb;  --warning-border: #fedf89;
  --danger: #d92d20;   --danger-bg: #fef3f2;   --danger-border: #fecdca;
  --info: #175cd3;     --info-bg: #eff8ff;     --info-border: #b2ddff;
  --violet: #6941c6;   --violet-bg: #f4f3ff;   --violet-border: #d9d6fe;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 20px 24px -4px rgba(16, 24, 40, .10), 0 8px 8px -4px rgba(16, 24, 40, .04);
  --ring: 0 0 0 4px rgba(79, 70, 229, .14);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hind Siliguri", "Noto Sans Bengali", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); }
code { font: 12.5px var(--mono); background: var(--surface-3); padding: 1px 6px; border-radius: 5px; color: var(--text-2); }
h1, h2, h3 { margin: 0; color: var(--text); letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); padding: 20px 14px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: linear-gradient(135deg, #6366f1, #4338ca); color: #fff; font-weight: 700; font-size: 13px; letter-spacing: .02em; box-shadow: var(--shadow-sm); }
.brand-name { font-weight: 650; font-size: 14.5px; line-height: 1.2; }
.brand-sub { font-size: 12px; color: var(--text-3); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-4); padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a.active { background: var(--brand-50); color: var(--brand); }
.nav a .count { margin-left: auto; font-size: 12px; color: var(--text-3); background: var(--surface-3); border-radius: 99px; padding: 0 8px; }
.nav a.active .count { background: var(--brand-100); color: var(--brand); }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding: 14px 6px 0; display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-50); color: var(--brand); display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: none; }
.who { min-width: 0; flex: 1; }
.who .name { font-weight: 600; font-size: 13px; }
.who .email { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 28px 32px 20px; }
.page-head .sub { color: var(--text-3); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.content { padding: 0 32px 48px; max-width: 1240px; }

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head .sub { color: var(--text-3); font-size: 13px; margin-top: 2px; }
.card-body { padding: 20px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); display: flex; justify-content: flex-end; gap: 8px; align-items: center; }

.section { display: grid; grid-template-columns: 280px 1fr; gap: 32px; padding: 24px 0; border-top: 1px solid var(--border); }
.section:first-child { border-top: 0; padding-top: 0; }
.section-intro h2 { font-size: 15px; }
.section-intro p { color: var(--text-3); margin-top: 6px; font-size: 13.5px; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-xs); }
.stat .label { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 13px; font-weight: 500; }
.stat .label svg { color: var(--text-4); width: 16px; height: 16px; }
.stat .value { font-size: 26px; font-weight: 650; margin-top: 6px; letter-spacing: -0.02em; }
.stat .hint { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.stat .live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px var(--success-bg); }

/* ---------- Forms ---------- */
label, .label-text { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.field + .field { margin-top: 16px; }
.field .help { font-size: 12.5px; color: var(--text-3); margin-top: 6px; }
input, select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface);
  color: var(--text); font: inherit; box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--text-4); }
input:focus, select:focus, textarea:focus { outline: none; border-color: #a5b4fc; box-shadow: var(--shadow-xs), var(--ring); }
textarea { font: 13px/1.6 var(--mono); resize: vertical; }
select { appearance: none; padding-right: 34px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23667085' stroke-width='1.8' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center; }
input[type="file"] { padding: 6px; box-shadow: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.input-group { display: flex; gap: 8px; }
.input-group input { flex: 1; min-width: 0; }

.switch { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; padding: 2px 0; }
.switch + .switch { margin-top: 16px; }
.switch input { appearance: none; width: 36px; height: 20px; flex: none; border-radius: 99px; background: var(--border-strong); position: relative; margin: 1px 0 0; padding: 0; border: 0; box-shadow: none; cursor: pointer; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(16,24,40,.2); transition: transform .15s; }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(16px); }
.switch input:focus-visible { box-shadow: var(--ring); }
.switch .t { font-weight: 500; color: var(--text); }
.switch .d { color: var(--text-3); font-size: 13px; margin-top: 2px; }

.choice { display: grid; gap: 10px; }
.choice label { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin: 0; cursor: pointer; transition: border-color .15s, background .15s; font-weight: 400; }
.choice label:hover { border-color: var(--border-strong); }
.choice label:has(input:checked) { border-color: var(--brand); background: var(--brand-50); box-shadow: 0 0 0 1px var(--brand) inset; }
.choice input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--brand); box-shadow: none; flex: none; }
.choice .t { font-weight: 600; color: var(--text); }
.choice .d { color: var(--text-3); font-size: 13px; margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 14px; border-radius: 8px;
  border: 1px solid var(--brand); background: var(--brand); color: #fff; font: 600 14px/1.2 var(--font); cursor: pointer;
  box-shadow: var(--shadow-xs); white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: .55; cursor: default; }
.btn svg.i { width: 16px; height: 16px; }
.btn.secondary { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); }
.btn.secondary:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: #b42318; }
.btn.danger-soft { background: var(--surface); color: var(--danger); border-color: var(--danger-border); }
.btn.danger-soft:hover { background: var(--danger-bg); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--text-3); cursor: pointer; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }
.icon-btn svg.i { width: 17px; height: 17px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--text-3); font: 500 13px var(--font); cursor: pointer; }
.link-btn:hover { color: var(--brand); }

/* ---------- Badges & pills ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 500; border: 1px solid; white-space: nowrap; line-height: 1.5; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.success { color: var(--success); background: var(--success-bg); border-color: var(--success-border); }
.badge.warning { color: var(--warning); background: var(--warning-bg); border-color: var(--warning-border); }
.badge.danger { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-border); }
.badge.info { color: var(--info); background: var(--info-bg); border-color: var(--info-border); }
.badge.violet { color: var(--violet); background: var(--violet-bg); border-color: var(--violet-border); }
.badge.neutral { color: var(--text-2); background: var(--surface-3); border-color: var(--border); }
.chip { display: inline-block; font-size: 11.5px; font-weight: 500; color: var(--text-2); background: var(--surface-3); border-radius: 5px; padding: 1px 6px; margin: 0 3px 3px 0; }

.pills { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font: 500 13px var(--font); cursor: pointer; transition: all .15s; }
.pill:hover { border-color: var(--border-strong); color: var(--text); }
.pill.active { background: var(--text); border-color: var(--text); color: #fff; }
.pill .n { font-size: 12px; color: var(--text-4); }
.pill.active .n { color: #c7cbd4; }

.segmented { display: inline-flex; background: var(--surface-3); border-radius: 9px; padding: 3px; gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; font: 500 13px var(--font); color: var(--text-3); cursor: pointer; }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.search { position: relative; width: 260px; max-width: 100%; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-4); }
.search input { padding-left: 34px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--text-3); background: var(--surface-2); padding: 10px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-2); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
td.actions { text-align: right; white-space: nowrap; }
.cell-title { display: flex; align-items: center; gap: 12px; min-width: 260px; }
.thumb { width: 80px; height: 45px; border-radius: 6px; background: var(--surface-3) center/cover no-repeat; flex: none; border: 1px solid var(--border); display: grid; place-items: center; color: var(--text-4); overflow: hidden; }
.thumb svg { width: 18px; height: 18px; }
.cell-title .t { font-weight: 600; color: var(--text); }
.cell-title .m { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }
.progress { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; width: 120px; margin-top: 6px; }
.progress i { display: block; height: 100%; width: 0; background: var(--brand); border-radius: 99px; transition: width .4s; }
.err-text { font-size: 12px; color: var(--danger); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 4px; }

/* ---------- Empty states ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty .ico { width: 44px; height: 44px; border-radius: 10px; margin: 0 auto 12px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-3); }
.empty h3 { color: var(--text); margin-bottom: 4px; }

/* ---------- Upload ---------- */
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); padding: 28px 20px; text-align: center; transition: border-color .15s, background .15s; }
.dropzone.over { border-color: var(--brand); background: var(--brand-50); }
.dropzone .ico { width: 44px; height: 44px; border-radius: 10px; margin: 0 auto 10px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); }
.dropzone h3 { font-size: 15px; }
.dropzone p { color: var(--text-3); margin-top: 4px; font-size: 13.5px; }
.dropzone .row { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.dropzone select { width: auto; min-width: 200px; }
.uploads { margin-top: 12px; display: grid; gap: 8px; }
.up-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.up-row .name { font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-row .size { color: var(--text-3); font-weight: 400; margin-left: 6px; }
.up-row .state { font-size: 12.5px; color: var(--text-3); }
.up-row .state.err { color: var(--danger); }
.up-row .state.ok { color: var(--success); }
.up-row .progress { grid-column: 1 / -1; width: 100%; margin: 0; }
.drop-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(79, 70, 229, .08); border: 2px dashed var(--brand); display: none; place-items: center; font-weight: 600; color: var(--brand); font-size: 16px; pointer-events: none; }
.drop-overlay.show { display: grid; }

/* ---------- Callouts ---------- */
.callout { display: flex; gap: 10px; align-items: flex-start; border: 1px solid; border-radius: var(--radius); padding: 12px 14px; font-size: 13.5px; }
.callout svg.i { width: 18px; height: 18px; margin-top: 1px; }
.callout.warning { color: var(--warning); background: var(--warning-bg); border-color: var(--warning-border); }
.callout.info { color: var(--info); background: var(--info-bg); border-color: var(--info-border); }
.callout.danger { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-border); }
.callout b { font-weight: 600; }
.callout + * { margin-top: 16px; }

.status-list { display: grid; gap: 8px; }
.status-item { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--text-2); }
.status-item .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.status-item.ok .dot { background: var(--success); box-shadow: 0 0 0 3px var(--success-bg); }
.status-item.no .dot { background: var(--border-strong); box-shadow: 0 0 0 3px var(--surface-3); }

/* ---------- Code ---------- */
.code { position: relative; background: #0f172a; color: #e2e8f0; border-radius: var(--radius); padding: 16px; font: 12.5px/1.65 var(--mono); white-space: pre; overflow-x: auto; margin: 0; }
.code-wrap { position: relative; }
.code-wrap .btn { position: absolute; top: 10px; right: 10px; background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.18); color: #fff; box-shadow: none; }
.code-wrap .btn:hover { background: rgba(255,255,255,.18); }

/* ---------- Dialog ---------- */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(760px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(16, 24, 40, .55); backdrop-filter: blur(2px); }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 20px 24px 0; }
.dlg-head .sub { color: var(--text-3); font-size: 13px; margin-top: 2px; }
.dlg-body { padding: 20px 24px 24px; }
.dlg-body > * + * { margin-top: 16px; }
.preview { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); overflow: hidden; }
.preview iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 16px; font-size: 13.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; color: var(--text); word-break: break-all; }

/* ---------- Toast ---------- */
#toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 16px); background: var(--text); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 500; opacity: 0; transition: .2s; pointer-events: none; z-index: 100; box-shadow: var(--shadow-lg); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.error-text { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 8px; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 50% -10%, #eef2ff 0%, var(--bg) 60%); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 32px; }
.auth-card .brand-mark { width: 44px; height: 44px; font-size: 15px; border-radius: 11px; margin-bottom: 20px; }
.auth-card h1 { font-size: 22px; }
.auth-card .sub { color: var(--text-3); margin: 6px 0 24px; }
.auth-foot { text-align: center; color: var(--text-4); font-size: 12.5px; margin-top: 18px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section { grid-template-columns: 1fr; gap: 14px; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { padding: 0; margin-right: auto; }
  .nav { flex-direction: row; flex-wrap: wrap; width: 100%; order: 3; }
  .nav-label, .nav a .count { display: none; }
  .sidebar-foot { margin: 0; border: 0; padding: 0; }
  .sidebar-foot .who { display: none; }
  .page-head { padding: 20px 16px 16px; }
  .content { padding: 0 16px 40px; }
  .grid-2 { grid-template-columns: 1fr; }
  .search { width: 100%; }
}

/* Stacked title + description inside switches and choice cards */
.switch .t, .switch .d, .choice .t, .choice .d { display: block; }
.grid-2 > .field + .field { margin-top: 0; }
