:root {
  --tp-ink: #0f172a;
  --tp-slate: #1e293b;
  --tp-muted: #64748b;
  --tp-line: #e2e8f0;
  --tp-paper: #f8fafc;
  --tp-card: #ffffff;
  --tp-teal: #0d9488;
  --tp-teal-2: #14b8a6;
  --tp-indigo: #4f46e5;
  --tp-navy: #0f172a;
  --tp-gold: #f59e0b;
  --tp-success: #10b981;
  --tp-warning: #f59e0b;
  --tp-danger: #f43f5e;
  --sidebar-w: 268px;
  --topbar-h: 64px;
  --radius: 16px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  --font: "Plus Jakarta Sans", system-ui, sans-serif;
  --ui: "Plus Jakarta Sans", "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  --tp-ink: #e2e8f0;
  --tp-slate: #cbd5e1;
  --tp-muted: #94a3b8;
  --tp-line: #334155;
  --tp-paper: #0f172a;
  --tp-card: #1e293b;
  --tp-navy: #020617;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: var(--ui);
  color: var(--tp-ink);
  background: var(--tp-paper);
}

a { color: var(--tp-indigo); text-decoration: none; }
a:hover { color: #4338ca; }
[data-theme="dark"] a:hover { color: #a5b4fc; }

.tp-shell { display: flex; min-height: 100vh; }
.tp-sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 55%, #312e81 160%);
  color: #dbe7ef;
  position: fixed;
  inset: 0 auto 0 0;
  padding: 22px 16px;
  overflow-y: auto;
  z-index: 20;
}
.tp-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 10px 22px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 18px;
}
.tp-mark {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, #4f46e5, #0d9488);
  display: grid; place-items: center; color: #fff; font-weight: 800;
  font-family: var(--font); font-size: 18px;
  overflow: hidden;
}
.tp-mark img { width: 100%; height: 100%; object-fit: cover; }
.tp-brand h1 { font-size: 18px; margin: 0; color: #fff; letter-spacing: -.02em; }
.tp-brand small { color: #a5b4fc; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; }

.tp-nav a, .tp-nav .nav-label {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px; color: #c5d4de; font-size: 14px; font-weight: 500;
}
.tp-nav a:hover, .tp-nav a.active { background: rgba(255,255,255,.08); color: #fff; }
.tp-nav .nav-label {
  margin-top: 16px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: #7f9ca8; padding-bottom: 4px;
}

.tp-main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; }
.tp-topbar {
  height: var(--topbar-h);
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--tp-line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; position: sticky; top: 0; z-index: 10;
}
[data-theme="dark"] .tp-topbar { background: rgba(15,23,42,.88); }
.tp-content { padding: 28px; }
.tp-page-title { font-family: var(--font); font-size: 30px; margin: 0 0 6px; letter-spacing: -.03em; font-weight: 700; }
.tp-page-sub { color: var(--tp-muted); margin-bottom: 22px; }

.tp-card {
  background: var(--tp-card);
  border: 1px solid var(--tp-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.tp-card h3 { font-size: 15px; margin: 0 0 14px; font-weight: 700; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat {
  background: var(--tp-card); border: 1px solid var(--tp-line); border-radius: var(--radius); padding: 18px 18px 16px;
  box-shadow: var(--shadow);
}
.stat .k { color: var(--tp-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.stat .v { font-family: var(--font); font-size: 28px; margin-top: 6px; font-weight: 700; }
.stat .hint { color: var(--tp-muted); font-size: 12px; margin-top: 4px; }

.table { --bs-table-bg: transparent; }
.table thead th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--tp-muted); font-weight: 600; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: #e0e7ff; color: #4f46e5; display: inline-grid; place-items: center;
  font-weight: 700; font-size: 12px;
}

.auth-wrap {
  min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr;
}
.auth-visual {
  background:
    radial-gradient(800px 400px at 20% 20%, rgba(79,70,229,.35), transparent 50%),
    linear-gradient(160deg, #0f172a, #134e4a);
  color: #fff; padding: 64px; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-visual h2 { font-family: var(--font); font-size: 44px; line-height: 1.15; max-width: 520px; font-weight: 700; }
.auth-panel { display: grid; place-items: center; padding: 40px 24px; background: #f8fafc; }
.auth-card { width: min(440px, 100%); background: #fff; border-radius: 20px; padding: 32px; border: 1px solid var(--tp-line); box-shadow: var(--shadow); }

.btn-teal { background: var(--tp-indigo); border-color: var(--tp-indigo); color: #fff; }
.btn-teal:hover { background: #4338ca; border-color: #4338ca; color: #fff; }
.btn-primary { background: var(--tp-indigo); border-color: var(--tp-indigo); }
.btn-primary:hover { background: #4338ca; border-color: #4338ca; }
.otp-input { letter-spacing: .4em; font-size: 24px; text-align: center; font-weight: 700; }

.nine-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; min-height: 360px; }
.nine-cell {
  border: 1px dashed #cbd5e1; border-radius: 12px; padding: 10px; background: #f8fafc; min-height: 110px;
}
.nine-cell.hot { background: #ecfdf5; border-color: #99f6e4; }
.nine-chip { display: inline-block; background: #fff; border: 1px solid var(--tp-line); border-radius: 999px; padding: 2px 8px; font-size: 12px; margin: 2px; }

.praise-card { border-left: 4px solid var(--tp-teal); }
.org-node { margin-left: 16px; padding: 8px 0; }
.org-node .box { display: inline-flex; gap: 8px; align-items: center; background: var(--tp-card); border: 1px solid var(--tp-line); border-radius: 10px; padding: 6px 10px; }

.user-chip { display: flex; align-items: center; gap: 10px; }
.flash { border-radius: 12px; }

.trial-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  background: linear-gradient(90deg, #4f46e5, #0d9488);
  color: #fff; padding: .65rem 1.25rem; border-radius: 12px; margin-bottom: 1rem;
}
.trial-banner--expired { background: linear-gradient(90deg, #f43f5e, #b45309); }
.empty-state {
  text-align: center; padding: 2.5rem 1rem; color: var(--tp-muted);
  border: 1px dashed var(--tp-line); border-radius: var(--radius); background: var(--tp-paper);
}

.aligna-toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 1080;
  display: flex; flex-direction: column; gap: 10px; max-width: min(360px, calc(100vw - 32px));
}
.aligna-toast {
  background: rgba(15, 23, 42, .82);
  color: #fff;
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  padding: .85rem 1rem;
  box-shadow: 0 12px 30px rgba(0,0,0,.2);
  opacity: 0; transform: translateY(8px); transition: .25s ease;
}
.aligna-toast.is-in { opacity: 1; transform: translateY(0); }
.aligna-toast--success { border-left: 3px solid var(--tp-success); }
.aligna-toast--error { border-left: 3px solid var(--tp-danger); }
.aligna-toast--warning { border-left: 3px solid var(--tp-warning); }
.aligna-toast--info { border-left: 3px solid #38bdf8; }

/* Math CAPTCHA */
.aligna-captcha {
  background: #f8fafc;
  border: 1px solid var(--tp-line, #e2e8f0);
  border-radius: 12px;
  padding: .85rem 1rem;
}
.aligna-captcha-label {
  margin-bottom: .45rem;
  font-weight: 600;
  color: #0f172a;
}
.aligna-captcha-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .65rem;
}
.aligna-captcha-input {
  width: 5.5rem;
  min-height: 44px;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  padding: .45rem .7rem;
  font-weight: 700;
  font-size: 1.05rem;
  text-align: center;
  background: #fff;
}
.aligna-captcha-input:focus {
  outline: none;
  border-color: #4338ca;
  box-shadow: 0 0 0 3px rgba(67, 56, 202, .18);
}
.aligna-captcha-hint {
  font-size: .82rem;
  color: #64748b;
}

.status-on_track, .badge-on-track { color: var(--tp-success); }
.status-at_risk { color: var(--tp-warning); }
.status-behind { color: var(--tp-danger); }

@media print {
  .tp-sidebar, .tp-topbar, .no-print, .trial-banner, .aligna-toasts { display: none !important; }
  .tp-main { margin: 0; }
  .tp-content { padding: 0; }
  .tp-card { box-shadow: none; border: 1px solid #ddd; }
}

@media (max-width: 992px) {
  .tp-sidebar { position: relative; width: 100%; }
  .tp-main { margin-left: 0; }
  .stat-grid, .auth-wrap { grid-template-columns: 1fr; }
  .auth-visual { min-height: 240px; padding: 32px; }
}
