/* ===========================================================
   Hosting CMP — admin UI (Linear/Vercel/Resend style)
   =========================================================== */

:root {
  /* Surfaces — warmer near-white, less blue-grey */
  --bg:               #f7f7f6;
  --bg-elev:          #ffffff;
  --bg-sidebar:       #f2f2f1;
  --bg-subtle:        #f5f5f4;
  --bg-hover:         #f0f0ef;

  /* Borders — softer, less contrast */
  --border:           #ececec;
  --border-strong:    #d4d4d4;

  /* Text — neutral greys, not zinc-blue */
  --fg:               #0a0a0a;
  --fg-secondary:     #404040;
  --fg-muted:         #737373;
  --fg-faint:         #a3a3a3;

  /* Brand — single confident colour, no gradient noise.
     Use sparingly: primary CTA, active row, focus ring, brand mark. */
  --brand:            #0a0a0a;
  --brand-2:          #0a0a0a;
  --brand-600:        #171717;
  --brand-700:        #262626;
  --brand-50:         #f5f5f4;
  --brand-100:        #e5e5e5;
  --brand-grad:       #0a0a0a;
  /* Accent colour reserved for chart highlights, status, etc.
     Indigo kept here so we can use it surgically, never as the dominant brand. */
  --accent:           #4f46e5;
  --accent-50:        #eef2ff;

  /* Status — desaturated, more elegant */
  --success:          #059669;
  --success-bg:       #ecfdf5;
  --success-border:   #a7f3d0;
  --warning:          #d97706;
  --warning-bg:       #fffbeb;
  --warning-border:   #fde68a;
  --danger:           #dc2626;
  --danger-bg:        #fef2f2;
  --danger-border:    #fecaca;

  /* Categories — kept similar but slightly desaturated */
  --cat-necessary:    #047857;  --cat-necessary-bg: #ecfdf5;
  --cat-preferences:  #6d28d9;  --cat-preferences-bg:#f5f3ff;
  --cat-statistics:   #1d4ed8;  --cat-statistics-bg:#eff6ff;
  --cat-marketing:    #c2410c;  --cat-marketing-bg: #fff7ed;

  /* Radii — slightly tighter, more refined */
  --r-sm: 4px; --r-md: 6px; --r-lg: 8px; --r-xl: 8px; --r-2xl: 10px;

  /* Shadows — subtle, almost imperceptible */
  --shadow-xs: 0 1px 0 rgba(0, 0, 0, 0.03);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.05), 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.05), 0 12px 32px rgba(0, 0, 0, 0.06);
  --shadow-xl: 0 12px 32px rgba(0, 0, 0, 0.08), 0 24px 64px rgba(0, 0, 0, 0.10);
  --shadow-focus: 0 0 0 3px rgba(10, 10, 10, 0.10);
  --shadow-brand: 0 1px 2px rgba(0, 0, 0, 0.08);

  /* Layout */
  --sidebar-w: 232px;
  --topbar-h: 52px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* Reset + base ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100vh; overflow: hidden; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  font-size: 13px;
  line-height: 1.55;
  color: var(--fg);
  background: var(--bg);
  color-scheme: light;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; transition: color 120ms var(--ease); }
a:hover { color: var(--fg); }
code, pre, kbd { font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12px; }
/* Headings: quiet weight scale, no tracking tricks */
h1, h2, h3, h4 { letter-spacing: 0; font-weight: 600; color: var(--fg); margin: 0; }
h1 { font-size: 20px; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
h4 { font-size: 13px; font-weight: 500; }
[x-cloak] { display: none !important; }

/* Form controls inherit the system font automatically */
button, input, select, textarea { font-family: inherit; font-feature-settings: inherit; }

/* Subtle focus ring for all interactive controls (keyboard nav) */
:focus-visible { outline: none; box-shadow: var(--shadow-focus); border-radius: var(--r-md); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; box-shadow: var(--shadow-focus);
}

/* Smooth page entry */
.content > * { animation: cg-fade-in 280ms var(--ease-out) both; }
@keyframes cg-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* App shell --------------------------------------------------------------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);  /* minmax(0,1fr) prevents content from pushing grid wider than viewport */
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas: "sidebar topbar" "sidebar content";
  height: 100vh;
}

/* Sidebar ----------------------------------------------------------------- */
.sidebar {
  grid-area: sidebar;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: 100vh; position: sticky; top: 0;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 9px;
  padding: 0 18px;
  height: var(--topbar-h);
  font-weight: 600; font-size: 13.5px; color: var(--fg);
  letter-spacing: 0;
}
.sidebar-brand svg {
  background: var(--fg);
  border-radius: 6px;
  padding: 4px;
  color: var(--bg-elev);
  width: 24px; height: 24px;
  box-shadow: none;
}
.sidebar-nav { padding: 8px 8px; display: flex; flex-direction: column; gap: 1px; flex: 1; overflow-y: auto; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; border-radius: var(--r-md);
  color: var(--fg-secondary); font-weight: 500; font-size: 13px;
  transition: background 80ms var(--ease), color 80ms var(--ease);
  position: relative;
}
.sidebar-nav a:hover { background: var(--bg-hover); color: var(--fg); }
.sidebar-nav a.active {
  background: color-mix(in srgb, var(--bg-elev) 82%, var(--bg-subtle));
  color: var(--fg);
  box-shadow: 0 0 0 1px var(--border), 0 1px 2px rgba(0,0,0,0.04);
  font-weight: 600;
}
.sidebar-nav a svg { flex: 0 0 16px; color: var(--fg-faint); }
.sidebar-nav a:hover svg, .sidebar-nav a.active svg { color: var(--fg); }
.sidebar-footer {
  padding: 12px 18px;
  font-size: 11px; color: var(--fg-faint);
  display: flex; align-items: center; gap: 8px;
}
.sidebar-footer::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--success);
  box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.14);
}

/* Topbar — clean white, no blur. Less chrome, more confident. */
.topbar {
  grid-area: topbar;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 30;
}
.topbar .crumbs { color: var(--fg-muted); font-size: 13px; flex: 1; font-weight: 500; }
.topbar .crumbs span:not(:last-child)::after {
  content: ''; display: inline-block;
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--fg-faint); margin: 0 10px 2px;
  vertical-align: middle;
}
.topbar .crumbs span:last-child { color: var(--fg); font-weight: 600; }
.topbar .user {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--fg-secondary);
}
.topbar .user .avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--fg);
  color: var(--bg-elev);
  display: grid; place-items: center;
  font-weight: 600; font-size: 11px;
}
.topbar .user form { display: inline; }
.topbar .user .btn-link {
  color: var(--fg-muted); font-size: 12.5px; padding: 4px 8px;
  border-radius: var(--r-sm); transition: background 80ms var(--ease), color 80ms var(--ease);
}
.topbar .user .btn-link:hover { color: var(--danger); background: var(--danger-bg); }

/* Content (scrolls independently) ---------------------------------------- */
.content {
  grid-area: content;
  padding: 28px 32px 64px;
  overflow-y: auto;
  overflow-x: hidden;   /* prevent horizontal page scroll; wide tables scroll inside .table-scroll */
  height: 100%;
  min-width: 0;
}
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 22px; gap: 16px; flex-wrap: wrap;
}
.page-header h1 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: 0; }
.page-header .subtitle { margin: 4px 0 0; color: var(--fg-muted); font-size: 13px; font-weight: 400; }
.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.muted { color: var(--fg-muted); }
.small { font-size: 12px; }

/* Cards — single hairline border, near-zero shadow */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 20px;
  margin-bottom: 14px;
}
.card > h2 { margin: 0 0 4px; font-size: 14px; font-weight: 600; letter-spacing: 0; }
.card > h2 + p { margin: 0 0 16px; color: var(--fg-muted); font-size: 13px; }

/* KPI — refined number-led tile */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: 16px 18px;
  transition: border-color 100ms var(--ease);
}
.kpi:hover { border-color: var(--border-strong); }
.kpi .label { color: var(--fg-muted); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0; }
.kpi .value {
  font-size: 24px; font-weight: 500; margin-top: 6px; color: var(--fg);
  letter-spacing: 0; font-variant-numeric: tabular-nums;
}
.kpi .delta {
  margin-top: 4px; font-size: 11.5px; color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}
.kpi .delta.up   { color: var(--success); }
.kpi .delta.down { color: var(--danger); }

/* Toolbar ----------------------------------------------------------------- */
.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: 10px 12px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-xs);
}
.toolbar > .spacer { flex: 1; }
.toolbar input, .toolbar select { min-width: 180px; }

/* Tables — hairline rows, hover stays subtle */
.table-wrap {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--r-xl); overflow: hidden;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}
.table-scroll { overflow-x: auto; max-width: 100%; }
table.data {
  width: 100%; border-collapse: separate; border-spacing: 0;
  min-width: 720px;
}
table.data th, table.data td {
  padding: 11px 18px; text-align: left;
  border-bottom: 1px solid var(--border); vertical-align: middle;
  white-space: nowrap;
}
table.data th {
  position: sticky; top: 0;
  background: var(--bg-elev);
  font-size: 10.5px; font-weight: 600; color: var(--fg-muted);
  text-transform: uppercase; letter-spacing: 0; z-index: 1;
  padding-top: 9px; padding-bottom: 9px;
}
table.data tbody tr { transition: background 80ms var(--ease); }
table.data tbody tr:hover { background: var(--bg-subtle); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td.wrap { white-space: normal; }
table.data td.truncate { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data code {
  background: var(--bg-subtle); color: var(--fg);
  padding: 2px 7px; border-radius: var(--r-sm);
  border: 0;
  display: inline-block; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; vertical-align: bottom;
  font-size: 11.5px;
}

/* Pills + badges — monochrome by default; status/category pills keep colour
   but the saturation is tamed. Region pills use a uniform neutral chip with a
   tiny coloured dot inside to indicate region. */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 500;
  background: var(--bg-subtle); color: var(--fg-secondary);
  white-space: nowrap;
  border: 1px solid transparent;
}
.pill::before { content: ''; }
.pill-region-anz, .pill-region-can, .pill-region-eur,
.pill-region-ind, .pill-region-lam, .pill-region-usa {
  background: var(--bg-subtle); color: var(--fg-secondary);
}
.pill-region-anz::before, .pill-region-can::before, .pill-region-eur::before,
.pill-region-ind::before, .pill-region-lam::before, .pill-region-usa::before {
  width: 6px; height: 6px; border-radius: 50%; display: inline-block; flex: 0 0 auto;
}
.pill-region-anz::before { background: #2563eb; }
.pill-region-can::before { background: #db2777; }
.pill-region-eur::before { background: #ea580c; }
.pill-region-ind::before { background: #be185d; }
.pill-region-lam::before { background: #ca8a04; }
.pill-region-usa::before { background: #7c3aed; }

.cat-pill { font-weight: 500; padding: 2px 9px; border-radius: 99px; font-size: 11px; display: inline-flex; align-items: center; gap: 5px; }
.cat-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.cat-necessary   { background: var(--bg-subtle); color: var(--fg-secondary); }
.cat-preferences { background: var(--bg-subtle); color: var(--fg-secondary); }
.cat-statistics  { background: var(--bg-subtle); color: var(--fg-secondary); }
.cat-marketing   { background: var(--bg-subtle); color: var(--fg-secondary); }
.cat-necessary::before   { background: var(--cat-necessary); }
.cat-preferences::before { background: var(--cat-preferences); }
.cat-statistics::before  { background: var(--cat-statistics); }
.cat-marketing::before   { background: var(--cat-marketing); }

.status-active   { background: var(--success-bg); color: var(--success); }
.status-inactive { background: var(--bg-subtle); color: var(--fg-muted); }
.status-warning  { background: var(--warning-bg); color: var(--warning); }
.status-danger   { background: var(--danger-bg); color: var(--danger); }

/* Buttons — confident, monochrome, no gradient noise */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 12px; height: 30px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev); color: var(--fg);
  border-radius: var(--r-md);
  font: 500 12.5px/1 inherit; cursor: pointer;
  text-decoration: none;
  transition: background 100ms var(--ease), border-color 100ms var(--ease), transform 60ms var(--ease);
}
.btn:hover { background: var(--bg-subtle); border-color: var(--border-strong); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn:active { transform: translateY(0.5px); }
.btn svg { flex: 0 0 14px; }
.btn-primary {
  background: var(--fg);
  border: 1px solid var(--fg);
  color: var(--bg-elev);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); color: var(--bg-elev); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--fg-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--fg); }
.btn-sm { padding: 0 10px; height: 24px; font-size: 11.5px; }
.btn-lg { padding: 0 16px; height: 36px; font-size: 13px; }
.btn-block { display: flex; width: 100%; justify-content: center; }
.btn[disabled], .btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-link { background: none; border: none; padding: 0; color: inherit; cursor: pointer; font: inherit; box-shadow: none; height: auto; }
/* Keyboard shortcut indicator inside a button (e.g. ⌘K) */
.btn .kbd, .kbd {
  display: inline-flex; align-items: center; padding: 1px 5px;
  font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 10.5px;
  border-radius: 4px; background: var(--bg-subtle); color: var(--fg-muted);
  border: 1px solid var(--border); line-height: 1; margin-left: 4px;
}

/* Inputs — same height as buttons, hairline border */
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=search], input[type=number], input[type=url], input:not([type]),
select, textarea {
  font: inherit;
  padding: 0 11px; height: 30px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--bg-elev); color: var(--fg);
  font-size: 12.5px;
  transition: border-color 100ms var(--ease), box-shadow 100ms var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--fg-faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--fg); box-shadow: var(--shadow-focus); }
textarea { resize: vertical; min-height: 80px; height: auto; padding: 8px 11px; }
textarea.json-edit { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; width: 100%; }
input[type=checkbox], input[type=radio] { width: 14px; height: 14px; margin: 0; accent-color: var(--fg); }
select[multiple] {
  height: auto;
  padding: 6px;
  line-height: 1.5;
}
select[multiple] option {
  padding: 6px 8px;
  border-radius: var(--r-sm);
}

label { display: block; margin: 12px 0; font-size: 13px; }
label > span:first-child { display: block; margin-bottom: 6px; font-weight: 500; color: var(--fg-secondary); font-size: 12.5px; }
fieldset {
  border: 1px solid var(--border); border-radius: var(--r-xl);
  padding: 16px; margin-bottom: 14px; background: var(--bg);
}
legend { padding: 0 6px; color: var(--fg-muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0; }
.split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

/* Dialog ------------------------------------------------------------------ */
dialog {
  border: none; border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  padding: 28px; min-width: 460px; max-width: 90vw;
  color: var(--fg);
}
dialog::backdrop { background: rgba(15, 23, 41, 0.4); backdrop-filter: blur(4px); }
dialog h2 { margin: 0 0 20px; font-size: 17px; font-weight: 600; letter-spacing: 0; }
dialog footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }

/* Tabs -------------------------------------------------------------------- */
.tabs {
  display: flex; gap: 2px; margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.tabs a {
  padding: 10px 14px; cursor: pointer;
  color: var(--fg-muted); font-weight: 500; font-size: 13px;
  border-bottom: 2px solid transparent;
  transition: color 100ms var(--ease), border-color 100ms var(--ease);
  margin-bottom: -1px;
}
.tabs a:hover { color: var(--fg); }
.tabs a.active { color: var(--fg); border-bottom-color: var(--brand); }

/* Snippet blocks ---------------------------------------------------------- */
.snippet-block {
  position: relative;
  background: #09090b; color: #e4e4e7;
  border-radius: var(--r-xl);
  padding: 18px 22px; padding-right: 90px;
  font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 12.5px; line-height: 1.6;
  overflow-x: auto;
  border: 1px solid #18181b;
}
.snippet-block pre { margin: 0; }
.snippet-block code { background: transparent; color: inherit; padding: 0; white-space: pre; border: none; }
.snippet-block .btn {
  position: absolute; top: 12px; right: 12px;
  background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.12); color: #fff;
  box-shadow: none;
}
.snippet-block .btn:hover { background: rgba(255,255,255,0.16); }

/* Theme editor rows ------------------------------------------------------- */
.theme-grid { display: grid; gap: 4px; }
.theme-row {
  display: grid; grid-template-columns: 110px 1fr 32px;
  gap: 8px; align-items: center;
  padding: 4px 4px; border-radius: var(--r-md);
  transition: background 80ms var(--ease);
  min-width: 0;
}
.theme-row:hover { background: var(--bg-subtle); }
.theme-row > span:first-child {
  font-family: inherit;
  font-size: 12px; color: var(--fg-secondary); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.theme-row input[type=color] { width: 32px; height: 26px; padding: 0; border-radius: var(--r-sm); cursor: pointer; border: 1px solid var(--border-strong); min-width: 0; }
.theme-row input[type=text], .theme-row input[type=number] { height: 26px; padding: 0 8px; font-size: 11.5px; min-width: 0; font-family: 'JetBrains Mono', monospace; }

/* Bulk action bar --------------------------------------------------------- */
.bulk-bar {
  position: sticky; bottom: 16px; z-index: 10;
  display: flex; gap: 12px; align-items: center;
  flex-wrap: wrap;
  background: var(--fg); color: #fff;
  padding: 12px 16px; border-radius: var(--r-xl);
  margin-top: 16px;
  box-shadow: var(--shadow-xl);
}
.bulk-bar select { background: #fff; color: var(--fg); border: none; }

/* Details + empty states ------------------------------------------------- */
details { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 12px 16px; margin-bottom: 8px; }
details summary { cursor: pointer; padding: 4px 0; font-weight: 500; font-size: 13px; }
details[open] summary { margin-bottom: 12px; }

.empty {
  padding: 64px 24px; text-align: center;
  color: var(--fg-muted);
  background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: var(--r-xl);
}
.empty .empty-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: inline-grid; place-items: center;
  background: var(--bg-subtle); color: var(--fg-muted);
  margin-bottom: 14px;
}
.empty svg { color: var(--fg-muted); margin-bottom: 0; }
.empty h3 { margin: 0 0 4px; font-size: 14px; color: var(--fg); font-weight: 600; }
.empty p { margin: 0 0 16px; font-size: 13px; color: var(--fg-muted); }
.empty .btn { margin-top: 8px; }

/* Skeleton loading rows (use on tables/lists while data loads) */
.skeleton {
  background: linear-gradient(90deg, var(--bg-subtle) 0%, var(--bg-hover) 50%, var(--bg-subtle) 100%);
  background-size: 200% 100%;
  animation: cg-skel 1.2s linear infinite;
  border-radius: var(--r-sm);
  display: inline-block; height: 12px; width: 100%;
}
@keyframes cg-skel {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* Toast notifications ----------------------------------------------------- */
.toast-stack { position: fixed; right: 24px; bottom: 24px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; max-width: 360px; }
.toast {
  background: var(--fg); color: #fff;
  padding: 12px 16px; border-radius: var(--r-md);
  box-shadow: var(--shadow-xl);
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 13px;
  animation: toast-in 200ms var(--ease);
}
.toast.success { background: var(--success); }
.toast.danger  { background: var(--danger); }
.toast.warning { background: var(--warning); }
.toast .close { margin-left: auto; cursor: pointer; opacity: 0.7; padding: 0 4px; }
.toast .close:hover { opacity: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Login screen ------------------------------------------------------------ */
.login-body {
  min-height: 100vh; display: grid; place-items: center;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.90), rgba(247,247,246,0.92)),
    var(--bg);
  padding: 24px; overflow: auto;
  font-family: 'Inter', sans-serif;
}
.login-card {
  background: var(--bg-elev); border-radius: var(--r-2xl);
  padding: 36px 32px;
  width: 100%; max-width: 380px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.login-card .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; font-size: 16px; font-weight: 600; color: var(--fg); letter-spacing: 0; }
.login-card .brand svg {
  background: var(--brand-grad); border-radius: var(--r-md);
  padding: 4px; color: #fff; width: 28px; height: 28px;
  box-shadow: var(--shadow-brand);
}
.login-card h1 { margin: 0 0 6px; font-size: 20px; font-weight: 600; letter-spacing: 0; }
.login-card p { margin: 0 0 28px; color: var(--fg-muted); font-size: 13px; }
.login-card input { width: 100%; padding: 0 12px; height: 38px; }
.login-card label > span:first-child { font-size: 12.5px; color: var(--fg-secondary); }
.login-card .btn-block { padding: 0; margin-top: 20px; height: 40px; }
.login-error {
  background: var(--danger-bg); color: var(--danger);
  border: 1px solid var(--danger-border);
  padding: 10px 12px; border-radius: var(--r-md); margin-bottom: 18px; font-size: 13px;
}

/* Inactive user row ------------------------------------------------------- */
tr.inactive td { opacity: 0.5; }

/* Brand grid — calm, neutral, content-forward ---------------------------- */
.brand-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px;
}
@media (max-width: 1280px) { .brand-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 1024px) { .brand-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 720px)  { .brand-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px)  { .brand-grid { grid-template-columns: 1fr; } }

.brand-card {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px;
  text-decoration: none; color: var(--fg);
  transition: border-color 120ms var(--ease-out), box-shadow 160ms var(--ease-out), transform 160ms var(--ease-out);
}
.brand-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  color: var(--fg);
  transform: translateY(-1px);
}

.brand-card-top { display: flex; align-items: center; gap: 10px; }
.brand-card-avatar {
  width: 32px; height: 32px;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  font-weight: 600; font-size: 11.5px;
  background: var(--bg-subtle); color: var(--fg-secondary);
  letter-spacing: 0;
  border: 1px solid var(--border);
  flex: 0 0 32px;
}
.brand-card-titles { flex: 1; min-width: 0; }
.brand-card-name {
  font-weight: 600; font-size: 13.5px; color: var(--fg);
  letter-spacing: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.brand-card-meta {
  display: flex; align-items: center; gap: 6px; margin-top: 2px;
  font-size: 11.5px; color: var(--fg-muted);
}
.brand-card-meta code {
  background: transparent; border: none; padding: 0;
  color: var(--fg-muted); font-size: 11px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.brand-card-meta .dot { color: var(--fg-faint); }
.brand-card-status {
  font-size: 10.5px; padding: 1px 6px; border-radius: 99px;
  background: var(--bg-subtle); color: var(--fg-muted);
  border: 1px solid var(--border);
}

.brand-card-domain {
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  color: var(--fg-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.brand-card-foot {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; color: var(--fg-muted);
  border-top: 1px solid var(--border); padding-top: 10px;
}
.brand-card-foot strong { color: var(--fg); font-weight: 600; font-variant-numeric: tabular-nums; }
.brand-card-foot .dot { color: var(--fg-faint); }

/* Brand switcher ---------------------------------------------------------- */
.brand-switcher { position: relative; }
.brand-switcher-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 0 10px; height: 32px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--r-md); color: var(--fg);
  font: 500 13px/1 inherit; cursor: pointer;
  min-width: 220px;
  transition: all 120ms var(--ease);
  box-shadow: var(--shadow-xs);
}
.brand-switcher-trigger:hover { border-color: var(--border-strong); background: var(--bg-subtle); }
.brand-switcher-trigger.open { border-color: var(--brand); box-shadow: var(--shadow-focus); }
.brand-switcher-trigger > svg:first-child { color: var(--fg-muted); }
.brand-switcher-trigger > svg:last-child { color: var(--fg-muted); margin-left: auto; }
.brand-switcher-label { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-switcher-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  width: 340px; max-height: 480px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--shadow-xl);
  z-index: 50;
  display: flex; flex-direction: column; overflow: hidden;
}
.brand-switcher-search { padding: 10px; border-bottom: 1px solid var(--border); }
.brand-switcher-search input { width: 100%; padding: 0 10px; font-size: 13px; height: 32px; }
.brand-switcher-list { overflow-y: auto; flex: 1; padding: 4px 0; }
.brand-switcher-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; color: var(--fg);
  text-decoration: none; font-size: 13px;
  transition: background 80ms var(--ease);
}
.brand-switcher-item:hover { background: var(--bg-subtle); color: var(--fg); }
.brand-switcher-item.active { background: var(--bg-subtle); color: var(--fg); font-weight: 600; }
.brand-switcher-item.active::after { content: '✓'; color: var(--fg); font-weight: 600; margin-left: auto; }
.brand-switcher-avatar {
  width: 28px; height: 28px; border-radius: var(--r-md);
  display: grid; place-items: center;
  font-weight: 600; font-size: 11px;
  flex: 0 0 28px;
  letter-spacing: 0;
}

/* =====================================================================
   BANNER WORKSPACE — Cookiebot-style: editor left, preview right
   ===================================================================== */
.banner-toolbar {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: 8px 12px;
  margin-bottom: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.banner-subtabs {
  display: flex; gap: 2px;
  background: var(--bg-subtle); padding: 3px; border-radius: var(--r-md);
  align-self: flex-start;
}
.banner-subtabs a {
  padding: 6px 14px; cursor: pointer;
  color: var(--fg-muted); font-weight: 500; font-size: 13px;
  border-radius: var(--r-sm);
  transition: all 100ms var(--ease);
}
.banner-subtabs a:hover { color: var(--fg); }
.banner-subtabs a.active {
  background: var(--bg-elev); color: var(--fg);
  box-shadow: var(--shadow-xs), 0 0 0 1px var(--border);
}
.banner-scope {
  display: flex; align-items: center; gap: 16px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.banner-workspace {
  display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 16px;
  align-items: flex-start;
}
@media (max-width: 1100px) { .banner-workspace { grid-template-columns: minmax(0, 1fr); } }

.banner-editor {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xs);
  padding: 6px;
  display: flex; flex-direction: column;
  max-height: calc(100vh - 260px);
  overflow-y: auto;
}

.ws-section {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 0; margin: 0;
}
.ws-section:last-child { border-bottom: none; }
.ws-section > summary {
  list-style: none;
  padding: 12px 14px; font-weight: 600; font-size: 13px;
  color: var(--fg); cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  user-select: none;
}
.ws-section > summary::-webkit-details-marker { display: none; }
.ws-section > summary::before {
  content: '›'; color: var(--fg-faint);
  font-size: 16px; line-height: 1;
  transition: transform 150ms var(--ease);
  flex: 0 0 12px;
}
.ws-section[open] > summary::before { transform: rotate(90deg); }
.ws-section:hover > summary { color: var(--brand); }
.ws-body { padding: 0 14px 16px; }
.ws-body > label { margin: 10px 0; }
.ws-body > label > span:first-child { margin-bottom: 4px; font-size: 12px; }

/* Drag-reorder button list (Design tab > Buttons section) */
.cg-btn-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.cg-btn-row {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-subtle, #f7f8fa);
  border: 1px solid var(--border, #e4e7ec);
  border-radius: var(--r-md, 8px);
  cursor: grab;
  user-select: none;
  transition: background 120ms var(--ease), border-color 120ms var(--ease);
}
.cg-btn-row:hover { background: var(--bg, #fff); border-color: var(--border-strong, #cdd5df); }
.cg-btn-row[draggable=true]:active { cursor: grabbing; }
.cg-btn-row--dragging { opacity: 0.4; }
.cg-btn-handle {
  font-size: 14px; color: var(--fg-faint, #9aa3b1); line-height: 1;
  letter-spacing: 0;
}
.cg-btn-pos {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--bg, #fff); border: 1px solid var(--border, #e4e7ec);
  font-size: 11px; font-weight: 600; color: var(--fg-muted, #6b7280);
}
.cg-btn-label { font-size: 13px; font-weight: 500; }
.cg-btn-role {
  font-size: 12px; padding: 4px 8px;
  border-radius: var(--r-sm, 6px); border: 1px solid var(--border, #e4e7ec);
  background: var(--bg, #fff);
  min-width: 110px;
}

/* Authorised-domains list (Install tab) */
.cg-domain-list {
  list-style: none; padding: 0; margin: 0 0 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.cg-domain-row {
  display: flex; align-items: center;
  padding: 8px 12px;
  background: var(--bg-subtle, #f7f8fa);
  border: 1px solid var(--border, #e4e7ec);
  border-radius: var(--r-md, 8px);
  font-size: 13px;
}
.cg-domain-row.cg-domain-empty {
  background: transparent; border-style: dashed;
  justify-content: center;
}
.cg-domain-host {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 12.5px;
  color: var(--fg, #0f1729);
}
.cg-domain-remove { color: var(--danger, #b42318); }
.cg-domain-remove:hover {
  background: rgba(180, 35, 24, 0.08);
  color: var(--danger, #b42318);
}
.cg-domain-add {
  display: flex; gap: 8px; align-items: center;
}
.cg-domain-add > input[type="text"] { flex: 1 1 auto; }
.ws-group-label {
  font-weight: 600; font-size: 10.5px;
  color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0;
  margin-bottom: 6px;
}
.ws-footer {
  display: flex; gap: 8px; align-items: center;
  padding: 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  position: sticky; bottom: 0; margin: 0 -6px -6px;
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}

.banner-preview-wrap { min-width: 0; max-width: 100%; }
.banner-editor { min-width: 0; }

/* =====================================================================
   FULL-PAGE PREVIEW (mock browser + fake site + cookie banner overlay)
   ===================================================================== */
.cg-preview-frame {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  display: flex; flex-direction: column;
  transition: border-radius 200ms var(--ease-out);
}
/* Full-screen mode: detaches from the layout and takes the whole viewport */
.cg-preview-frame.cg-fullscreen {
  position: fixed; inset: 16px;
  z-index: 999;
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-xl);
}
.cg-preview-frame.cg-fullscreen .cg-preview-stage {
  aspect-ratio: auto;   /* expand to fill remaining space, ignore 16:10 */
  height: 100%;
}
/* Scale-to-fit wrapper: iframe runs at a real laptop viewport (1280×800)
   and gets CSS-transform-scaled to fit whatever space the preview pane has,
   so the banner inside appears at its true proportion relative to the page.
   The stage maintains 16:10 aspect ratio (laptop) — chrome width stays in
   visual lock-step with the content underneath it. */
.cg-preview-stage {
  width: 100%;
  aspect-ratio: 1280 / 800;
  position: relative;
  overflow: hidden;
  background: var(--bg-subtle);
}
.cg-preview-iframe {
  position: absolute; top: 0; left: 0;
  width: 1280px; height: 800px;
  border: 0; background: #fafafa;
  display: block;
  transform-origin: top left;
  /* JS sets transform: scale(...) on the actual stage width. */
  transform: scale(0.56);
}

/* Browser chrome */
.cg-browser-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: #f4f4f5;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.cg-browser-dots { display: flex; gap: 6px; flex: 0 0 auto; }
.cg-browser-dots span {
  width: 11px; height: 11px; border-radius: 50%;
  background: #ddd;
  border: 1px solid rgba(0,0,0,0.08);
}
.cg-browser-dots span:nth-child(1) { background: #ff5f56; border-color: #e0443e; }
.cg-browser-dots span:nth-child(2) { background: #ffbd2e; border-color: #dea123; }
.cg-browser-dots span:nth-child(3) { background: #27c93f; border-color: #1aab29; }
.cg-browser-url {
  flex: 1; background: #fff; border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; color: var(--fg-muted);
  display: flex; align-items: center; gap: 6px;
  height: 28px;
}
.cg-browser-url svg { color: var(--success); flex: 0 0 12px; }

/* Stage where the banner overlays — clean light surface, no mock site */
.cg-site-stage {
  position: relative; flex: 1;
  background: #f4f5f8;
  overflow: hidden;
  font-family: var(--cc-font-family);
}

/* Banner / Prefs overlays positioned on the fake site */
.cg-overlay {
  position: absolute; z-index: 10;
  font-family: var(--cc-font-family);
  pointer-events: auto;
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
}
/* Position presets — corners/center for box+cloud */
.cg-pos-bottom-right  { right: 20px;  bottom: 20px; top: auto; left: auto; }
.cg-pos-bottom-left   { left: 20px;   bottom: 20px; top: auto; right: auto; }
.cg-pos-bottom-center { left: 50%;    bottom: 20px; top: auto; transform: translateX(-50%); }
.cg-pos-top-right     { right: 20px;  top: 20px;    bottom: auto; left: auto; }
.cg-pos-top-left      { left: 20px;   top: 20px;    bottom: auto; right: auto; }
.cg-pos-top-center    { left: 50%;    top: 20px;    bottom: auto; transform: translateX(-50%); }
.cg-pos-middle-center { left: 50%;    top: 50%;     transform: translate(-50%, -50%); }
/* Bar positions */
.cg-pos-bottom          { left: 0; right: 0; bottom: 0; top: auto; transform: none; width: 100%; }
.cg-pos-top             { left: 0; right: 0; top: 0;    bottom: auto; transform: none; width: 100%; }
/* 75% centred bar — floating, has gaps from the edges */
.cg-pos-bottom-centered { left: 50%; right: auto; bottom: 20px; top: auto; transform: translateX(-50%); width: 75%; max-width: 920px; }
.cg-pos-top-centered    { left: 50%; right: auto; top: 20px;    bottom: auto; transform: translateX(-50%); width: 75%; max-width: 920px; }

/* All overlays use opacity for cross-fade — no display:none */
.cg-overlay.hidden { opacity: 0; pointer-events: none; }

/* The banner */
.cg-banner {
  background: var(--cc-bg); color: var(--cc-primary-color);
  border-radius: var(--cc-modal-border-radius);
  box-shadow: 0 16px 48px rgba(15, 23, 41, 0.16);
  padding: 18px 20px 16px;
  width: 360px; max-width: 92vw;
  position: relative;
  border: 1px solid rgba(0,0,0,0.06);
}
.cg-banner.layout-cloud { border-radius: 20px; }

/* Bar layout — text on the left, actions on the right */
.cg-pos-bottom > .cg-banner.layout-bar,
.cg-pos-top    > .cg-banner.layout-bar,
.cg-pos-bottom-centered > .cg-banner.layout-bar,
.cg-pos-top-centered    > .cg-banner.layout-bar {
  width: 100%; max-width: 100%;
  padding: 14px 24px;
  display: flex; align-items: center; gap: 20px;
}
/* Edge-to-edge full bar: no radius, only top/bottom shadow + border */
.cg-pos-bottom > .cg-banner.layout-bar,
.cg-pos-top > .cg-banner.layout-bar {
  border-radius: 0; border-left: none; border-right: none;
}
.cg-pos-bottom > .cg-banner.layout-bar { border-bottom: none; box-shadow: 0 -4px 16px rgba(15, 23, 41, 0.10); border-top: 1px solid rgba(0,0,0,0.08); }
.cg-pos-top    > .cg-banner.layout-bar { border-top: none;    box-shadow: 0  4px 16px rgba(15, 23, 41, 0.10); border-bottom: 1px solid rgba(0,0,0,0.08); }
/* Centred bar: pill-shaped, floating, all-around shadow */
.cg-pos-bottom-centered > .cg-banner.layout-bar,
.cg-pos-top-centered    > .cg-banner.layout-bar {
  border-radius: var(--cc-modal-border-radius);
  border: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 12px 32px rgba(15, 23, 41, 0.14);
}

.cg-banner.layout-bar .cg-close { position: static; order: 99; margin-left: 4px; align-self: flex-start; }
.cg-banner.layout-bar .cg-title { display: none; }
.cg-banner.layout-bar .cg-body  { flex: 1; margin: 0; font-size: 12.5px; min-width: 0; line-height: 1.45; }
/* Stack action buttons vertically — compact column, three rows */
.cg-banner.layout-bar .cg-actions {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  flex: 0 0 auto;
  min-width: 110px;
}
.cg-banner.layout-bar .cg-actions .cg-btn {
  width: 100%;
  justify-content: center;
  margin: 0;
}
.cg-banner.layout-bar .cg-actions .cg-btn-primary { margin-left: 0; }
.cg-banner .cg-title { margin: 0 0 6px; font-size: 14px; font-weight: 600; color: var(--cc-primary-color); }
.cg-banner .cg-body  { margin: 0 0 14px; font-size: 12.5px; line-height: 1.5; color: var(--cc-secondary-color); }
.cg-banner .cg-body strong { color: var(--cc-primary-color); }
.cg-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.cg-actions .cg-btn-primary { margin-left: auto; }

/* Preferences modal */
.cg-prefs {
  background: var(--cc-bg); color: var(--cc-primary-color);
  border-radius: var(--cc-modal-border-radius);
  box-shadow: 0 24px 64px rgba(15, 23, 41, 0.24);
  width: 440px; max-width: 92vw;
  display: flex; flex-direction: column;
  max-height: 420px; overflow: hidden;
  border: 1px solid rgba(0,0,0,0.06);
}
.cg-prefs-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 10px; border-bottom: 1px solid rgba(0,0,0,0.06); }
.cg-prefs-head h4 { margin: 0; font-size: 14px; font-weight: 600; color: var(--cc-primary-color); }
.cg-prefs-body { padding: 12px 20px; overflow-y: auto; }
.cg-prefs-foot { display: flex; gap: 6px; padding: 10px 20px 14px; border-top: 1px solid rgba(0,0,0,0.06); flex-wrap: wrap; }
.cg-prefs-foot .cg-btn-primary { margin-left: auto; }

.cg-cat { padding: 8px 0; border-bottom: 1px solid rgba(0,0,0,0.06); }
.cg-cat:last-child { border-bottom: none; }
.cg-cat-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; }
.cg-cat-head strong { font-size: 12.5px; color: var(--cc-primary-color); }
.cg-cat-desc { margin: 0; font-size: 11.5px; line-height: 1.4; color: var(--cc-secondary-color); }

/* Per-category cookie list (Cookiebot-style: providers grouped, each cookie as a card) */
.cg-cat-cookies {
  margin-top: 10px;
  background: transparent;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 6px;
  padding: 0;
  font-size: 11.5px;
}
.cg-cat-cookies > summary {
  list-style: none;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--cc-secondary-color);
  font-weight: 500;
  user-select: none;
}
.cg-cat-cookies > summary::before,
.cg-provider > summary::before {
  content: '›';
  margin-right: 8px;
  display: inline-block;
  transition: transform 120ms;
  color: currentColor;
}
.cg-cat-cookies[open] > summary::before,
.cg-provider[open] > summary::before { transform: rotate(90deg); }
.cg-cat-cookies > summary::-webkit-details-marker,
.cg-provider   > summary::-webkit-details-marker { display: none; }
.cg-cat-cookies[open] > summary { border-bottom: 1px solid rgba(0,0,0,0.06); }

.cg-providers {
  display: flex; flex-direction: column;
  padding: 8px;
  gap: 6px;
  background: rgba(0,0,0,0.015);
}
.cg-provider {
  background: var(--cc-bg);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 5px;
  padding: 0;
}
.cg-provider > summary {
  list-style: none;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  display: flex; align-items: center;
  color: var(--cc-primary-color);
  font-size: 12px;
}
.cg-provider-count {
  margin-left: 8px;
  padding: 1px 7px;
  background: rgba(0,0,0,0.08);
  color: var(--cc-secondary-color);
  border-radius: 99px;
  font-size: 10.5px; font-weight: 500;
}

.cg-cookies-list {
  padding: 0 12px 8px;
}
.cg-cookie {
  padding: 8px 0;
  border-top: 1px solid rgba(0,0,0,0.05);
  min-width: 0;
}
.cg-cookie:first-child { border-top: none; }
.cg-cookie code {
  background: transparent; border: none; padding: 0;
  color: var(--cc-primary-color);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px; font-weight: 600;
  word-break: break-all;
}
.cg-cookie-purpose {
  margin: 4px 0 6px;
  font-size: 11px; line-height: 1.45;
  color: var(--cc-secondary-color);
  word-break: break-word;
}
.cg-cookie-meta {
  display: flex; flex-wrap: wrap; gap: 4px 16px;
  font-size: 10.5px;
  color: var(--cc-secondary-color);
}
.cg-cookie-meta strong { color: var(--cc-primary-color); font-weight: 500; }
.cg-more {
  margin: 8px 0 0; font-size: 10.5px;
  color: var(--cc-secondary-color); opacity: 0.75;
  text-align: center;
}

.cg-btn {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: inherit; font-size: 12px; font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--cc-btn-border-radius);
  border-width: 1px; border-style: solid;
  cursor: pointer;
  transition: filter 120ms var(--ease), transform 60ms var(--ease);
  user-select: none;
}
.cg-btn:hover { filter: brightness(0.92); }
.cg-btn:active { transform: scale(0.97); }
.cg-btn-primary   { background: var(--cc-btn-primary-bg);   color: var(--cc-btn-primary-color);   border-color: var(--cc-btn-primary-border-color); }
.cg-btn-secondary { background: var(--cc-btn-secondary-bg); color: var(--cc-btn-secondary-color); border-color: var(--cc-btn-secondary-border-color); }
.cg-btn-tertiary  { background: var(--cc-btn-tertiary-bg);  color: var(--cc-btn-tertiary-color);  border-color: var(--cc-btn-tertiary-border-color); }

.cg-close {
  background: transparent; border: none;
  font-size: 18px; line-height: 1;
  color: var(--cc-secondary-color);
  cursor: pointer; padding: 4px 8px; border-radius: 4px;
}
.cg-banner .cg-close { position: absolute; top: 8px; right: 8px; }
.cg-close:hover { background: rgba(0,0,0,0.06); color: var(--cc-primary-color); }

/* Toggles */
.cg-toggle {
  position: relative; width: 34px; height: 18px;
  background: var(--cc-toggle-bg-off);
  border-radius: 99px; cursor: pointer; flex: 0 0 34px;
  transition: background 200ms var(--ease);
}
.cg-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.cg-toggle.on { background: var(--cc-toggle-bg-on); }
.cg-toggle .cg-toggle-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: #fff; border-radius: 99px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform 200ms var(--ease);
}
.cg-toggle.on .cg-toggle-thumb { transform: translateX(16px); }
.cg-toggle.disabled { opacity: 0.5; cursor: not-allowed; }

/* Closed state — small toast-ish indicator */
.cg-closed-toast {
  background: var(--cc-bg);
  border-radius: var(--cc-modal-border-radius);
  padding: 12px 16px;
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 8px 24px rgba(15, 23, 41, 0.10);
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--cc-primary-color); font-size: 12.5px;
}

/* Backdrop dim for middle-center modal */
.cg-backdrop {
  position: absolute; inset: 0; z-index: 9;
  background: rgba(15, 23, 41, 0.25);
  backdrop-filter: blur(2px);
  transition: opacity 200ms var(--ease);
}

/* Responsive (narrow viewports) ------------------------------------------- */
@media (max-width: 920px) {
  .app { grid-template-columns: 64px 1fr; }
  :root { --sidebar-w: 64px; }
  .sidebar-brand span:last-child, .sidebar-nav a span:last-child, .sidebar-footer { display: none; }
  .sidebar-brand { justify-content: center; padding: 14px 0; }
  .sidebar-nav a { justify-content: center; padding: 10px 0; }
  .topbar .user > span:not(.avatar):not(.pill) { display: none; }
  .brand-switcher-trigger { min-width: 160px; }
}
@media (max-width: 600px) {
  html, body { height: auto; min-height: 100%; overflow: auto; }
  .app {
    min-height: 100vh;
    height: auto;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
    grid-template-areas: "topbar" "sidebar" "content";
  }
  .sidebar {
    height: auto;
    position: sticky;
    top: var(--topbar-h);
    z-index: 20;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-brand,
  .sidebar-footer { display: none; }
  .sidebar-nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 8px;
  }
  .sidebar-nav a {
    flex: 0 0 auto;
    width: 42px;
    height: 36px;
    padding: 0;
  }
  .topbar {
    min-height: var(--topbar-h);
    height: auto;
    flex-wrap: wrap;
    row-gap: 8px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .topbar .crumbs { flex-basis: 100%; }
  .brand-switcher { flex: 1; min-width: 0; }
  .brand-switcher-trigger { width: 100%; min-width: 0; }
  .brand-switcher-menu { left: 0; right: auto; width: min(340px, calc(100vw - 32px)); }
  .content { padding: 20px 16px 40px; }
  .card { padding: 18px; }
  .toolbar,
  .page-actions,
  .cg-domain-add,
  .banner-scope,
  .bulk-bar { align-items: stretch; }
  .toolbar > *,
  .page-actions > *,
  .cg-domain-add > *,
  .bulk-bar > * { width: 100%; }
  .split-grid { grid-template-columns: 1fr; }
  dialog { min-width: auto; width: 95vw; padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===========================================================
   Grid workspace (global cookie patterns)
   Ported from the CSM Dashboard object-grid architecture:
   grid + toolbar filter popover + resizable record side panel.
   =========================================================== */

.gw-shell { display: flex; gap: 12px; align-items: flex-start; min-height: 0; }
.gw-main  { flex: 1; min-width: 0; }

/* --- sortable headers --- */
.gw-th {
  display: inline-flex; align-items: center; gap: 4px;
  background: none; border: 0; padding: 0; margin: 0;
  font: inherit; color: inherit; cursor: pointer;
}
.gw-th:disabled { cursor: default; }
.gw-th:not(:disabled):hover { color: var(--fg); }
.gw-sort { color: var(--fg-muted); font-size: 10px; }
.gw-table tbody tr:hover { background: var(--bg-hover); }
.gw-row-active { background: var(--brand-50) !important; box-shadow: inset 2px 0 0 var(--brand); }

/* --- filter popover --- */
.gw-pop-wrap { position: relative; }
.gw-pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30;
  width: 260px; padding: 12px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
}
.gw-pop label { display: block; margin-bottom: 10px; }
.gw-pop label > span { display: block; font-size: 11px; color: var(--fg-muted); margin-bottom: 4px; }
.gw-pop select { width: 100%; }
.gw-pop-foot { display: flex; justify-content: flex-end; border-top: 1px solid var(--border); padding-top: 8px; margin-top: 2px; }
.gw-badge {
  display: inline-grid; place-items: center; min-width: 15px; height: 15px;
  margin-left: 5px; padding: 0 4px; border-radius: 999px;
  background: var(--brand); color: var(--bg-elev); font-size: 10px; font-weight: 500;
}
.btn-active { background: var(--bg-hover); border-color: var(--border-strong); }

/* --- record side panel --- */
.gw-panel {
  position: relative; flex: 0 0 auto; align-self: stretch;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column;
  max-height: calc(100vh - var(--topbar-h) - 130px);
  position: sticky; top: 12px;
}
.gw-resize {
  position: absolute; left: -3px; top: 0; bottom: 0; width: 6px;
  cursor: col-resize; z-index: 2;
}
.gw-resize:hover { background: var(--brand-100); }
.gw-panel-inner { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.gw-panel-head {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.gw-panel-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.gw-panel-title code { font-size: 12.5px; word-break: break-all; }
.gw-panel-nav { display: flex; gap: 4px; flex: 0 0 auto; }
.gw-panel-body { padding: 14px; overflow-y: auto; flex: 1; min-height: 0; }
.gw-panel-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-top: 1px solid var(--border); background: var(--bg-subtle);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* --- panel fields --- */
.gw-field { display: block; margin-bottom: 12px; }
.gw-field > span { display: block; font-size: 11px; color: var(--fg-muted); margin-bottom: 4px; }
.gw-field input[type="text"], .gw-field input:not([type]), .gw-field select, .gw-field textarea { width: 100%; }
.gw-field textarea { resize: vertical; font-family: inherit; font-size: 12.5px; }
.gw-check { display: flex; align-items: center; gap: 7px; }
.gw-check input { width: auto; }
.gw-check > span { margin: 0; font-size: 12px; color: var(--fg-secondary); }
.gw-err {
  margin: 8px 0 0; padding: 7px 9px; font-size: 12px;
  color: var(--danger); background: var(--danger-bg);
  border: 1px solid var(--danger-border); border-radius: var(--r-md);
}
.gw-ro { margin: 12px 0 0; font-size: 12.5px; }
.gw-ro dt { color: var(--fg-muted); font-size: 11px; margin-top: 10px; }
.gw-ro dd { margin: 2px 0 0; }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.gw-dialog { max-width: 460px; }

@media (max-width: 1100px) {
  /* Below this the grid needs its full width - panel drops to an overlay. */
  .gw-panel {
    position: fixed; top: var(--topbar-h); right: 0; bottom: 0;
    width: min(420px, 92vw) !important; max-height: none;
    border-radius: 0; box-shadow: var(--shadow-xl); z-index: 40;
  }
  .gw-resize { display: none; }
}
