/* =============================================================
   MediWord Admin Panel — Modern SaaS Dashboard UI v2.0
   Font: Inter (Google Fonts)
   Brand: Deep Forest Teal (#0F6E56)
   ============================================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── Brand teal ─────────────────────────────────────────── */
  --teal-900: #052E22;
  --teal-800: #074A38;
  --teal-700: #0F6E56;
  --teal-600: #1A8C70;
  --teal-500: #28B589;
  --teal-400: #4ECBA3;
  --teal-200: #9EDFCC;
  --teal-100: #D0F2E8;
  --teal-50:  #E8FAF4;

  /* ── Neutrals ───────────────────────────────────────────── */
  --white:    #FFFFFF;
  --cream:    #F0F5F3;   /* compat alias */
  --cream-2:  #EBF2EE;   /* compat alias */

  /* ── Borders ────────────────────────────────────────────── */
  --border:   #E2E8F0;
  --border-2: #CBD5E1;

  /* ── Text ───────────────────────────────────────────────── */
  --text-1:   #0F172A;
  --text-2:   #475569;
  --text-3:   #94A3B8;

  /* ── Status ─────────────────────────────────────────────── */
  --coral:     #DC2626;
  --coral-900: #7F1D1D;
  --coral-50:  #FEF2F2;
  --amber:     #D97706;
  --amber-900: #78350F;
  --amber-50:  #FFFBEB;
  --purple-900:#4C1D95;
  --purple-50: #F5F3FF;
  --blue-900:  #1E3A5F;
  --blue-50:   #EFF6FF;
  --gray-50:   #F8FAFC;
  --gray-900:  #1E293B;

  /* ── Sidebar ─────────────────────────────────────────────── */
  --sb-bg:      #0A1F1A;
  --sb-hover:   rgba(255,255,255,0.055);
  --sb-active:  rgba(255,255,255,0.10);
  --sb-text:    rgba(255,255,255,0.74);
  --sb-muted:   rgba(255,255,255,0.36);
  --sb-border:  rgba(255,255,255,0.07);

  /* ── Shadows ─────────────────────────────────────────────── */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:    0 4px 12px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.08), 0 3px 8px rgba(0,0,0,0.04);
  --shadow-lg: 0 20px 48px rgba(0,0,0,0.10), 0 6px 16px rgba(0,0,0,0.05);

  /* ── Radii ───────────────────────────────────────────────── */
  --radius-sm: 5px;
  --radius:    8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* ── Motion ──────────────────────────────────────────────── */
  --ease: 140ms cubic-bezier(0.4, 0, 0.2, 1);

  /* ── Backward-compat aliases (legacy view support) ───────── */
  --bg-0:   #FFFFFF;
  --bg-1:   #F8FAFC;
  --bg-2:   #F1F5F9;
  --text-0: #0F172A;
}

/* ── Base ────────────────────────────────────────────────── */
html, body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--text-1);
  background: #F0F5F3;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
svg { display: block; }

/* ── Shell ───────────────────────────────────────────────── */
.mw-shell { display: flex; min-height: 100vh; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.mw-side {
  width: 256px;
  background: var(--sb-bg);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  border-right: 1px solid rgba(0,0,0,0.18);
  box-shadow: 2px 0 12px rgba(0,0,0,0.14);
  z-index: 40;
}

/* Brand */
.mw-brand {
  display: flex;
  align-items: center;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
}
.mw-brand-logo {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--teal-600);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; flex-shrink: 0;
}
.mw-brand-name {
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
  margin-left: 10px;
}

/* Nav */
.mw-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.mw-nav::-webkit-scrollbar { width: 3px; }
.mw-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.10); border-radius: 3px; }

.mw-nav-group {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--sb-muted);
  padding: 16px 10px 4px;
}

.mw-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  margin: 1px 0;
  font-size: 13.5px;
  font-weight: 400;
  color: var(--sb-text);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--ease), color var(--ease);
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mw-link:hover { background: var(--sb-hover); color: #fff; }
.mw-link.is-active {
  background: var(--sb-active);
  color: #fff;
  font-weight: 500;
}
.mw-link.is-active::before {
  content: '';
  position: absolute;
  left: 0; top: 5px; bottom: 5px;
  width: 3px;
  background: var(--teal-400);
  border-radius: 0 3px 3px 0;
}

/* Nav icon container */
.mw-nav-icon {
  width: 17px; height: 17px;
  flex-shrink: 0;
  opacity: 0.70;
  transition: opacity var(--ease);
  display: flex; align-items: center; justify-content: center;
}
.mw-link:hover .mw-nav-icon,
.mw-link.is-active .mw-nav-icon { opacity: 1; }

/* Sub links */
.mw-link-sub {
  padding-left: 36px;
  font-size: 13px;
  color: rgba(255,255,255,0.50);
}
.mw-link-sub:hover { color: rgba(255,255,255,0.85); }
.mw-link-sub.is-active { color: #fff; }
.mw-link-sub::before { display: none; }
.mw-link-sub.is-active::before { display: none; }

/* User footer */
.mw-user {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--sb-border);
  flex-shrink: 0;
}
.mw-user-name {
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ============================================================
   TOPBAR / HEADER
   ============================================================ */
.mw-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 20px;
  margin-bottom: 26px;
  border-bottom: 1px solid var(--border);
}
.mw-topbar-left { display: flex; align-items: center; gap: 10px; }
.mw-topbar-section {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.7px;
}
.mw-topbar-right { display: flex; align-items: center; gap: 10px; }
.mw-topbar-user { display: flex; align-items: center; gap: 10px; }
.mw-topbar-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal-600), var(--teal-800));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--teal-100);
}
.mw-topbar-userinfo { display: flex; flex-direction: column; }
.mw-topbar-username { font-size: 13px; font-weight: 500; color: var(--text-1); line-height: 1.3; }
.mw-topbar-role     { font-size: 11px; color: var(--text-3); line-height: 1.3; }
.mw-topbar-sep      { width: 1px; height: 20px; background: var(--border); margin: 0 2px; }
.mw-topbar-logout {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 13px;
  font-size: 12.5px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-2);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--ease);
}
.mw-topbar-logout:hover {
  background: var(--coral-50);
  color: var(--coral-900);
  border-color: #FECACA;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.mw-main {
  flex: 1;
  padding: 28px 36px 72px;
  overflow-x: auto;
  min-width: 0;
}

/* ── Headings ─────────────────────────────────────────────── */
h1.mw-h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-1);
  margin-bottom: 3px;
  line-height: 1.25;
}
h2.mw-h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
  letter-spacing: -0.2px;
}
.mw-card-title, .mw-card-t {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: -0.15px;
}
.mw-sub {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 20px;
  line-height: 1.6;
}

/* ── Layout primitives ────────────────────────────────────── */
.mw-row         { display: flex; gap: 12px; align-items: center; }
.mw-row-between { display: flex; justify-content: space-between; align-items: center; }
.mw-grid        { display: grid; gap: 16px; }
.mw-grid-2      { grid-template-columns: 1fr 1fr; }
.mw-grid-3      { grid-template-columns: repeat(3, 1fr); }
.mw-grid-4      { grid-template-columns: repeat(4, 1fr); }
.mw-mb-4  { margin-bottom: 4px; }
.mw-mb-6  { margin-bottom: 6px; }
.mw-mb-8  { margin-bottom: 8px; }
.mw-mb-12 { margin-bottom: 12px; }
.mw-mb-16 { margin-bottom: 16px; }
.mw-mb-20 { margin-bottom: 20px; }
.mw-mb-24 { margin-bottom: 24px; }
.mw-mt-16 { margin-top: 16px; }

/* ============================================================
   CARDS
   ============================================================ */
.mw-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}
.mw-card-tight { padding: 0; overflow: hidden; }
.mw-card-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

/* ============================================================
   ALERTS
   ============================================================ */
.mw-alert {
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.55;
  border: 1px solid;
}
.mw-alert-success { background: #F0FDF4; border-color: #BBF7D0; color: #065F46; }
.mw-alert-error   { background: var(--coral-50); border-color: #FECACA; color: var(--coral-900); }
.mw-alert-warning { background: var(--amber-50); border-color: #FDE68A; color: var(--amber-900); }

/* ============================================================
   METRIC CARDS
   ============================================================ */
.mw-metric {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.mw-metric::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--teal-700) 0%, var(--teal-400) 100%);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.mw-metric-lbl {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.65px;
  color: var(--text-3);
  margin-bottom: 9px;
}
.mw-metric-val {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.8px;
  line-height: 1.05;
  color: var(--text-1);
}
.mw-metric-delta { font-size: 11.5px; color: var(--text-3); margin-top: 7px; }
.mw-metric-up   { color: var(--teal-700); font-weight: 500; }
.mw-metric-down { color: var(--coral);    font-weight: 500; }

/* ============================================================
   CHIPS / BADGES
   ============================================================ */
.mw-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 20px;
  line-height: 1.8;
  letter-spacing: 0.1px;
  white-space: nowrap;
}
.mw-chip-teal   { background: var(--teal-100);  color: #065F46; }
.mw-chip-coral  { background: #FEF2F2;           color: var(--coral-900); }
.mw-chip-amber  { background: var(--amber-50);   color: var(--amber-900); }
.mw-chip-red    { background: var(--coral-50);   color: var(--coral-900); }
.mw-chip-purple { background: var(--purple-50);  color: var(--purple-900); }
.mw-chip-blue   { background: var(--blue-50);    color: var(--blue-900); }
.mw-chip-gray   { background: var(--gray-50);    color: var(--text-2); border: 1px solid var(--border); }

.mw-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}

/* ============================================================
   TABS
   ============================================================ */
.mw-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 0;
}
.mw-tab {
  display: inline-block;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  user-select: none;
  transition: color var(--ease);
  text-decoration: none;
}
.mw-tab:hover { color: var(--text-1); }
.mw-tab.is-active {
  color: var(--teal-700);
  border-bottom-color: var(--teal-700);
  font-weight: 600;
}

/* ============================================================
   FORMS
   ============================================================ */
.mw-lab {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
  letter-spacing: 0.1px;
}

.mw-input, .mw-select, .mw-textarea {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  font-size: 13.5px;
  font-family: inherit;
  font-weight: 400;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-1);
  transition: border-color var(--ease), box-shadow var(--ease);
  appearance: none;
  -webkit-appearance: none;
}
.mw-input::placeholder, .mw-textarea::placeholder { color: var(--text-3); }
.mw-textarea {
  height: auto;
  min-height: 96px;
  padding: 10px 12px;
  line-height: 1.65;
  resize: vertical;
}
.mw-input:focus, .mw-select:focus, .mw-textarea:focus {
  outline: none;
  border-color: var(--teal-600);
  box-shadow: 0 0 0 3px rgba(15,110,86,0.10);
}
.mw-input[type="file"] {
  height: auto;
  padding: 7px 10px;
  font-size: 12.5px;
  cursor: pointer;
}
.mw-select {
  background: var(--white)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2364748B' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E")
    no-repeat right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.mw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  background: var(--white);
  color: var(--text-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--ease);
  white-space: nowrap;
  letter-spacing: -0.1px;
  line-height: 1;
  user-select: none;
}
.mw-btn:hover {
  background: var(--gray-50);
  border-color: var(--border-2);
  box-shadow: var(--shadow-xs);
}
.mw-btn-primary {
  background: var(--teal-700);
  color: #fff;
  border-color: var(--teal-700);
  box-shadow: 0 1px 2px rgba(15,110,86,0.25), 0 0 0 1px rgba(15,110,86,0.15);
}
.mw-btn-primary:hover {
  background: var(--teal-800);
  border-color: var(--teal-800);
  box-shadow: 0 3px 8px rgba(15,110,86,0.32), 0 0 0 1px rgba(15,110,86,0.2);
}
.mw-btn-sm    { height: 30px; padding: 0 11px; font-size: 12px; border-radius: 6px; }
.mw-btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--teal-700);
}
.mw-btn-ghost:hover { background: var(--teal-50); border-color: transparent; box-shadow: none; }
.mw-btn-danger {
  background: var(--coral-50);
  color: var(--coral-900);
  border-color: #FECACA;
}
.mw-btn-danger:hover { background: #FEE2E2; border-color: #FCA5A5; box-shadow: none; }

/* ============================================================
   TABLES
   ============================================================ */
.mw-table-wrap { overflow-x: auto; }
.mw-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mw-table thead th {
  background: var(--gray-50);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  padding: 11px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.mw-table tbody tr { border-bottom: 1px solid var(--border); transition: background var(--ease); }
.mw-table tbody tr:last-child { border-bottom: none; }
.mw-table tbody tr:hover { background: var(--gray-50); }
.mw-table td { padding: 12px 16px; vertical-align: middle; color: var(--text-1); }

/* ── Grid-based list rows ─────────────────────────────────── */
.mw-th {
  display: grid;
  padding: 10px 20px;
  background: var(--gray-50);
  font-size: 11px; font-weight: 600;
  color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
.mw-tr {
  display: grid;
  padding: 13px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13px; align-items: center;
  transition: background var(--ease);
}
.mw-tr:last-child { border-bottom: none; }
.mw-tr:hover { background: var(--gray-50); }
.mw-tr-ellipsis { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mw-listrow {
  display: grid;
  padding: 13px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13px; align-items: center; gap: 8px;
  transition: background var(--ease);
}
.mw-listrow:last-child { border-bottom: none; }
.mw-listrow:hover { background: var(--gray-50); }

/* ── Fix: prevent grid display breaking native table elements ─── */
table th.mw-th    { display: table-cell; background: var(--gray-50); }
table tr.mw-listrow { display: table-row; padding: 0; gap: 0; }

/* ============================================================
   PANES / ANIMATION
   ============================================================ */
.mw-pane { display: none; animation: mwFade 0.15s ease; }
.mw-pane.is-active { display: block; }
@keyframes mwFade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

/* ── Action bar ───────────────────────────────────────────── */
.mw-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================================================
   DASHBOARD SPECIFICS
   ============================================================ */
.mw-spark { display: flex; gap: 3px; align-items: flex-end; height: 44px; }
.mw-spark-bar { flex: 1; background: var(--teal-400); border-radius: 2px 2px 0 0; }
.mw-act { padding: 10px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.mw-act:last-child { border: none; }

/* ============================================================
   QUESTIONS LIST
   ============================================================ */
.mw-qrow { border-bottom: 1px solid var(--border); }
.mw-qrow:last-child { border: none; }
.mw-qhead {
  display: grid;
  grid-template-columns: 70px 1fr 110px 110px 110px 100px 90px;
  padding: 13px 20px;
  font-size: 13px; align-items: center; cursor: pointer;
}
.mw-qhead:hover { background: var(--gray-50); }
.mw-qbody {
  padding: 18px 20px 22px;
  background: #FAFCFF;
  border-top: 1px solid var(--border);
  display: none;
}
.mw-qrow.is-open .mw-qbody { display: block; }
.mw-qrow.is-open .mw-qtoggle::after { content: "Collapse"; }
.mw-qtoggle { color: var(--teal-700); font-size: 12px; cursor: pointer; font-weight: 500; }
.mw-qtoggle::after { content: "Expand"; }

.mw-opt {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  font-size: 13px;
  background: var(--white);
}
.mw-opt-correct { background: #F0FDF4; border-color: #86EFAC; color: #065F46; font-weight: 500; }

.mw-fb { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 8px; font-size: 12px; }
.mw-fb-meta { color: var(--text-3); font-size: 11px; margin-bottom: 3px; }

/* ============================================================
   BULK UPLOAD
   ============================================================ */
.mw-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px; margin-bottom: 22px;
}
.mw-step {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
}
.mw-step.is-done   { background: #F0FDF4; border-color: #86EFAC; }
.mw-step.is-active { border: 2px solid var(--teal-700); padding: 13px 15px; box-shadow: 0 0 0 3px rgba(15,110,86,0.09); }
.mw-stepnum {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--border-2); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.mw-step.is-done .mw-stepnum, .mw-step.is-active .mw-stepnum { background: var(--teal-700); }
.mw-step-title { font-weight: 600; font-size: 13px; line-height: 1.2; }
.mw-step-meta  { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.mw-bulkrow { border-bottom: 1px solid var(--border); }
.mw-bulkrow:last-child { border: none; }
.mw-bulkhead { display: grid; grid-template-columns: 50px 1fr 130px 150px 120px; padding: 12px 18px; align-items: center; font-size: 13px; }
.mw-bulkbody { padding: 14px 18px; display: none; background: var(--gray-50); border-top: 1px solid var(--border); }
.mw-bulkrow.is-open .mw-bulkbody { display: block; }
.mw-bulkrow.is-warning .mw-bulkhead { background: #FFFBF0; }
.mw-bulkrow.is-error   .mw-bulkhead { background: #FFF5F5; }

/* ============================================================
   STRUCTURED EDITOR
   ============================================================ */
.mw-sect {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); margin-bottom: 10px;
  overflow: hidden; box-shadow: var(--shadow-xs);
}
.mw-sect-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; cursor: pointer; user-select: none;
  transition: background var(--ease);
}
.mw-sect-head:hover { background: var(--gray-50); }
.mw-sect-body { padding: 0 18px 18px; display: none; }
.mw-sect.is-open .mw-sect-body { display: block; }
.mw-sect.is-open .mw-sect-arrow::after { content: "▾"; }
.mw-sect-arrow { color: var(--text-3); font-size: 12px; margin-left: auto; }
.mw-sect-arrow::after { content: "▸"; }

.mw-sect-icon {
  width: 28px; height: 28px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.mw-sect-icon-green { background: var(--teal-100); color: var(--teal-700); }
.mw-sect-icon-red   { background: var(--coral-50); color: var(--coral-900); }
.mw-sect-icon-teal  { background: var(--teal-700); color: var(--white); }
.mw-sect-icon-gray  { background: var(--gray-50);  color: var(--text-2); }

.mw-sect-t    { font-weight: 600; font-size: 14px; line-height: 1.2; }
.mw-sect-meta { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.mw-required-badge {
  background: var(--coral-50); color: var(--coral-900);
  font-size: 10px; padding: 2px 8px; border-radius: 20px; font-weight: 600;
}

.mw-csvtag {
  background: var(--gray-50); color: var(--text-2);
  padding: 2px 7px; border-radius: 4px;
  font-size: 11px; font-family: 'Menlo', 'Monaco', monospace;
  border: 1px solid var(--border);
}

.mw-optrow { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.mw-optrow.is-correct { background: #F0FDF4; border-radius: 8px; padding: 8px 10px; }

.mw-letter {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--gray-50); color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; flex-shrink: 0;
  border: 1px solid var(--border);
}
.mw-letter-correct { background: var(--teal-700); color: #fff; border-color: var(--teal-700); }

.mw-wrongrow { padding: 10px 0; border-bottom: 1px dashed var(--border); }
.mw-wrongrow:last-child { border-bottom: none; }
.mw-wrongrow.is-disabled { opacity: 0.55; font-style: italic; padding: 12px 0; }
.mw-wrongopt-label { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }

.mw-subsect { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; }
.mw-subsect-head {
  display: flex; align-items: center; padding: 10px 14px;
  cursor: pointer; user-select: none; font-size: 13px;
  transition: background var(--ease);
}
.mw-subsect-head:hover { background: var(--gray-50); }
.mw-subsect-body { padding: 0 14px 14px; display: none; }
.mw-subsect.is-open .mw-subsect-body { display: block; }
.mw-subsect.is-open .mw-sect-arrow::after { content: "▾"; }

/* ── CSV schema ───────────────────────────────────────────── */
.mw-csvrow { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; font-size: 12px; align-items: center; }
.mw-csvrow > span:last-child { color: var(--text-3); font-size: 11px; }
.mw-csvsep {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-3); margin: 10px 0 4px;
  padding-top: 8px; border-top: 1px dashed var(--border);
}

/* ============================================================
   ANALYTICS
   ============================================================ */
.mw-scatter { width: 100%; height: 320px; }
.mw-legend { display: flex; gap: 16px; font-size: 11px; color: var(--text-2); margin-top: 10px; flex-wrap: wrap; }
.mw-legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }

.mw-distbar { display: grid; grid-template-columns: 180px 1fr 42px; gap: 10px; align-items: center; padding: 4px 0; font-size: 12px; }
.mw-distlbl { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mw-disttrack { background: var(--border); border-radius: 4px; height: 8px; overflow: hidden; }
.mw-distfill  { height: 100%; border-radius: 4px; }
.mw-distpct   { text-align: right; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ── AI Review ────────────────────────────────────────────── */
.mw-finding { padding: 12px 0; border-bottom: 1px dashed var(--border); }
.mw-finding:last-child { border: none; }
.mw-finding-row { display: flex; gap: 12px; align-items: flex-start; }

/* ============================================================
   PREVIEW MODE
   ============================================================ */
.mw-preview-bar {
  background: var(--teal-900); color: #fff;
  padding: 12px 22px;
  display: flex; justify-content: space-between; align-items: center;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.mw-preview-body {
  background: var(--white);
  padding: 24px 26px;
  border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.mw-prev-opt {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 18px; margin-bottom: 8px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--white); font-size: 14px; cursor: pointer;
  transition: all var(--ease);
}
.mw-prev-opt:hover { border-color: var(--border-2); background: var(--gray-50); }
.mw-prev-opt.is-correct   { background: #F0FDF4; border-color: #86EFAC; color: #065F46; font-weight: 500; }
.mw-prev-opt.is-incorrect { background: var(--coral-50); border-color: #FECACA; color: var(--coral-900); }

/* ============================================================
   EMPTY STATES
   ============================================================ */
.mw-empty {
  background: var(--gray-50);
  border: 1.5px dashed var(--border-2);
  border-radius: var(--radius-lg);
  padding: 44px 24px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}
.mw-empty-icon { font-size: 30px; margin-bottom: 12px; opacity: 0.55; }

/* ============================================================
   HELPERS
   ============================================================ */
.mw-link-inline { color: var(--teal-700); cursor: pointer; text-decoration: none; font-weight: 500; }
.mw-link-inline:hover { text-decoration: underline; }
.mw-mono { font-family: 'Menlo', 'Monaco', 'Courier New', monospace; font-size: 12px; }
.mw-center  { text-align: center; }
.mw-text-muted { color: var(--text-2); }
.mw-text-sm    { font-size: 12px; }
.mw-nowrap     { white-space: nowrap; }

/* ── Dev note ─────────────────────────────────────────────── */
.mw-devnote {
  background: #FFFBEB;
  border: 1px solid #FDE68A; border-left: 4px solid #F59E0B;
  border-radius: var(--radius); padding: 10px 16px;
  margin-bottom: 16px; font-size: 12.5px; color: #92400E;
}
.mw-devnote strong { font-weight: 600; color: #1A202C; }

.mw-inline-form { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.mw-import-raw {
  white-space: pre-wrap; word-break: break-word;
  font-family: 'Menlo', 'Monaco', monospace; font-size: 12px;
  color: var(--text-1); background: transparent;
}

/* ============================================================
   WIZARD STEPPER
   ============================================================ */
.mw-wizard { display: flex; align-items: center; margin-bottom: 24px; }
.mw-wizard-step { display: flex; flex-direction: column; align-items: center; gap: 5px; flex-shrink: 0; }
.mw-wizard-circle {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid var(--border); background: var(--white);
  color: var(--text-3); font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-xs);
}
.mw-wizard-step.is-active .mw-wizard-circle { border-color: var(--teal-700); color: var(--teal-700); background: var(--teal-50); }
.mw-wizard-step.is-done   .mw-wizard-circle { border-color: var(--teal-700); background: var(--teal-700); color: #fff; }
.mw-wizard-label { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.mw-wizard-step.is-active .mw-wizard-label { color: var(--teal-700); font-weight: 500; }
.mw-wizard-step.is-done   .mw-wizard-label { color: var(--text-2); }
.mw-wizard-line { flex: 1; height: 2px; background: var(--border); margin: 0 8px; margin-bottom: 20px; }
.mw-wizard-line.is-done { background: var(--teal-700); }

/* ============================================================
   PAGINATION
   ============================================================ */
.mw-pagination { margin-top: 20px; }
.mw-pag-nav {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; padding: 14px 0;
  border-top: 1px solid var(--border);
}
.mw-pag-info { font-size: 12px; color: var(--text-2); }
.mw-pag-info strong { color: var(--text-1); font-weight: 600; }
.mw-pag-pages { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.mw-pag-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 10px;
  font-size: 13px; font-weight: 500;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--white); color: var(--text-2);
  text-decoration: none; cursor: pointer;
  transition: all var(--ease); user-select: none;
  box-shadow: var(--shadow-xs);
}
.mw-pag-btn:hover { background: var(--teal-50); border-color: var(--teal-200); color: var(--teal-800); }
.mw-pag-current { background: var(--teal-700); border-color: var(--teal-700); color: #fff !important; cursor: default; box-shadow: none; }
.mw-pag-current:hover { background: var(--teal-700); border-color: var(--teal-700); }
.mw-pag-disabled { opacity: 0.35; cursor: default; pointer-events: none; }
.mw-pag-dots { border-color: transparent; background: transparent; color: var(--text-3); cursor: default; min-width: 24px; box-shadow: none; }
.mw-pag-dots:hover { background: transparent; border-color: transparent; color: var(--text-3); }

/* ============================================================
   QUILL EDITOR
   ============================================================ */
.mw-quill-wrap .ql-toolbar.ql-snow {
  border-color: var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--gray-50);
}
.mw-quill-wrap .ql-container.ql-snow {
  border-color: var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
}
.mw-quill-wrap .ql-editor { min-height: 320px; font-size: 14px; line-height: 1.7; }

/* ============================================================
   GLOBAL TOAST
   ============================================================ */
#mwToastEl {
  font-family: 'Inter', sans-serif !important;
  border-radius: var(--radius-md) !important;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
  .mw-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .mw-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .mw-th, .mw-listrow, .mw-qhead { min-width: 860px; }
}

/* Covers standard tablet widths (iPad portrait is 768px) as well as phones —
   the old 760px cutoff missed 768px by 8px, so tablets got the fixed-width
   two-column desktop grid squeezed into a too-narrow content pane instead of
   the intended single-column stacked layout. */
@media (max-width: 880px) {
  .mw-shell  { display: block; }
  .mw-side   { width: 100%; height: auto; max-height: 60vh; overflow-y: auto; position: relative; z-index: 10; }
  .mw-main   { padding: 18px 16px 52px; }
  .mw-row-between { align-items: flex-start; gap: 12px; flex-direction: column; }
  .mw-grid, .mw-grid-2, .mw-grid-3, .mw-grid-4 { grid-template-columns: 1fr !important; }
  .mw-actions { flex-wrap: wrap; }
  .mw-topbar  { flex-direction: column; align-items: flex-start; gap: 10px; }
  .mw-steps   { grid-template-columns: 1fr 1fr; }
  h1.mw-h1   { font-size: 19px; }
}
