/* =========================================================================
   Sigma Mail v5.0 — Resend / Linear Design System
   Sub-menu navigation, command palette, analytics, monochrome minimalism.
   ========================================================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  color-scheme: dark;
  --bg: #000000;
  --bg-sidebar: #09090b;
  --surface: #0a0a0c;
  --surface-2: #121215;
  --surface-3: #1b1b1f;
  --hover: rgba(255, 255, 255, 0.05);
  --active: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.17);
  --text: #f4f4f5;
  --text-2: #a1a1aa;
  --text-3: #71717a;
  --primary-bg: #f4f4f5;
  --primary-fg: #09090b;
  --primary-hover: #ffffff;
  --ring: rgba(255, 255, 255, 0.2);
  --green: #3ecf8e;
  --green-bg: rgba(62, 207, 142, 0.12);
  --amber: #f5a524;
  --amber-bg: rgba(245, 165, 36, 0.12);
  --red: #f25555;
  --red-bg: rgba(242, 85, 85, 0.12);
  --blue: #52a8ff;
  --blue-bg: rgba(82, 168, 255, 0.12);
  --radius: 8px;
  --radius-lg: 12px;
  --ctl-h: 36px;
  --ctl-h-sm: 30px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* semantic aliases */
  --text-main: var(--text);
  --text-soft: var(--text-2);
  --text-faint: var(--text-3);
  --bg-sunken: var(--surface-2);
  --border-subtle: var(--border);
  --sky: var(--blue);
  --ok: var(--green);
  --warn: var(--amber);
  --err: var(--red);
}

html.light {
  color-scheme: light;
  --bg: #fafafa;
  --bg-sidebar: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --surface-3: #e4e4e7;
  --hover: rgba(0, 0, 0, 0.04);
  --active: rgba(0, 0, 0, 0.07);
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #09090b;
  --text-2: #52525b;
  --text-3: #71717a;
  --primary-bg: #09090b;
  --primary-fg: #ffffff;
  --primary-hover: #27272a;
  --ring: rgba(0, 0, 0, 0.14);
  --green: #16a34a;
  --green-bg: rgba(22, 163, 74, 0.1);
  --amber: #b45309;
  --amber-bg: rgba(180, 83, 9, 0.1);
  --red: #dc2626;
  --red-bg: rgba(220, 38, 38, 0.08);
  --blue: #0284c7;
  --blue-bg: rgba(2, 132, 199, 0.08);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; max-width: 100%; overflow-x: clip; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
img, svg { display: block; max-width: 100%; }
button { font-family: inherit; }
.hidden { display: none !important; }
code, pre, .mono { font-family: var(--font-mono); }
code {
  font-size: 0.86em;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
  word-break: break-word;
}
pre code { background: none; border: 0; padding: 0; }
h1, h2, h3, h4 { letter-spacing: -0.02em; font-weight: 600; }
::selection { background: var(--active); }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 10px;
  border: 3px solid transparent;
  background-clip: content-box;
}

/* ---------- Unified Inline SVG Icons ---------- */
.icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  vertical-align: middle;
}
.icon-sm { width: 14px; height: 14px; }
.icon-xs { width: 13px; height: 13px; }
.icon-lg { width: 20px; height: 20px; }
.icon-muted { color: var(--text-3); }
.icon-ok { color: var(--green); }
.icon-warn { color: var(--amber); }
.icon-err { color: var(--red); }
.icon-info { color: var(--blue); }

.inline-icon-text {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

/* =========================================================================
   Auth Screen
   ========================================================================= */
.auth-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, var(--hover), transparent 70%),
    var(--bg);
}
.auth-shell { width: 100%; max-width: 400px; }
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
  text-align: center;
}
.auth-brand img { width: 44px; height: 44px; border-radius: 11px; }
.auth-brand h1 { font-size: 22px; }
.auth-brand p { color: var(--text-2); font-size: 14px; }
.auth-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
}
.segmented .btn {
  height: 30px;
  background: transparent;
  color: var(--text-2);
  border: 0;
  box-shadow: none;
}
.segmented .btn:not(.btn-ghost) {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
html.light .segmented .btn:not(.btn-ghost) {
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.auth-foot { text-align: center; color: var(--text-3); font-size: 12px; margin-top: 18px; }
.captcha-box { margin-bottom: 16px; }
.captcha-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.captcha-img {
  height: 44px;
  width: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* =========================================================================
   App Shell & Collapsible Sub-Menu Sidebar
   ========================================================================= */
.app-shell {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  min-height: 100vh;
}
.app-shell > * { min-width: 0; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}
.sidebar-top { display: flex; flex-direction: column; gap: 2px; }

.brand-lockup {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 8px 14px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.brand-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { width: 26px; height: 26px; border-radius: 7px; flex-shrink: 0; }
.brand-title { font-size: 15px; font-weight: 600; letter-spacing: -0.015em; }
.brand-ver {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 6px;
}

.nav-section-sep {
  height: 1px;
  background: var(--border);
  margin: 8px 6px;
}

.nav-item,
.nav-parent {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 34px;
  padding: 0 10px;
  border-radius: 7px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-item:hover,
.nav-parent:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--active); color: var(--text); }
.nav-parent.has-active { color: var(--text); }

.nav-parent-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-chevron {
  width: 14px;
  height: 14px;
  color: var(--text-3);
  transition: transform 0.18s ease, color 0.12s;
}
.nav-group.open > .nav-parent .nav-chevron {
  transform: rotate(90deg);
  color: var(--text-2);
}

.nav-submenu-wrap {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.18s ease;
}
.nav-group.open > .nav-submenu-wrap {
  grid-template-rows: 1fr;
}
.nav-submenu {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-left: 17px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}
.nav-group.open .nav-submenu {
  margin-top: 2px;
  margin-bottom: 4px;
}
.nav-subitem {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 31px;
  padding: 0 9px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 450;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-subitem:hover { background: var(--hover); color: var(--text); }
.nav-subitem.active {
  background: var(--active);
  color: var(--text);
  font-weight: 500;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 12px 4px 2px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px;
}
.sidebar-user {
  font-size: 12px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.sidebar-footer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.mobile-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 40;
  height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.mobile-title-wrap {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.mobile-page-label {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); border-color: var(--border-strong); }
.sidebar-close-btn { display: none; }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 48;
  background: rgba(0, 0, 0, 0.6);
}
.sidebar-backdrop.open { display: block; }

/* =========================================================================
   Workspace, Breadcrumb & Contextual Page Header
   ========================================================================= */
.workspace {
  width: 100%;
  max-width: 1180px;
  min-width: 0;
  margin: 0 auto;
  padding: 26px 32px 64px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.page-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 6px;
}
.page-breadcrumb button {
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.page-breadcrumb button:hover { color: var(--text); }
.topbar h1 { font-size: 23px; font-weight: 600; line-height: 1.25; }
.topbar-sub { color: var(--text-2); font-size: 13.5px; margin-top: 3px; }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: var(--ctl-h-sm);
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
}
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex-shrink: 0; }

.pane { animation: paneIn 0.16s ease-out; }
@keyframes paneIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* =========================================================================
   Cards, Banners & Empty States
   ========================================================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  min-width: 0;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 600; }
.card-desc { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }

.section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.toolbar-filters input[type="text"],
.toolbar-filters input[type="search"] { max-width: 280px; }
.toolbar-filters select { width: auto; min-width: 145px; max-width: 210px; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 44px 20px;
  gap: 10px;
}
.empty-icon-wrap {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
}
.empty-state h4 { font-size: 14.5px; font-weight: 600; }
.empty-state p { font-size: 13px; color: var(--text-2); max-width: 380px; }

.alert-banner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
}
.alert-ok {
  background: var(--green-bg);
  border: 1px solid color-mix(in srgb, var(--green) 35%, transparent);
  color: var(--text);
}
.alert-warn {
  background: var(--amber-bg);
  border: 1px solid color-mix(in srgb, var(--amber) 35%, transparent);
  color: var(--amber);
}

/* KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 0;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}
.kpi-grid > * { min-width: 0; }
.kpi-card {
  box-shadow: inset -1px -1px 0 var(--border);
  padding: 16px 18px;
}
.kpi-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
}
.kpi-value {
  font-size: 26px;
  font-weight: 600;
  margin-top: 5px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.kpi-foot { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.quick-links-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.quick-link-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.quick-link-card:hover { background: var(--surface-2); border-color: var(--border-strong); }
.quick-link-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  flex-shrink: 0;
}
.quick-link-card strong { display: block; font-size: 13.5px; font-weight: 600; }
.quick-link-card span { display: block; font-size: 12px; color: var(--text-2); }

/* =========================================================================
   Buttons
   ========================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--ctl-h);
  padding: 0 13px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--primary-bg);
  color: var(--primary-fg);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s, opacity 0.12s;
}
.btn:hover { background: var(--primary-hover); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--hover); border-color: var(--border-strong); }

.btn-subtle {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.btn-subtle:hover { background: var(--surface-3); border-color: var(--border-strong); }

.btn-danger {
  background: transparent;
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 35%, transparent);
}
.btn-danger:hover { background: var(--red-bg); }

.btn-sm { height: var(--ctl-h-sm); padding: 0 10px; font-size: 12.5px; border-radius: 6px; }
.btn-block { width: 100%; }

/* =========================================================================
   Forms & Grids
   ========================================================================= */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; }
.grid-2 > *, .grid-3 > *, .studio-split > * { min-width: 0; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field label { font-size: 12.5px; font-weight: 500; color: var(--text); }
.field-hint { font-size: 12px; color: var(--text-3); }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="url"], input[type="search"], input[type="datetime-local"], input[type="date"],
input[type="time"], select, textarea {
  width: 100%;
  min-width: 0;
  height: var(--ctl-h);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0 11px;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
  -webkit-appearance: none;
  appearance: none;
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus { border-color: var(--text-3); box-shadow: 0 0 0 3px var(--ring); }
input:disabled { opacity: 0.65; cursor: not-allowed; }
select {
  padding-right: 30px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
textarea { height: auto; min-height: 92px; padding: 10px 11px; line-height: 1.5; resize: vertical; }
textarea.code-editor {
  font-family: var(--font-mono);
  font-size: 12.5px;
  min-height: 240px;
  background: var(--surface-2);
  tab-size: 2;
}
input[type="checkbox"], input[type="radio"] {
  accent-color: var(--text);
  width: 15px;
  height: 15px;
  cursor: pointer;
}
input[type="file"].hidden { display: none !important; }

.switch-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 14px; }
.toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: var(--ctl-h-sm);
  padding: 0 11px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.toggle-pill:hover { background: var(--hover); color: var(--text); }
.toggle-pill:has(input:checked) { color: var(--text); border-color: var(--border-strong); background: var(--hover); }
.toggle-pill input { width: 14px; height: 14px; }

/* =========================================================================
   Sub-Tabs, Pills, Chips & Dropzone
   ========================================================================= */
.tab-strip {
  display: flex;
  gap: 2px;
  flex-wrap: nowrap;
  overflow-x: auto;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.tab-strip::-webkit-scrollbar { display: none; }
.tab-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  height: 36px;
  padding: 0 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.12s, border-color 0.12s;
}
.tab-pill:hover { color: var(--text); }
.tab-pill.active { color: var(--text); border-bottom-color: var(--text); }

.mode-switch {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  gap: 2px;
}
.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 10px;
  border-radius: 5px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.mode-btn.active {
  background: var(--surface-3);
  color: var(--text);
}
html.light .mode-btn.active {
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.var-chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
}
.var-chip:hover { color: var(--text); border-color: var(--border-strong); }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 22px 16px;
  text-align: center;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-2);
  transition: background 0.12s, border-color 0.12s;
}
.dropzone:hover { background: var(--hover); color: var(--text); border-color: var(--text-3); }

/* =========================================================================
   Studio & Preview Split
   ========================================================================= */
.studio-split {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr);
  gap: 16px;
  align-items: start;
}
.studio-preview-col { position: sticky; top: 20px; }
.preview-frame-shell {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 0 auto;
  width: 100%;
  background: var(--surface-2);
  transition: max-width 0.2s;
}
.preview-frame-shell.mobile-mode { max-width: 375px; }
.preview-browser-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
  overflow: hidden;
  white-space: nowrap;
}
.window-dots { display: flex; gap: 5px; }
.window-dots span { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--border-strong); }
.preview-iframe { width: 100%; height: 500px; border: 0; background: #ffffff; display: block; }
.compose-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid var(--border);
}
.lint-panel {
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13px;
}
.lint-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 8px;
  font-size: 12.5px;
  line-height: 1.45;
}

/* =========================================================================
   Tables & Badges
   ========================================================================= */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  padding: 11px 13px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
th {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface-2);
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--hover); }
tbody tr.row-clickable { cursor: pointer; }
td.cell-actions { white-space: nowrap; }
td.cell-actions .btn + .btn { margin-left: 6px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  text-transform: capitalize;
  border: 1px solid transparent;
}
.badge-ok { background: var(--green-bg); color: var(--green); }
.badge-warn { background: var(--amber-bg); color: var(--amber); }
.badge-err { background: var(--red-bg); color: var(--red); }
.badge-info { background: var(--blue-bg); color: var(--blue); }
.badge-html { background: var(--surface-3); color: var(--text-2); border-color: var(--border); text-transform: none; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-html::before, .badge-info::before { display: none; }

/* =========================================================================
   Copy Fields, Code & DNS Records
   ========================================================================= */
.copy-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 4px 4px 12px;
  cursor: pointer;
  transition: border-color 0.12s;
}
.copy-row:hover { border-color: var(--border-strong); }
.copy-row-val {
  font-family: var(--font-mono);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.copy-box {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 9px;
  cursor: pointer;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: border-color 0.12s;
}
.copy-box:hover { border-color: var(--border-strong); }

pre.sdk-pre {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.6;
  max-width: 100%;
}

.dns-tip { font-size: 12.5px; color: var(--text-2); margin-bottom: 12px; line-height: 1.55; }
.dns-hint {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  color: var(--amber);
  background: var(--amber-bg);
  border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 12px;
}
.dns-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.dns-row { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-bottom: 1px solid var(--border); min-width: 0; }
.dns-row:last-child { border-bottom: 0; }
.dns-row-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.dns-row-fields { display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 2.15fr); gap: 8px; min-width: 0; }
.dns-copy-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 34px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 4px 0 10px;
  cursor: pointer;
  transition: border-color 0.12s;
}
.dns-copy-field:hover { border-color: var(--border-strong); }
.dns-field-label { font-size: 11px; font-weight: 500; color: var(--text-3); flex-shrink: 0; }
.dns-copy-val {
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}
.dns-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  height: 26px;
  padding: 0 9px;
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 500;
  pointer-events: none;
}

/* =========================================================================
   Templates Gallery, Quota, Timeline
   ========================================================================= */
.tpl-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.tpl-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.tpl-preview-frame {
  width: 100%;
  height: 195px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
}

.quota-track { width: 100%; height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.quota-fill { height: 100%; border-radius: 999px; background: var(--text); transition: width 0.35s ease; }

.timeline-item {
  padding: 10px 14px;
  border-left: 2px solid var(--blue);
  margin-bottom: 10px;
  background: var(--surface-2);
  border-radius: 0 8px 8px 0;
}

/* ---------- Command Palette (Cmd/Ctrl + K) ---------- */
.sidebar-search-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 32px;
  padding: 0 10px;
  margin-bottom: 8px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}
.sidebar-search-btn:hover { border-color: var(--border-strong); color: var(--text); }
.kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--surface-3);
  color: var(--text-2);
}

.cmdk-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.68);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: min(14vh, 110px) 16px 16px;
}
.cmdk-box {
  width: min(560px, 100%);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  animation: modalIn 0.14s ease-out;
}
.cmdk-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.cmdk-input-wrap input {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  height: 28px;
  padding: 0;
  font-size: 14px;
}
.cmdk-list {
  max-height: 360px;
  overflow-y: auto;
  padding: 6px;
}
.cmdk-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 7px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.cmdk-item:hover,
.cmdk-item.active { background: var(--active); }
.cmdk-item-group { font-size: 11.5px; color: var(--text-3); }

/* ---------- Pagination, Bulk Bar, Diagnostics, Funnel & 2FA ---------- */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-2);
}
.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  font-size: 13px;
}
.diag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.diag-tile {
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.diag-tile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-2);
}
.diag-tile-val {
  font-family: var(--font-mono);
  font-size: 12.5px;
  word-break: break-all;
}
.funnel-bar {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-3);
  margin: 12px 0;
}
.qr-box {
  display: inline-block;
  padding: 10px;
  background: #ffffff;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.recovery-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}
.recovery-grid code { text-align: center; padding: 5px 8px; }
.wh-delivery-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--surface-2);
}
.live-pill-active {
  border-color: color-mix(in srgb, var(--green) 45%, transparent) !important;
  color: var(--green) !important;
  background: var(--green-bg) !important;
}

/* =========================================================================
   Drawer, Modal & Toast
   ========================================================================= */
.drawer-backdrop, .modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  justify-content: flex-end;
}
.modal-backdrop { align-items: center; justify-content: center; padding: 16px; }

.drawer-panel {
  width: min(720px, 100vw);
  height: 100vh;
  height: 100dvh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 22px;
  overflow-y: auto;
  animation: drawerIn 0.2s ease-out;
}
@keyframes drawerIn { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-card {
  width: min(540px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  animation: modalIn 0.16s ease-out;
}
@keyframes modalIn { from { transform: translateY(8px) scale(0.99); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 120;
  max-width: min(380px, calc(100vw - 32px));
  padding: 11px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  animation: toastIn 0.16s ease-out;
}
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Layout helpers */
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.flex-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }

/* =========================================================================
   Responsive Breakpoints
   ========================================================================= */
@media (max-width: 1100px) {
  .studio-split { grid-template-columns: minmax(0, 1fr); }
  .studio-preview-col { position: static; }
  .tpl-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 1024px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .mobile-topbar { display: flex; }
  .sidebar-close-btn { display: inline-flex; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(280px, 86vw);
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 20px 0 50px rgba(0, 0, 0, 0.4);
  }
  .sidebar.open { transform: none; }
  .workspace { padding: 20px 20px 56px; }
  .quick-links-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 768px) {
  :root { --ctl-h: 40px; --ctl-h-sm: 34px; }
  input[type="text"], input[type="email"], input[type="password"], input[type="number"],
  input[type="url"], input[type="search"], input[type="datetime-local"], select, textarea { font-size: 16px; }
  textarea.code-editor { font-size: 13px; min-height: 200px; }

  .grid-2, .grid-3, .dns-row-fields { grid-template-columns: minmax(0, 1fr); gap: 0 12px; }
  .workspace { padding: 16px 14px 48px; }
  .topbar { flex-direction: column; align-items: stretch; gap: 12px; padding-bottom: 14px; margin-bottom: 16px; }
  .topbar h1 { font-size: 20px; }
  .topbar-right { justify-content: space-between; }
  .card { padding: 16px; border-radius: 10px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-value { font-size: 22px; }
  .preview-iframe { height: 390px; }

  .toolbar-filters input[type="text"],
  .toolbar-filters input[type="search"],
  .toolbar-filters select {
    max-width: 100%;
    width: 100%;
    flex: 1 1 100%;
  }

  .drawer-panel, .modal-card { padding: 16px; }
  .toast { left: 14px; right: 14px; bottom: 14px; max-width: none; }

  /* Stacked mobile cards for tables */
  .table-wrap { border: 0; border-radius: 0; overflow: visible; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    padding: 4px 0;
    background: var(--surface);
  }
  .table-wrap tbody tr:hover { background: var(--surface); }
  .table-wrap td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    text-align: right;
    word-break: break-word;
    white-space: normal;
  }
  .table-wrap td:last-child { border-bottom: 0; }
  .table-wrap td::before {
    content: attr(data-label);
    flex-shrink: 0;
    max-width: 42%;
    text-align: left;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-3);
    padding-top: 2px;
  }
  .table-wrap td:not([data-label])::before, .table-wrap td[data-label=""]::before { display: none; }
  .table-wrap td[colspan] { justify-content: center; text-align: center; }
  .table-wrap td.cell-actions { justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
  .table-wrap td.cell-actions::before { display: none; }
  .table-wrap td.cell-actions .btn + .btn { margin-left: 0; }
  .copy-box { max-width: 100%; white-space: normal; word-break: break-all; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: minmax(0, 1fr); }
  .auth-panel { padding: 20px 16px; }
  .workspace { padding: 14px 12px 44px; }
  .card { padding: 14px; }
}

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