/* ==========================================================================
   Neomedis — administration (2026)
   Tokens, shell (sidebar + topbar), components, forms, tables, dialogs.
   No framework. Dense dashboard scale (4px grid), brand blue / orange.
   ========================================================================== */

:root {
  --np-blue: #0c2174;
  --np-blue-700: #091a5c;
  --np-blue-600: #15308f;
  --np-blue-100: #dfe5f7;
  --np-blue-50: #eef1fb;
  --np-orange: #ff6f19;
  --np-orange-600: #e55f0f;
  --np-orange-50: #fff3eb;

  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #0f172a;
  --text: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --hover: #f8fafc;

  --success: #15803d; --success-bg: #ecfdf3; --success-line: #bbf7d0;
  --warn: #b45309; --warn-bg: #fffbeb; --warn-line: #fde68a;
  --danger: #b91c1c; --danger-bg: #fef2f2; --danger-line: #fecaca;
  --info: #1d4ed8; --info-bg: #eff6ff; --info-line: #bfdbfe;

  --font: "Figtree", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 4px 16px -4px rgba(15, 23, 42, .12);
  --shadow-lg: 0 24px 60px -20px rgba(15, 23, 42, .35);
  --ring: 0 0 0 3px rgba(12, 33, 116, .18);

  --sidebar-w: 264px;
  --sidebar-w-collapsed: 72px;
  --topbar-h: 60px;
  --content-max: 1440px;
  --speed: 160ms;
  --ease: cubic-bezier(.2, .7, .3, 1);

  /* Legacy aliases (older templates) */
  --navy: var(--np-blue); --blue: var(--np-blue); --blue-dark: var(--np-blue-700); --ocean: var(--np-blue-600); --aqua: var(--np-orange);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 14.5px/1.55 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--np-blue); }
a:hover { color: var(--np-orange-600); }
h1, h2, h3, h4 { color: var(--ink); line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; font-weight: 800; }
h2 { font-size: 1.05rem; font-weight: 700; }
h3 { font-size: .95rem; font-weight: 700; margin-top: 1.4em; }
p { margin: 0 0 .9em; }
code { font-family: var(--mono); font-size: .84em; background: #eef2f6; padding: 1px 6px; border-radius: 5px; color: var(--ink); }
pre.log { font-family: var(--mono); font-size: .8rem; background: #0f172a; color: #e2e8f0; padding: 12px 14px; border-radius: var(--radius-sm); overflow: auto; margin: 14px 0 0; }
kbd { font: 600 .7rem/1 var(--font); color: var(--muted); background: #fff; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; padding: 3px 5px; }
img, svg { max-width: 100%; }
.icon { width: 18px; height: 18px; flex: none; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 22px; height: 22px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 1.4em; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 200; background: var(--np-blue); color: #fff; padding: 10px 14px; border-radius: 8px; }
.skip-link:focus { top: 12px; }
:focus-visible { outline: 2px solid var(--np-orange); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--np-blue-100); }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  display: flex; flex-direction: column; gap: 6px;
  background: linear-gradient(180deg, var(--np-blue) 0%, var(--np-blue-700) 100%); color: #c7cfe8;
  padding: 14px 12px 14px; transition: width var(--speed) var(--ease), transform var(--speed) var(--ease);
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; min-width: 0; }
.brand .logo img { height: 36px; width: auto; display: block; }
.brand-tag { font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .14em; background: var(--np-orange); color: #fff; padding: 3px 7px; border-radius: 6px; }
.sidebar-close { display: none; color: #fff; }
.search-trigger {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; margin: 4px 0 8px;
  border: 1px solid rgba(255,255,255,.14); border-radius: 10px; background: rgba(255,255,255,.07); color: #dfe4f5;
  font: inherit; font-size: .88rem; cursor: pointer; text-align: left; transition: background var(--speed);
}
.search-trigger:hover { background: rgba(255,255,255,.12); color: #fff; }
.search-trigger span { flex: 1; }
.search-trigger kbd { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.2); color: #c7cfe8; }
.nav { flex: 1; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent; padding-bottom: 8px; }
.nav-group + .nav-group { margin-top: 10px; }
.nav-heading { font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .14em; color: #8d9bcf; margin: 10px 12px 4px; }
.nav-link {
  display: flex; align-items: center; gap: 11px; padding: 8px 12px; border-radius: 9px; margin-bottom: 2px;
  color: #d9dff2; text-decoration: none; font-weight: 500; font-size: .92rem; line-height: 1.3; position: relative;
  transition: background var(--speed), color var(--speed);
}
.nav-link .icon { opacity: .85; }
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.is-active { background: rgba(255,255,255,.14); color: #fff; font-weight: 650; }
.nav-link.is-active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--np-orange); }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-badge { background: var(--np-orange); color: #fff; font-size: .7rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; min-width: 20px; text-align: center; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.1); padding-top: 8px; }
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 39; }
.sidebar-backdrop[hidden] { display: none; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; transition: margin var(--speed) var(--ease); }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px; padding: 0 24px;
  background: rgba(255,255,255,.9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.topbar-spacer { flex: 1; }
.topbar-search {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--muted); font: inherit; font-size: .88rem; cursor: pointer; min-width: 260px; text-align: left; transition: border-color var(--speed), box-shadow var(--speed);
}
.topbar-search span { flex: 1; }
.topbar-search:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.topbar-site .icon { width: 16px; height: 16px; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--text); cursor: pointer; transition: background var(--speed), color var(--speed); }
.icon-btn:hover { background: var(--np-blue-50); color: var(--np-blue); }
.icon-btn .icon { width: 20px; height: 20px; }
[data-sidebar-toggle] { display: none; }

.content { padding: 28px 28px 60px; max-width: var(--content-max); width: 100%; }
.content:focus { outline: none; }

/* Collapsed sidebar (desktop) */
@media (min-width: 1025px) {
  body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); padding-inline: 10px; }
  body.sidebar-collapsed .main { margin-left: var(--sidebar-w-collapsed); }
  body.sidebar-collapsed .brand-tag, body.sidebar-collapsed .nav-label, body.sidebar-collapsed .nav-heading, body.sidebar-collapsed .search-trigger span, body.sidebar-collapsed .search-trigger kbd { display: none; }
  body.sidebar-collapsed .brand .logo img { height: 30px; }
  body.sidebar-collapsed .nav-link { justify-content: center; padding-inline: 0; }
  body.sidebar-collapsed .nav-link.is-active::before { left: -10px; }
  body.sidebar-collapsed .nav-badge { position: absolute; top: 2px; right: 4px; padding: 0 5px; font-size: .62rem; }
  body.sidebar-collapsed .search-trigger { justify-content: center; }
  body.sidebar-collapsed .topbar-collapse .icon { transform: rotate(180deg); }
}

/* Mobile */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; width: min(300px, 86vw); }
  .sidebar.is-open { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar-close { display: inline-grid; }
  .main { margin-left: 0; }
  [data-sidebar-toggle] { display: inline-grid; }
  .topbar-collapse { display: none; }
  .topbar { padding: 0 14px; }
  .topbar-search { min-width: 0; }
  .topbar-search span, .topbar-search kbd { display: none; }
  .topbar-site span { display: none; }
  .content { padding: 18px 16px 48px; }
}

/* User dropdown */
.dropdown { position: relative; }
.user-btn { display: inline-flex; align-items: center; gap: 10px; padding: 4px 6px 4px 4px; border: 1px solid transparent; border-radius: 12px; background: transparent; font: inherit; cursor: pointer; color: var(--ink); transition: background var(--speed); }
.user-btn:hover, .dropdown.is-open .user-btn { background: var(--np-blue-50); }
.avatar { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--np-blue), var(--np-blue-600)); color: #fff; font-weight: 800; font-size: .95rem; }
.user-meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; text-align: left; }
.user-name { font-weight: 650; font-size: .9rem; }
.user-role { font-size: .74rem; color: var(--muted); }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; display: none; z-index: 50; }
.dropdown.is-open .dropdown-menu { display: block; animation: pop var(--speed) var(--ease); }
.dropdown-menu a, .dropdown-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; text-decoration: none; cursor: pointer; text-align: left; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--hover); color: var(--np-blue); }
.dropdown-menu form { margin: 0; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
.dropdown-menu .icon { width: 16px; height: 16px; color: var(--muted); }
@media (max-width: 600px) { .user-meta { display: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---------- Page head & breadcrumbs ---------- */
.page-head { display: flex; flex-wrap: wrap; gap: 14px 20px; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; }
.page-head h1 { margin-bottom: .15em; }
.page-head p { margin: 0; }
.page-head .btn-row, .page-head > .btn { align-self: center; }
.crumb { margin: 0 0 6px; font-size: .82rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--np-blue); }
.crumb .icon { width: 14px; height: 14px; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; box-shadow: var(--shadow-sm); }
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.card-flush .card-head { padding: 16px 20px 0; }
.card > h2:first-child { margin-bottom: 14px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr)); gap: 18px; align-items: start; }
.cols-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.tile { text-decoration: none; display: flex; flex-direction: column; gap: 6px; transition: transform var(--speed), box-shadow var(--speed), border-color var(--speed); }
.tile h2 { margin: 0; font-size: 1rem; }
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--np-blue-100); }
.tile-icon { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--np-blue-50); color: var(--np-blue); margin-bottom: 6px; }
.tile-meta { font-size: .82rem; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; min-height: 38px;
  border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: .9rem; line-height: 1.2;
  text-decoration: none; cursor: pointer; white-space: nowrap; transition: background var(--speed), color var(--speed), border-color var(--speed), box-shadow var(--speed), transform var(--speed);
}
.btn .icon { width: 16px; height: 16px; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--np-blue); color: #fff; box-shadow: 0 6px 14px -8px rgba(12,33,116,.8); }
.btn-primary:hover { background: var(--np-blue-600); color: #fff; }
.btn-accent { background: var(--np-orange); color: #fff; box-shadow: 0 6px 14px -8px rgba(255,111,25,.8); }
.btn-accent:hover { background: var(--np-orange-600); color: #fff; }
.btn-ghost { background: #fff; border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { border-color: var(--np-blue); color: var(--np-blue); background: var(--np-blue-50); }
.btn-subtle { background: transparent; color: var(--text); }
.btn-subtle:hover { background: var(--np-blue-50); color: var(--np-blue); }
.btn-danger { background: #fff; border-color: var(--danger-line); color: var(--danger); }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: 6px 11px; min-height: 32px; font-size: .84rem; border-radius: 8px; }
.btn-lg { padding: 12px 20px; min-height: 46px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn[disabled], .btn.is-loading { opacity: .6; pointer-events: none; }
.btn.is-loading::before { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.link-danger { background: none; border: 0; color: var(--danger); cursor: pointer; font: inherit; font-size: .84rem; padding: 0; }
.link-danger:hover { text-decoration: underline; }
.icon-link { color: var(--muted); display: inline-flex; }
.icon-link:hover { color: var(--np-blue); }

/* ---------- Alerts, toasts, badges ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; border: 1px solid; }
.alert .icon { flex: none; margin-top: 1px; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: var(--success-line); }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-line); }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.alert-info, .notice { background: var(--info-bg); color: var(--info); border: 1px solid var(--info-line); border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; font-size: .9rem; }
.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 40px)); }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px; border-radius: 12px; background: #0f172a; color: #fff; box-shadow: var(--shadow-lg); font-weight: 500; animation: toast-in .25s var(--ease); }
.toast .icon { flex: none; }
.toast span { flex: 1; }
.toast-success .icon { color: #4ade80; }
.toast-error .icon { color: #f87171; }
.toast-warn .icon { color: #fbbf24; }
.toast button { background: none; border: 0; color: #94a3b8; cursor: pointer; padding: 4px; border-radius: 6px; display: grid; }
.toast button:hover { color: #fff; background: rgba(255,255,255,.1); }
.toast.is-leaving { animation: toast-out .2s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); margin: 0; }
.empty-state { text-align: center; padding: 40px 20px; }
.empty-state .icon { width: 40px; height: 40px; color: var(--line-strong); }
.empty-state h2 { margin: 10px 0 4px; }
.status, .badge { display: inline-flex; align-items: center; gap: 5px; font-size: .74rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: #eef2f6; color: var(--muted); white-space: nowrap; line-height: 1.3; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.status-published, .status-won, .badge-ok { background: var(--success-bg); color: var(--success); }
.status-draft, .status-lost { background: #f1f5f9; color: #64748b; }
.status-new, .badge-warn { background: var(--np-orange-50); color: var(--np-orange-600); }
.status-qualified, .status-contacted, .badge-info { background: var(--info-bg); color: var(--info); }
.status-samples_sent, .status-quote_sent, .status-negotiation { background: #f5f3ff; color: #6d28d9; }
.tag { display: inline-block; font-size: .74rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); margin-left: 4px; color: var(--text); }
.tag-warn { border-color: var(--warn-line); background: var(--warn-bg); color: var(--warn); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 11px 16px; border-bottom: 1px solid var(--line); background: #fafbfd; white-space: nowrap; }
.table td { padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--speed); }
.table tbody tr:hover td { background: var(--hover); }
.table tr.is-new td:first-child { box-shadow: inset 3px 0 0 var(--np-orange); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table a { text-decoration: none; }
.table a:hover { text-decoration: underline; }
.row-title { font-weight: 650; color: var(--ink); }
.row-title:hover { color: var(--np-blue); }
.actions-col { width: 44px; text-align: right; }
.good { color: var(--success); font-weight: 600; }
.warn { color: var(--warn); font-weight: 600; }
.bad { color: var(--danger); font-weight: 700; }
.issues { margin: 0; padding-left: 16px; font-size: .82rem; color: var(--warn); }
.th-sort { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.th-sort .icon { width: 12px; height: 12px; opacity: .5; }
.th-sort.is-active { color: var(--np-blue); }
.th-sort.is-active .icon { opacity: 1; }

/* Toolbar, pager, pipeline */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.toolbar input[type="search"] { flex: 1 1 240px; }
.toolbar input, .toolbar select { width: auto; min-height: 38px; }
.toolbar .btn { min-height: 38px; }
.pager, .pipeline { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0; }
.pager a, .pipeline a { padding: 7px 12px; border: 1px solid var(--line); background: #fff; border-radius: 9px; text-decoration: none; color: var(--text); font-size: .86rem; font-weight: 600; transition: border-color var(--speed), background var(--speed); }
.pager a:hover, .pipeline a:hover { border-color: var(--np-blue); color: var(--np-blue); }
.pipeline a span { color: var(--muted); font-weight: 500; margin-left: 5px; }
.pager a[aria-current="page"], .pipeline a[aria-current="page"] { background: var(--np-blue); color: #fff; border-color: var(--np-blue); }
.pipeline a[aria-current="page"] span { color: #c7cfe8; }
.pipeline { margin-top: 0; }

/* ---------- Stats & dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 16px; text-decoration: none; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow-sm); transition: border-color var(--speed), transform var(--speed), box-shadow var(--speed); overflow: hidden; }
.stat::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--np-blue-100); }
.stat-accent::after { background: var(--np-orange); }
a.stat:hover { border-color: var(--np-blue-100); transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-icon { position: absolute; right: 14px; top: 14px; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--np-blue-50); color: var(--np-blue); }
.stat-accent .stat-icon { background: var(--np-orange-50); color: var(--np-orange); }
.stat-value { font-size: 1.9rem; font-weight: 800; color: var(--ink); line-height: 1.1; letter-spacing: -.02em; }
.stat-label { color: var(--muted); font-size: .84rem; font-weight: 500; }
.bars, .kv, .health, .plain { list-style: none; margin: 0; padding: 0; }
.bars li { display: grid; grid-template-columns: 120px 1fr 36px; gap: 10px; align-items: center; padding: 5px 0; font-size: .88rem; }
.bar { height: 8px; background: #eef2f6; border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--np-blue-600), var(--np-blue)); border-radius: 99px; }
.bars strong, .kv strong { text-align: right; color: var(--ink); }
.kv li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.kv li:last-child { border-bottom: 0; }
.health li { padding: 11px 12px 11px 38px; border-radius: 9px; position: relative; margin-bottom: 6px; background: var(--hover); font-size: .9rem; }
.health li::before { content: ""; position: absolute; left: 14px; top: 18px; width: 10px; height: 10px; border-radius: 50%; }
.health li.ok::before { background: var(--success); }
.health li.warn::before { background: #f59e0b; }
.health li.info::before { background: var(--np-blue-600); }
.health a { margin-left: 6px; font-size: .86rem; }
.plain li { display: flex; gap: 6px; align-items: center; padding: 4px 0; }
.welcome { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.welcome h1 { margin: 0 0 2px; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Forms ---------- */
.edit-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
@media (max-width: 1100px) { .edit-layout { grid-template-columns: 1fr; } }
.sticky { position: sticky; top: calc(var(--topbar-h) + 16px); }
.sticky .btn + .btn, .sticky p + .btn { margin-top: 8px; }
.form-field { margin-bottom: 16px; display: block; }
.form-field > label, .form-field > span, .form-field legend, .field > span { display: block; font-weight: 600; color: var(--ink); margin-bottom: 6px; font-size: .88rem; padding: 0; }
.form-field fieldset { border: 0; padding: 0; margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 0 18px; }
.req { color: var(--danger); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], input[type="url"], input[type="tel"], input[type="datetime-local"], input[type="date"], input[type="file"], select, textarea {
  width: 100%; padding: 9px 12px; min-height: 40px; font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: 9px;
  transition: border-color var(--speed), box-shadow var(--speed);
}
input::placeholder, textarea::placeholder { color: #94a3b8; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.6' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
textarea { resize: vertical; min-height: 96px; }
textarea.mono { font-family: var(--mono); font-size: .84rem; line-height: 1.55; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--np-blue); box-shadow: var(--ring); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.help { font-size: .8rem; color: var(--muted); margin: 5px 0 0; }
.error-text { font-size: .82rem; color: var(--danger); font-weight: 600; margin: 5px 0 0; display: flex; align-items: center; gap: 4px; }
.check { display: inline-flex; align-items: center; gap: 9px; font-weight: 500; color: var(--ink); cursor: pointer; min-height: 32px; }
.check input { width: 17px; height: 17px; accent-color: var(--np-blue); margin: 0; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 2px 16px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; color: var(--ink); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 38px; height: 22px; border-radius: 999px; background: var(--line-strong); position: relative; transition: background var(--speed); flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--speed); }
.switch input:checked + .track { background: var(--np-blue); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: var(--ring); }
.color-field { display: flex; gap: 8px; align-items: center; }
.color-field input[type="color"] { width: 44px; height: 40px; padding: 3px; border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; cursor: pointer; }
.color-field input[type="text"] { max-width: 140px; font-family: var(--mono); }
.counter { float: right; font-size: .74rem; font-weight: 600; color: var(--muted); }
.counter.over { color: var(--danger); }
.stack > * + * { margin-top: 12px; }
.stack .form-field { margin-bottom: 0; }
.danger-zone { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 8px; padding: 14px 16px; border: 1px dashed var(--danger-line); border-radius: var(--radius); background: #fff; }
.danger-zone p { margin: 0; font-size: .86rem; color: var(--muted); flex: 1; }
.upload-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 14px; align-items: end; }
.upload-form .form-field { margin: 0; }
@media (max-width: 800px) { .upload-form { grid-template-columns: 1fr; } }
.input-code { font-size: 1.4rem; letter-spacing: .3em; text-align: center; font-family: var(--mono); }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs button, .tabs a { padding: 10px 14px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; color: var(--muted); font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; white-space: nowrap; text-decoration: none; transition: color var(--speed), border-color var(--speed); }
.tabs button:hover, .tabs a:hover { color: var(--ink); }
.tabs [aria-selected="true"], .tabs .is-active { color: var(--np-blue); border-bottom-color: var(--np-orange); }
.tab-panel[hidden] { display: none; }

/* SERP preview */
.serp { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 18px; background: #fff; font-family: Arial, sans-serif; }
.serp-url { display: block; font-size: 13px; color: #4d5156; }
.serp-title { display: block; font-size: 19px; color: #1a0dab; margin: 3px 0; line-height: 1.3; }
.serp-desc { display: block; font-size: 14px; color: #4d5156; line-height: 1.45; }

/* Legacy rich text editor (replaced in phase 2) */
.editor { border: 1px solid var(--line-strong); border-radius: 9px; overflow: hidden; background: #fff; }
.editor:focus-within { border-color: var(--np-blue); box-shadow: var(--ring); }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); background: #fafbfd; }
.editor-toolbar button { background: none; border: 1px solid transparent; border-radius: 6px; padding: 4px 9px; font: 600 .8rem var(--font); color: var(--ink); cursor: pointer; }
.editor-toolbar button:hover, .editor-toolbar button.is-active { background: #fff; border-color: var(--line); }
.editor-area { min-height: 240px; max-height: 640px; overflow-y: auto; padding: 14px 18px; outline: none; }
.editor-area h2 { font-size: 1.25rem; margin-top: 1em; }
.editor-area h3 { font-size: 1.05rem; }
.editor-area table { border-collapse: collapse; }
.editor-area td, .editor-area th { border: 1px solid var(--line); padding: 4px 8px; }
.editor textarea { border: 0; border-radius: 0; min-height: 240px; font-family: var(--mono); font-size: .84rem; }

/* ---------- Media ---------- */
.media-field { display: flex; gap: 14px; align-items: center; }
.media-preview { width: 128px; height: 96px; border: 1px dashed var(--line-strong); border-radius: 9px; display: grid; place-items: center; overflow: hidden; background: var(--hover); font-size: .78rem; color: var(--muted); }
.media-preview img { width: 100%; height: 100%; object-fit: contain; }
.media-actions { display: flex; flex-direction: column; gap: 6px; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.media-item { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; transition: box-shadow var(--speed), border-color var(--speed); }
.media-item:hover { box-shadow: var(--shadow); border-color: var(--np-blue-100); }
.media-item img { width: 100%; height: 150px; object-fit: contain; background: var(--hover); border-radius: 8px; }
.media-item p { margin: 8px 0 6px; }
.inline-form { display: flex; gap: 6px; margin-bottom: 6px; }
.inline-form input { min-height: 34px; padding: 6px 10px; font-size: .86rem; }
.inline-form input.is-missing { border-color: #f59e0b; background: var(--warn-bg); }
.media-dialog { width: min(960px, 94vw); max-height: 86vh; border: 0; border-radius: 16px; padding: 0; box-shadow: var(--shadow-lg); }
.media-dialog-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
.media-dialog-head h2 { margin: 0 auto 0 0; }
.media-dialog-status { margin: 10px 18px 0; font-size: .86rem; color: var(--muted); }
.media-grid-picker { padding: 16px 18px 20px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.media-grid-picker button { background: var(--hover); border: 2px solid transparent; border-radius: 10px; padding: 6px; cursor: pointer; text-align: left; font: inherit; font-size: .74rem; color: var(--muted); }
.media-grid-picker button:hover, .media-grid-picker button:focus { border-color: var(--np-blue); }
.media-grid-picker img { width: 100%; height: 100px; object-fit: contain; }
.upload-btn { cursor: pointer; }

/* ---------- Dialogs ---------- */
dialog { color: var(--text); font: inherit; }
dialog::backdrop { background: rgba(15, 23, 42, .55); backdrop-filter: blur(2px); }
.modal { width: min(560px, 94vw); border: 0; border-radius: 16px; padding: 24px; box-shadow: var(--shadow-lg); }
.modal-sm { width: min(440px, 94vw); }
.modal h2 { margin-bottom: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.palette { width: min(640px, 94vw); border: 0; border-radius: 16px; padding: 0; box-shadow: var(--shadow-lg); margin-top: 10vh; overflow: hidden; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.palette-input .icon { color: var(--muted); }
.palette-input input { border: 0; box-shadow: none; font-size: 1.02rem; padding: 10px 0; min-height: 44px; }
.palette-input input:focus { box-shadow: none; }
.palette-results { max-height: min(60vh, 460px); overflow-y: auto; padding: 8px; }
.palette-group { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); padding: 10px 10px 4px; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 9px; text-decoration: none; color: var(--text); cursor: pointer; }
.palette-item .icon { color: var(--muted); width: 18px; height: 18px; }
.palette-item strong { color: var(--ink); font-weight: 600; display: block; line-height: 1.2; }
.palette-item small { color: var(--muted); display: block; }
.palette-item.is-active, .palette-item:hover { background: var(--np-blue-50); color: var(--np-blue); }
.palette-item.is-active .icon { color: var(--np-blue); }
.palette-empty { padding: 28px; text-align: center; color: var(--muted); }
.palette-foot { display: flex; gap: 16px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: .76rem; color: var(--muted); background: #fafbfd; }
.palette-foot kbd { margin-right: 3px; }

/* ---------- Lead detail & misc ---------- */
.details { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 24px; }
.details div { padding: 9px 0; border-bottom: 1px solid var(--line); }
.details dt { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.details dd { margin: 2px 0 0; font-weight: 600; color: var(--ink); word-break: break-word; }
.details-compact { grid-template-columns: 1fr; }
.message { background: var(--hover); border-radius: 10px; padding: 14px; white-space: normal; border: 1px solid var(--line); }
.timeline { list-style: none; margin: 16px 0 0; padding: 0; }
.timeline li { border-left: 2px solid var(--line); padding: 2px 0 14px 14px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid var(--np-blue-100); }
.timeline p { margin: 0 0 2px; }
.steps { padding-left: 18px; }
.steps li { margin-bottom: 10px; }
.secret { display: inline-block; margin-top: 6px; font-size: 1rem; letter-spacing: .08em; padding: 6px 10px; }

/* ---------- Auth ---------- */
body.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(800px 500px at 85% -10%, rgba(255,111,25,.22), transparent 60%), radial-gradient(700px 500px at -10% 110%, rgba(21,48,143,.5), transparent 60%), linear-gradient(135deg, #0c2174 0%, #0b1a55 60%, #081243 100%); }
.auth-wrap { width: min(440px, 100%); }
.auth-card { background: #fff; border-radius: 18px; padding: 36px 34px 30px; box-shadow: var(--shadow-lg); animation: pop .3s var(--ease); }
.auth-brand { margin-bottom: 22px; }
.auth-brand .logo img { height: 52px; width: auto; display: block; }
.auth-card h1 { font-size: 1.45rem; margin-bottom: .2em; }
.auth-intro { color: var(--muted); margin-bottom: 20px; }
.auth-note { display: flex; gap: 8px; align-items: flex-start; font-size: .78rem; color: var(--muted); margin: 20px 0 0; }
.auth-foot { text-align: center; color: rgba(255,255,255,.6); font-size: .8rem; margin: 18px 0 0; }
.auth-links { margin: 16px 0 0; font-size: .88rem; text-align: center; }
.auth-links a { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; font-weight: 600; }
.auth-links a:hover { text-decoration: underline; }
.pw-field { position: relative; display: block; }
.pw-field input { padding-right: 44px; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.pw-toggle:hover { color: var(--np-blue); background: var(--np-blue-50); }
.error-code { font-size: 3rem; font-weight: 800; color: var(--np-orange); line-height: 1; margin: 0 0 6px; letter-spacing: -.03em; }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Small screens ---------- */
@media (max-width: 600px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 1.5rem; }
  .stat-icon { display: none; }
  .page-head .btn { width: 100%; }
  .table td, .table th { padding: 9px 10px; }
  .card { padding: 16px; }
  .toast-stack { right: 10px; left: 10px; bottom: 10px; max-width: none; }
}

/* ---------- Page builder ---------- */
.blocks { display: flex; flex-direction: column; gap: 10px; }
.block { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); transition: box-shadow var(--speed), border-color var(--speed), opacity var(--speed); }
.block.is-open { border-color: var(--np-blue-100); box-shadow: var(--shadow); }
.block.is-disabled { opacity: .55; }
.block.is-disabled .block-type::after { content: " · masqué"; color: var(--np-orange-600); font-weight: 600; }
.block.has-errors { border-color: var(--danger-line); }
.block.is-dragging { opacity: .4; border-style: dashed; }
.block.is-moved { box-shadow: 0 0 0 3px rgba(255,111,25,.35); }
.block-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px 8px 6px; }
.block-grip, .repeater-grip { cursor: grab; color: var(--line-strong); }
.block-grip:hover, .repeater-grip:hover { color: var(--np-blue); background: transparent; }
.block-toggle { flex: 1; display: flex; align-items: center; gap: 12px; min-width: 0; padding: 6px 8px; border: 0; border-radius: 10px; background: none; font: inherit; text-align: left; cursor: pointer; color: var(--ink); }
.block-toggle:hover { background: var(--hover); }
.block-icon { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--np-blue-50); color: var(--np-blue); flex: none; }
.block-titles { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.block-type { font-weight: 700; font-size: .92rem; }
.block-summary { color: var(--muted); font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.block-toggle .chev { margin-left: auto; color: var(--muted); transition: transform var(--speed); }
.block.is-open .block-toggle .chev { transform: rotate(180deg); }
.block-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.block-actions .icon-btn { width: 32px; height: 32px; }
.icon-btn-danger:hover { background: var(--danger-bg); color: var(--danger); }
.block-body { padding: 4px 18px 18px; border-top: 1px solid var(--line); }
.block-description { margin: 12px 0 14px; }
.blocks-add { display: flex; justify-content: center; padding: 18px 0 4px; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.rot-90 { transform: rotate(90deg); }
.switch-sm .track { width: 32px; height: 18px; }
.switch-sm .track::after { width: 12px; height: 12px; }
.switch-sm input:checked + .track::after { transform: translateX(14px); }

/* Fields */
.field-label { display: block; font-weight: 600; color: var(--ink); margin-bottom: 6px; font-size: .88rem; }
.link-field { display: grid; grid-template-columns: 1.2fr 1.4fr auto; gap: 8px; }
.link-field input.mono { font-family: var(--mono); font-size: .86rem; }
@media (max-width: 700px) { .link-field { grid-template-columns: 1fr; } }
.icon-field { display: flex; align-items: center; gap: 10px; }
.icon-field select { flex: 1; }
.icon-field-preview { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 9px; background: var(--hover); color: var(--np-blue); flex: none; }
.icon-field-preview .icon { width: 20px; height: 20px; }
.check-grid-compact { gap: 0 12px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.check-grid-compact .check { min-height: 28px; font-size: .88rem; }
.field-richtext textarea { min-height: 200px; }
.tox-tinymce { border-radius: 9px !important; border-color: var(--line-strong) !important; }

/* Repeaters */
.repeater-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.repeater-row { border: 1px solid var(--line); border-radius: 10px; background: var(--hover); }
.repeater-row.is-dragging { opacity: .4; border-style: dashed; }
.repeater-row.is-moved { box-shadow: 0 0 0 3px rgba(255,111,25,.35); }
.repeater-head { display: flex; align-items: center; gap: 4px; padding: 4px 6px 4px 2px; }
.repeater-toggle { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; padding: 6px 8px; border: 0; background: none; font: inherit; font-weight: 600; font-size: .88rem; color: var(--ink); text-align: left; cursor: pointer; border-radius: 8px; }
.repeater-toggle:hover { background: #fff; }
.repeater-index { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 999px; background: var(--np-blue); color: #fff; font-size: .74rem; font-weight: 700; }
.repeater-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.repeater-toggle .chev { color: var(--muted); transition: transform var(--speed); }
.repeater-row:not(.is-collapsed) .repeater-toggle .chev { transform: rotate(180deg); }
.repeater-actions { display: flex; gap: 0; }
.repeater-actions .icon-btn { width: 30px; height: 30px; }
.repeater-body { padding: 4px 14px 12px; border-top: 1px solid var(--line); background: #fff; border-radius: 0 0 10px 10px; }
.repeater-body .form-field { margin-bottom: 12px; }
.repeater-body .form-field:last-child { margin-bottom: 0; }

/* Block palette */
.modal-lg { width: min(820px, 94vw); max-height: 86vh; overflow-y: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.modal-head h2 { margin: 0; }
.palette-blocks .palette-group { padding: 14px 0 6px; }
.block-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.block-choice { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font: inherit; text-align: left; cursor: pointer; transition: border-color var(--speed), box-shadow var(--speed), transform var(--speed); }
.block-choice:hover { border-color: var(--np-blue); box-shadow: var(--shadow); transform: translateY(-1px); }
.block-choice strong { display: block; color: var(--ink); font-size: .92rem; }
.block-choice small { color: var(--muted); display: block; line-height: 1.35; margin-top: 2px; }
.block-choice.is-loading { opacity: .5; pointer-events: none; }
.tabs .icon { width: 15px; height: 15px; margin-right: 6px; vertical-align: -2px; }

/* Toggle switches inside form fields keep their inline layout (the generic label rule made them block). */
.form-field > label.switch, .form-field .switch { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 0; font-size: .92rem; }
.switch .track { display: inline-block; flex: none; }
.field-toggle { padding: 4px 0; }

/* Nested repeaters (e.g. sub-menu entries inside a menu item) */
.repeater-body .field-repeater { margin-top: 6px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; background: var(--hover); }
.repeater-body .field-repeater .repeater-row { background: #fff; }
.repeater-body .field-repeater .repeater-body { background: var(--hover); }
