:root {
  color-scheme: dark;
  --canvas: #060912;
  --surface-1: #0b1120;
  --surface-2: #10192b;
  --surface-3: #151f34;
  --surface-elevated: #19243a;
  --border: rgba(139, 157, 205, 0.22);
  --border-strong: rgba(146, 128, 255, 0.48);
  --text: #f4f7ff;
  --text-secondary: #b7c2d8;
  --text-muted: #7f8da9;
  --accent: #7d6dff;
  --accent-2: #4d84ff;
  --danger: #ff6f82;
  --success: #35c58c;
  --warning: #f5b75f;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.42);
  --radius: 8px;
  --radius-lg: 12px;
  --focus: 0 0 0 3px rgba(125, 109, 255, 0.28);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 22% 18%, rgba(74, 102, 220, 0.12), transparent 34%),
    radial-gradient(circle at 82% 72%, rgba(126, 75, 219, 0.10), transparent 36%),
    var(--canvas);
  color: var(--text);
  overflow-x: hidden;
}

button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.ambient {
  position: fixed;
  width: 38vw;
  height: 38vw;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.12;
  pointer-events: none;
  animation: drift 14s ease-in-out infinite alternate;
}
.ambient-a { left: -15vw; top: 5vh; background: #3f70d5; }
.ambient-b { right: -13vw; bottom: -10vh; background: #7448d8; animation-delay: -6s; }

@keyframes drift {
  from { transform: translate3d(0, -2%, 0) scale(0.96); }
  to { transform: translate3d(8%, 4%, 0) scale(1.05); }
}

.shell { min-height: 100vh; padding: 28px; position: relative; z-index: 1; }
.hidden { display: none !important; }
.eyebrow { margin: 0 0 8px; color: var(--text-secondary); font-size: 12px; text-transform: uppercase; font-weight: 700; }
.muted, .field-hint { color: var(--text-secondary); }
.field-hint { margin: -4px 0 2px; font-size: 12px; line-height: 1.45; }

.auth-layout {
  width: min(1080px, 100%);
  min-height: calc(100vh - 56px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(380px, 0.95fr);
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: rgba(8, 13, 24, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.brand-panel {
  position: relative;
  padding: clamp(36px, 6vw, 76px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 46px;
  background: linear-gradient(145deg, rgba(17, 28, 51, 0.96), rgba(8, 13, 25, 0.98));
  border-right: 1px solid var(--border);
}

.brand-mark {
  width: 58px;
  height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: linear-gradient(145deg, rgba(125, 109, 255, 0.22), rgba(77, 132, 255, 0.08));
  color: var(--text);
  font-size: 17px;
  font-weight: 800;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.05), 0 14px 30px rgba(18, 24, 59, 0.34);
}
.brand-mark.small { width: 38px; height: 38px; font-size: 12px; }
.brand-logo {
  width: 112px;
  height: 112px;
  object-fit: contain;
  object-position: left center;
  border-radius: 28px;
  mix-blend-mode: screen;
  filter: contrast(1.55) brightness(1.12) drop-shadow(0 14px 28px rgba(74, 103, 212, 0.24));
}
.brand-panel h1 { margin: 10px 0 18px; font-size: clamp(38px, 5vw, 64px); line-height: 1; }
.brand-copy { margin: 0; max-width: 520px; color: var(--text-secondary); font-size: 17px; line-height: 1.65; }
.security-note { display: flex; align-items: flex-start; gap: 12px; color: var(--text-secondary); font-size: 13px; line-height: 1.45; }
.status-dot { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(53, 197, 140, 0.10); flex: 0 0 auto; }

.auth-card { padding: clamp(30px, 4vw, 54px); background: rgba(11, 17, 32, 0.96); overflow-y: auto; }
.card-head, .workspace-head, .topbar, .topbar-actions, .compact-brand { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.card-head { margin-bottom: 30px; }
.card-head h2, .workspace-head h2 { margin: 0; font-size: 28px; }
.version { color: var(--text-muted); font-size: 12px; }

.form { display: grid; gap: 16px; }
.form label { display: grid; gap: 8px; color: var(--text-secondary); font-size: 13px; font-weight: 650; }
input, select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}
input::placeholder { color: var(--text-muted); }
textarea { min-height: 92px; padding-top: 12px; resize: vertical; }
select { appearance: none; padding-right: 38px; background-image: linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%), linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%); background-position: calc(100% - 18px) 19px, calc(100% - 13px) 19px; background-size: 5px 5px; background-repeat: no-repeat; }
input:hover, select:hover, textarea:hover { border-color: rgba(139, 157, 205, 0.38); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: var(--focus); background-color: var(--surface-3); }

.password-field { position: relative; display: block; }
.password-field input { padding-right: 50px; }
.password-toggle { position: absolute; top: 50%; right: 6px; width: 38px; height: 36px; padding: 0; transform: translateY(-50%); border: 0; border-radius: var(--radius); background: transparent; color: var(--text-secondary); display: grid; place-items: center; }
.password-toggle:hover { background: rgba(125, 109, 255, 0.12); color: var(--text); }
.password-toggle:focus-visible { outline: none; box-shadow: var(--focus); }
.password-toggle span { position: relative; width: 19px; height: 12px; border: 1.8px solid currentColor; border-radius: 50% / 62%; }
.password-toggle span::after { content: ""; position: absolute; left: 50%; top: 50%; width: 5px; height: 5px; transform: translate(-50%, -50%); border-radius: 50%; background: currentColor; }
.password-toggle span::before { content: ""; position: absolute; left: -3px; top: 4px; width: 24px; height: 2px; transform: rotate(-38deg); border-radius: 2px; background: currentColor; box-shadow: 0 0 0 2px var(--surface-2); }
.password-toggle.visible span::before { display: none; }

.button {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 700;
  transition: transform 120ms ease, background 150ms ease, border-color 150ms ease, opacity 150ms ease;
}
.button:hover { transform: translateY(-1px); }
.button:focus-visible, .link-button:focus-visible, .nav-item:focus-visible, .icon-button:focus-visible { outline: none; box-shadow: var(--focus); }
.button:disabled { cursor: wait; opacity: 0.58; transform: none; }
.button.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 12px 24px rgba(77, 91, 255, 0.20); }
.button.primary:hover { background: linear-gradient(135deg, #8a7cff, #5a90ff); }
.button.secondary { border-color: var(--border); background: var(--surface-2); }
.button.secondary:hover { border-color: var(--border-strong); background: var(--surface-3); }
.button.provider-button { border-color: var(--border-strong); background: var(--surface-2); }
.button.provider-button:hover { border-color: rgba(139, 157, 205, 0.52); background: var(--surface-3); }
.button.danger { border-color: rgba(255, 111, 130, 0.35); background: rgba(255, 111, 130, 0.10); color: #ffd8de; }
.button.compact { min-height: 36px; padding-inline: 14px; font-size: 13px; }

.form-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 12px; }
.auth-divider::before, .auth-divider::after { content: ""; height: 1px; flex: 1; background: var(--border); }
.link-button { padding: 4px 0; border: 0; background: transparent; color: #aab7ff; font-size: 13px; }
.link-button:hover { color: var(--text); }

.notice, .error-box {
  padding: 12px 14px;
  margin-bottom: 18px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.5;
}
.notice { border: 1px solid rgba(125, 109, 255, 0.32); background: rgba(125, 109, 255, 0.10); color: #d9d5ff; }
.control-notice { margin-bottom: 14px; }
.error-box { border: 1px solid rgba(255, 111, 130, 0.35); background: rgba(255, 111, 130, 0.10); color: #ffd8de; }

.verification { text-align: center; padding: 16px 0; }
.verification h3 { margin: 0 0 10px; font-size: 23px; }
.verification p { color: var(--text-secondary); line-height: 1.55; }
.verification .button { width: 100%; margin-top: 10px; }
.code-input {
  font-variant-numeric: tabular-nums;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 8px;
  text-align: center;
}

.control-layout { min-height: calc(100vh - 56px); max-width: 1540px; margin: 0 auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: rgba(8, 13, 24, 0.94); box-shadow: var(--shadow); overflow: hidden; }
.topbar { min-height: 70px; padding: 12px 18px; border-bottom: 1px solid var(--border); background: var(--surface-1); }
.compact-brand { justify-content: flex-start; }
.compact-brand div { display: grid; gap: 3px; }
.compact-brand small, .account-label { color: var(--text-secondary); font-size: 12px; }
.control-content { min-height: calc(100vh - 128px); display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.control-nav { padding: 18px 12px; border-right: 1px solid var(--border); background: #080e1a; }
.nav-item { width: 100%; min-height: 42px; padding: 0 12px; margin-bottom: 6px; border: 1px solid transparent; border-radius: var(--radius); background: transparent; color: var(--text-secondary); text-align: left; font-weight: 650; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { border-color: rgba(125, 109, 255, 0.3); background: rgba(125, 109, 255, 0.12); color: var(--text); }
.workspace { min-width: 0; padding: 24px; }
.workspace-head { margin-bottom: 18px; }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); color: var(--text); font-size: 20px; }
.icon-button:hover { border-color: var(--border-strong); }
.workspace-body { display: grid; gap: 12px; }

.context-switcher { min-width: 420px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.context-switcher label { display: grid; grid-template-columns: auto minmax(120px, 1fr); align-items: center; gap: 8px; color: var(--text-muted); font-size: 11px; font-weight: 700; }
.context-switcher select { min-height: 38px; padding-left: 10px; font-size: 12px; }
.context-switcher:has(option:only-child) { opacity: 0.72; }

.empty-state, .business-card, .session-card, .security-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-1); }
.empty-state { padding: 30px; text-align: center; }
.empty-state h3 { margin: 0 0 8px; }
.empty-state p { margin: 0; color: var(--text-secondary); line-height: 1.55; }
.business-card, .session-card { padding: 16px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; }
.business-card h3, .session-card h3, .security-card h3 { margin: 0 0 6px; font-size: 16px; }
.business-card p, .session-card p, .security-card p { margin: 0; color: var(--text-secondary); font-size: 13px; line-height: 1.5; }
.badge { display: inline-flex; align-items: center; min-height: 26px; padding: 0 9px; border: 1px solid var(--border); border-radius: 999px; color: var(--text-secondary); background: var(--surface-2); font-size: 11px; font-weight: 700; }
.badge.current { border-color: rgba(77, 132, 255, 0.38); color: #c9dcff; }
.badge.revoked { border-color: rgba(255, 111, 130, 0.3); color: #ffc8d0; }
.session-actions { display: flex; align-items: center; gap: 10px; }
.security-card { padding: 20px; }
.security-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.security-metric { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.security-metric span { display: block; color: var(--text-muted); font-size: 11px; margin-bottom: 6px; }
.security-metric strong { font-size: 14px; }

.organization-shell { display: grid; gap: 16px; }
.organization-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-1); }
.organization-toolbar p { margin: 4px 0 0; color: var(--text-secondary); font-size: 13px; }
.organization-grid { display: grid; grid-template-columns: minmax(260px, 0.34fr) minmax(0, 0.66fr); gap: 16px; align-items: start; }
.business-list, .structure-panel { min-width: 0; display: grid; gap: 10px; }
.business-card { cursor: pointer; transition: border-color 150ms ease, background 150ms ease, transform 120ms ease; }
.business-card:hover { transform: translateY(-1px); border-color: rgba(139, 157, 205, 0.38); }
.business-card.selected { border-color: var(--border-strong); background: linear-gradient(145deg, rgba(125, 109, 255, 0.14), var(--surface-1)); }
.business-card.archived, .structure-row.archived { opacity: 0.62; }
.business-card-actions, .structure-actions, .section-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.structure-section { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-1); overflow: hidden; }
.structure-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.structure-head h3 { margin: 0; font-size: 15px; }
.structure-head p { margin: 3px 0 0; color: var(--text-muted); font-size: 12px; }
.structure-list { display: grid; }
.structure-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.structure-row:last-child { border-bottom: 0; }
.structure-row h4 { margin: 0 0 4px; font-size: 14px; }
.structure-row p { margin: 0; color: var(--text-secondary); font-size: 12px; line-height: 1.45; }
.structure-empty { padding: 20px 16px; color: var(--text-secondary); font-size: 13px; }
.split-structure { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.structure-filter { min-width: min(320px, 42vw); display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px; color: var(--text-muted); font-size: 11px; }
.structure-filter input { min-height: 38px; }
.row-check { width: 16px; min-height: 16px; margin: 0 8px 0 0; vertical-align: -3px; accent-color: var(--accent); }
.catalog-shell { display: grid; gap: 12px; }
.catalog-toolbar { display: grid; grid-template-columns: minmax(260px, 1fr) 180px 150px auto auto; gap: 9px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-1); }
.catalog-summary { display: flex; flex-wrap: wrap; gap: 10px 22px; padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); color: var(--text-secondary); font-size: 11px; }
.catalog-table { min-width: 980px; }
.catalog-table small { display: block; margin-top: 4px; color: var(--text-muted); }
.catalog-actions { display: flex; flex-wrap: nowrap; gap: 6px; }
.catalog-footer { position: sticky; bottom: 0; display: flex; justify-content: flex-end; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: rgba(10, 16, 30, 0.96); backdrop-filter: blur(10px); }
.metric-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.metric { padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.metric span { display: block; margin-bottom: 4px; color: var(--text-muted); font-size: 10px; text-transform: uppercase; }
.metric strong { font-size: 13px; }
.button.ghost { min-height: 34px; padding: 0 11px; border-color: var(--border); background: transparent; font-size: 12px; }
.button.ghost:hover { background: var(--surface-3); }

.modal-layer { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(2, 5, 12, 0.76); backdrop-filter: blur(9px); animation: modal-fade 150ms ease; }
.modal-card { width: min(620px, 100%); max-height: min(820px, calc(100vh - 40px)); overflow: hidden; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface-1); box-shadow: var(--shadow); animation: modal-rise 170ms ease; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 20px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.modal-head h2 { margin: 0; font-size: 21px; }
.modal-form { max-height: calc(100vh - 150px); overflow-y: auto; padding: 20px; scrollbar-gutter: stable; }
.modal-form .form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.modal-form .form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.check-item { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 9px !important; min-height: 42px; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); color: var(--text-secondary); }
.check-item input { width: 17px; min-height: 17px; accent-color: var(--accent); }
.close-button { font-size: 26px; line-height: 1; }
@keyframes modal-fade { from { opacity: 0; } }
@keyframes modal-rise { from { opacity: 0; transform: translateY(8px) scale(0.99); } }

.busy { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; gap: 12px; background: rgba(3, 6, 13, 0.68); backdrop-filter: blur(6px); color: var(--text); font-weight: 700; }
.spinner { width: 22px; height: 22px; border: 2px solid rgba(255, 255, 255, 0.2); border-top-color: var(--accent); border-radius: 50%; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 820px) {
  .shell { padding: 14px; }
  .auth-layout { min-height: calc(100vh - 28px); grid-template-columns: 1fr; }
  .brand-panel { padding: 28px; gap: 24px; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand-panel h1 { font-size: 38px; }
  .brand-copy { font-size: 14px; }
  .auth-card { padding: 28px; }
  .control-layout { min-height: calc(100vh - 28px); }
  .topbar { flex-wrap: wrap; }
  .context-switcher { min-width: 0; width: 100%; order: 3; }
  .control-content { grid-template-columns: 1fr; }
  .control-nav { display: flex; gap: 6px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .nav-item { width: auto; flex: 0 0 auto; margin: 0; }
  .security-grid { grid-template-columns: 1fr; }
  .organization-grid { grid-template-columns: 1fr; }
  .split-structure { grid-template-columns: 1fr; }
  .catalog-toolbar { grid-template-columns: 1fr 1fr; }
  .catalog-toolbar input { grid-column: 1 / -1; }
  .metric-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 500px) {
  .shell { padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom)); }
  .auth-layout { min-height: calc(100vh - 16px); }
  .brand-panel { min-height: 148px; padding: 22px 22px 22px 94px; justify-content: center; }
  .brand-panel .brand-mark, .security-note { display: none; }
  .brand-panel .brand-logo {
    display: block;
    position: absolute;
    left: 20px;
    top: 24px;
    width: 58px;
    height: 58px;
    border-radius: 16px;
  }
  .brand-panel h1 { margin: 4px 0 10px; font-size: 30px; }
  .brand-copy { line-height: 1.5; }
  .auth-card { padding: 22px; }
  .card-head { margin-bottom: 22px; }
  .card-head h2 { font-size: 24px; }
  .form-links { display: grid; justify-items: start; }
  .topbar { align-items: flex-start; }
  .account-label { display: none; }
  .workspace { padding: 16px; }
  .business-card, .session-card { grid-template-columns: 1fr; }
  .session-actions { justify-content: space-between; }
  .context-switcher { grid-template-columns: 1fr; }
  .context-switcher label { grid-template-columns: 62px minmax(0, 1fr); }
  .organization-toolbar, .structure-head, .structure-row { align-items: stretch; flex-direction: column; }
  .organization-toolbar { display: grid; }
  .structure-row { grid-template-columns: 1fr; }
  .metric-row, .modal-form .form-row, .check-grid { grid-template-columns: 1fr; }
  .modal-layer { padding: 8px; }
  .modal-card { max-height: calc(100vh - 16px); }
  .modal-form { max-height: calc(100vh - 94px); }
}

/* Stage 07: protected control-center shell */
.control-layout { position: relative; }
.offline-banner { padding: 9px 18px; border-bottom: 1px solid rgba(245, 183, 95, 0.32); background: rgba(245, 183, 95, 0.10); color: #ffe0af; font-size: 12px; font-weight: 700; text-align: center; }
.control-logo { width: 42px; height: 42px; border-radius: var(--radius); object-fit: cover; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.32); }
.menu-button { display: none; }
.topbar { position: relative; z-index: 8; }
.topbar-actions { margin-left: auto; }
.topbar-tool, .account-button {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.topbar-tool { min-width: 40px; padding: 0 11px; position: relative; }
.topbar-tool:hover, .account-button:hover { border-color: var(--border-strong); background: var(--surface-3); color: var(--text); }
.topbar-tool kbd { padding: 2px 5px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-1); color: var(--text-muted); font-size: 9px; }
.account-button { padding: 4px 10px 4px 5px; }
.account-avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(145deg, rgba(125, 109, 255, 0.32), rgba(77, 132, 255, 0.24)); color: var(--text); font-size: 10px; font-weight: 800; }
.notification-count { position: absolute; top: -6px; right: -6px; min-width: 19px; height: 19px; padding: 0 5px; display: grid; place-items: center; border: 2px solid var(--surface-1); border-radius: 999px; background: var(--danger); color: #fff; font-size: 9px; font-weight: 800; }

.control-content { grid-template-columns: 248px minmax(0, 1fr); }
.control-nav { position: relative; z-index: 7; padding: 18px 12px 24px; }
.nav-group-label { margin: 16px 12px 8px; color: var(--text-muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.nav-group-label:first-child { margin-top: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; }
.nav-icon { width: 26px; height: 26px; flex: 0 0 26px; display: grid; place-items: center; border: 1px solid transparent; border-radius: 6px; color: var(--text-muted); font-size: 15px; line-height: 1; }
.nav-item.active .nav-icon { border-color: rgba(125, 109, 255, 0.28); background: rgba(125, 109, 255, 0.14); color: var(--text); }
.nav-scrim { display: none; }
.workspace { min-height: 620px; }
.breadcrumbs { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; color: var(--text-muted); font-size: 11px; }
.breadcrumbs span + span::before { content: "/"; margin-right: 8px; color: rgba(139, 157, 205, 0.44); }

.overview-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.overview-card, .onboarding-card, .profile-card, .table-shell, .activity-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
}
.overview-card { min-height: 106px; padding: 16px; display: grid; align-content: space-between; }
.overview-card span { color: var(--text-secondary); font-size: 12px; }
.overview-card strong { font-size: 27px; }
.overview-section { display: grid; gap: 12px; margin-top: 4px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.section-heading h3 { margin: 0; font-size: 16px; }
.section-heading p { margin: 4px 0 0; color: var(--text-secondary); font-size: 12px; }
.activity-list { display: grid; gap: 8px; }
.activity-card { padding: 13px 15px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; }
.activity-card strong { display: block; margin-bottom: 4px; font-size: 13px; }
.activity-card p { margin: 0; color: var(--text-secondary); font-size: 11px; }
.activity-card time { color: var(--text-muted); font-size: 11px; white-space: nowrap; }
.onboarding-card { padding: 22px; }
.onboarding-card h3 { margin: 0 0 8px; }
.onboarding-card > p { max-width: 760px; margin: 0; color: var(--text-secondary); line-height: 1.55; }
.onboarding-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 18px 0; }
.onboarding-step { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.onboarding-step span { display: block; margin-bottom: 8px; color: #c9c4ff; font-size: 11px; font-weight: 800; }
.onboarding-step strong { display: block; margin-bottom: 6px; font-size: 13px; }
.onboarding-step p { margin: 0; color: var(--text-muted); font-size: 11px; line-height: 1.45; }
.onboarding-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.button-link { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }

.table-shell { overflow: hidden; }
.table-toolbar { padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.table-toolbar p { margin: 4px 0 0; color: var(--text-secondary); font-size: 12px; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 13px 16px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.data-table th { color: var(--text-muted); background: rgba(7, 12, 23, 0.62); font-size: 10px; text-transform: uppercase; }
.data-table td { color: var(--text-secondary); font-size: 12px; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table strong { color: var(--text); }
.staff-identity { display: grid; gap: 3px; }
.staff-identity small { color: var(--text-muted); }
.role-select { min-width: 172px; min-height: 38px; font-size: 12px; }
.table-scroll { overflow-x: auto; scrollbar-gutter: stable; }
.profile-card { max-width: 760px; overflow: hidden; }
.profile-card header { padding: 18px 20px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.profile-card h3 { margin: 0 0 5px; }
.profile-card p { margin: 0; color: var(--text-secondary); font-size: 12px; }
.profile-form { padding: 20px; }
.profile-form .form-actions { display: flex; justify-content: flex-end; }

.state-card { min-height: 360px; padding: 34px; display: grid; place-items: center; text-align: center; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-1); }
.state-card > div { max-width: 560px; }
.state-code { color: #c9c4ff; font-size: 12px; font-weight: 800; }
.state-card h3 { margin: 8px 0; font-size: 24px; }
.state-card p { margin: 0 0 18px; color: var(--text-secondary); line-height: 1.55; }

.notification-panel { position: absolute; z-index: 15; top: 78px; right: 18px; width: min(390px, calc(100% - 36px)); max-height: min(640px, calc(100vh - 110px)); overflow: hidden; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-1); box-shadow: var(--shadow); }
.notification-panel header { padding: 15px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.notification-panel h2 { margin: 0; font-size: 18px; }
.notification-list { max-height: 520px; overflow-y: auto; padding: 10px; }
.notification-item { padding: 12px; border-bottom: 1px solid var(--border); }
.notification-item:last-child { border-bottom: 0; }
.notification-item strong { display: block; margin-bottom: 4px; font-size: 12px; }
.notification-item p { margin: 0; color: var(--text-secondary); font-size: 11px; line-height: 1.4; }

.command-layer { position: fixed; inset: 0; z-index: 30; display: grid; place-items: start center; padding: 12vh 16px 16px; background: rgba(2, 5, 12, 0.76); backdrop-filter: blur(10px); }
.command-card { width: min(650px, 100%); overflow: hidden; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-1); box-shadow: var(--shadow); }
.command-search { min-height: 62px; padding: 9px 16px; display: grid; grid-template-columns: 24px minmax(0, 1fr); align-items: center; gap: 8px; border-bottom: 1px solid var(--border); }
.command-search input { min-height: 42px; border: 0; background: transparent; box-shadow: none; }
.command-results { max-height: 380px; overflow-y: auto; padding: 8px; }
.command-option { width: 100%; min-height: 46px; padding: 0 12px; display: flex; align-items: center; justify-content: space-between; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--text-secondary); text-align: left; }
.command-option:hover, .command-option.active { border-color: var(--border); background: var(--surface-2); color: var(--text); }
.command-option small { color: var(--text-muted); }
.command-card footer { padding: 10px 14px; display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 10px; }

@media (max-width: 1160px) {
  .control-content { grid-template-columns: 224px minmax(0, 1fr); }
  .context-switcher { min-width: 330px; }
  .tool-label, .topbar-tool kbd { display: none; }
  .overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .control-layout { min-height: calc(100vh - 28px); }
  .topbar { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; }
  .menu-button { display: grid; }
  .compact-brand { min-width: 0; }
  .compact-brand div { overflow: hidden; }
  .compact-brand strong, .compact-brand small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-actions { grid-column: 3; }
  .topbar-actions .button, .account-label { display: none; }
  .context-switcher { grid-column: 1 / -1; width: 100%; order: initial; }
  .control-content { display: block; }
  .control-nav { position: absolute; inset: 0 auto 0 0; width: min(292px, 86vw); min-height: 100%; display: block; overflow-y: auto; transform: translateX(-102%); transition: transform 180ms ease; border-right: 1px solid var(--border-strong); border-bottom: 0; box-shadow: 18px 0 54px rgba(0, 0, 0, 0.42); }
  .control-nav.open { transform: translateX(0); }
  .nav-item { width: 100%; margin-bottom: 6px; }
  .nav-scrim { position: absolute; inset: 0; z-index: 6; display: block; border: 0; background: rgba(2, 5, 12, 0.68); }
  .workspace { min-height: calc(100vh - 184px); }
  .onboarding-steps { grid-template-columns: 1fr; }
}

@media (max-width: 500px) {
  .control-logo { width: 36px; height: 36px; }
  .compact-brand small { display: none; }
  .topbar { padding: 10px; gap: 8px; }
  .topbar-actions { gap: 6px; }
  .command-trigger { display: none; }
  .context-switcher { gap: 7px; }
  .context-switcher label { grid-template-columns: 58px minmax(0, 1fr); }
  .workspace-head h2 { font-size: 23px; }
  .overview-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .overview-card { min-height: 90px; padding: 12px; }
  .overview-card strong { font-size: 22px; }
  .activity-card { grid-template-columns: 1fr; gap: 6px; }
  .activity-card time { white-space: normal; }
  .onboarding-card { padding: 16px; }
  .table-toolbar { align-items: stretch; flex-direction: column; }
  .data-table th, .data-table td { padding: 11px 12px; }
  .profile-form { padding: 16px; }
  .notification-panel { top: 70px; right: 8px; width: calc(100% - 16px); }
  .catalog-toolbar { grid-template-columns: 1fr; }
  .catalog-toolbar input { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
/* Stage 11 catalog details */
.catalog-inline-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; }
.catalog-detail-section { margin-top: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: rgba(8, 17, 31, .68); }
.catalog-detail-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.catalog-detail-row span { min-width: 0; display: grid; gap: 3px; }
.catalog-detail-row small { color: var(--text-muted); overflow-wrap: anywhere; }
.catalog-history { display: grid; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }
.catalog-history li { display: flex; justify-content: space-between; gap: 12px; color: var(--text-muted); }
.catalog-history strong { color: var(--text); font-weight: 600; }
.catalog-label-preview { width: min(100%, 430px); margin: 10px auto; padding: 28px; display: grid; gap: 12px; text-align: center; color: #000; background: #fff; border: 2px solid #000; }
.catalog-label-preview strong { font-size: 24px; }
.catalog-label-preview b { font-family: ui-monospace, Consolas, monospace; letter-spacing: 2px; }

@media (max-width: 720px) {
  .catalog-inline-field { grid-template-columns: 1fr; }
  .catalog-detail-row { align-items: flex-start; }
}

@media print {
  body * { visibility: hidden !important; }
  .catalog-label-preview, .catalog-label-preview * { visibility: visible !important; }
  .catalog-label-preview { position: fixed; inset: 0 auto auto 0; margin: 0; }
}
/* Stage 12 pricing engine */
.pricing-shell { display: grid; gap: 14px; }
.pricing-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: rgba(9, 18, 34, .84); }
.pricing-toolbar h3 { margin: 0 0 5px; }
.pricing-toolbar p { max-width: 720px; margin: 0; color: var(--text-muted); line-height: 1.5; }
.pricing-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.pricing-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.pricing-metrics span { display: flex; justify-content: space-between; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: rgba(10, 20, 38, .76); color: var(--text-muted); }
.pricing-metrics strong { color: var(--text); font-size: 18px; }
.pricing-tabs { display: flex; gap: 6px; padding: 5px; border: 1px solid var(--line); border-radius: 10px; background: rgba(7, 14, 27, .82); overflow-x: auto; }
.pricing-tabs button { min-height: 38px; padding: 8px 16px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--text-muted); cursor: pointer; white-space: nowrap; }
.pricing-tabs button.active { border-color: rgba(128, 119, 255, .42); background: rgba(96, 82, 210, .2); color: var(--text); }
.pricing-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.pricing-card { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: rgba(10, 20, 38, .78); }
.pricing-card h3 { margin: 12px 0 6px; }
.pricing-card p { margin: 0 0 10px; color: var(--text); }
.pricing-card small { color: var(--text-muted); }
.pricing-history { display: grid; gap: 9px; }
.pricing-history article { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 14px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: rgba(9, 18, 34, .78); }
.pricing-history article div { display: grid; gap: 3px; }
.pricing-history article span, .pricing-history article small, .pricing-history article p { color: var(--text-muted); }
.pricing-history article p { grid-column: 1 / -1; margin: 0; }
.pricing-table { min-width: 920px; table-layout: fixed; }
.pricing-table th, .pricing-table td { padding: 13px 12px; vertical-align: top; overflow-wrap: anywhere; }
.pricing-table th:nth-child(1) { width: 22%; }
.pricing-table th:nth-child(2) { width: 12%; }
.pricing-table th:nth-child(3), .pricing-table th:nth-child(4) { width: 12%; }
.pricing-table th:nth-child(5) { width: 22%; }
.pricing-table th:nth-child(6) { width: 20%; }
.pricing-table td strong, .pricing-table td small { display: block; }
.pricing-table td small { margin-top: 4px; color: var(--text-muted); line-height: 1.35; }

@media (max-width: 880px) {
  .pricing-toolbar { display: grid; }
  .pricing-actions { justify-content: flex-start; }
  .pricing-metrics { grid-template-columns: 1fr; }
}

/* Stage 13 inventory ledger */
.inventory-shell { display: grid; gap: 14px; min-width: 0; }
.inventory-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: rgba(10, 20, 38, .78); }
.inventory-toolbar h3 { margin: 0 0 6px; }
.inventory-toolbar p { max-width: 720px; margin: 0; color: var(--text-muted); line-height: 1.45; }
.inventory-toolbar-actions, .inventory-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.inventory-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.inventory-metrics span { display: flex; justify-content: space-between; gap: 12px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 10px; background: rgba(8, 17, 32, .78); color: var(--text-muted); }
.inventory-metrics strong { color: var(--text); font-size: 18px; }
.inventory-table { min-width: 980px; }
.inventory-table td, .inventory-table th { vertical-align: top; }
.inventory-table td small, .inventory-table td strong { display: block; }
.inventory-table td small { margin-top: 4px; color: var(--text-muted); }
.table-link { padding: 0; border: 0; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.table-link:hover strong { color: var(--accent); }
.inventory-ledger { display: grid; gap: 9px; }
.inventory-ledger article { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(150px, .5fr); gap: 5px 14px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 10px; background: rgba(8, 17, 32, .78); }
.inventory-ledger article div { display: grid; gap: 3px; }
.inventory-ledger article p { grid-column: 1 / -1; margin: 0; color: var(--text); }
.inventory-ledger article small, .inventory-ledger article span { color: var(--text-muted); }
.inventory-document-summary { display: grid; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: rgba(8, 17, 32, .78); }
.inventory-document-summary .badge { width: fit-content; }
.inventory-document-summary p { margin: 0; color: var(--text-muted); }
@media (max-width: 880px) {
  .inventory-toolbar { display: grid; }
  .inventory-metrics { grid-template-columns: 1fr; }
  .inventory-ledger article { grid-template-columns: 1fr; }
  .inventory-ledger article p { grid-column: auto; }
}
/* Stage 14 CRM */
.crm-shell { display: grid; gap: 16px; }
.crm-toolbar, .crm-controls, .crm-metrics, .crm-row, .crm-duplicate-card, .crm-detail-grid article, .crm-merge-grid article { background: var(--srm-surface-1, #0c1629); border: 1px solid var(--srm-border-default, #243553); border-radius: 12px; }
.crm-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px; }
.crm-toolbar h3, .crm-duplicate-card h3, .crm-detail-grid h3, .crm-merge-grid h3 { margin: 0 0 6px; color: var(--srm-text-primary, #f5f7ff); }
.crm-toolbar p, .crm-row span, .crm-duplicate-card p, .crm-merge-grid p { margin: 0; color: var(--srm-text-secondary, #9dacbf); }
.crm-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); overflow: hidden; }
.crm-metrics span { display: flex; justify-content: space-between; gap: 12px; padding: 14px 16px; color: var(--srm-text-secondary, #9dacbf); }
.crm-metrics span + span { border-left: 1px solid var(--srm-border-subtle, #1d2a43); }
.crm-metrics strong { color: var(--srm-text-primary, #f5f7ff); }
.crm-controls { display: grid; grid-template-columns: auto minmax(220px, 1fr) auto; align-items: end; gap: 14px; padding: 12px; }
.crm-search { display: grid; gap: 5px; color: var(--srm-text-secondary, #9dacbf); font-size: 12px; }
.crm-controls .check-row { display: flex; align-items: center; align-self: end; gap: 8px; min-height: 42px; padding: 0 8px; }
.crm-controls .check-row input { flex: 0 0 18px; width: 18px; height: 18px; min-width: 18px; min-height: 18px; margin: 0; accent-color: var(--srm-accent, #7167ff); }
.crm-list, .crm-duplicate-list { display: grid; gap: 10px; }
.crm-row { display: grid; grid-template-columns: minmax(220px, 1.2fr) minmax(200px, 1fr) auto; align-items: center; gap: 16px; padding: 14px 16px; cursor: pointer; transition: border-color .16s ease, background .16s ease, transform .16s ease; }
.crm-row:hover, .crm-row:focus-visible { border-color: var(--srm-accent, #7167ff); background: var(--srm-surface-2, #111d33); outline: none; transform: translateY(-1px); }
.crm-row-main, .crm-row-contact, .crm-row-status { min-width: 0; display: grid; gap: 5px; }
.crm-row-main strong { color: var(--srm-text-primary, #f5f7ff); overflow-wrap: anywhere; }
.crm-row-contact span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-row-status { justify-items: end; }
.crm-chips, .crm-role-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.crm-role-picker { gap: 16px; padding: 4px 0; }
.crm-role-picker .check-row { display: flex; align-items: center; gap: 8px; }
.crm-role-picker .check-row input { flex: 0 0 18px; width: 18px; height: 18px; min-width: 18px; min-height: 18px; margin: 0; accent-color: var(--srm-accent, #7167ff); }
.crm-chip { width: fit-content; padding: 3px 7px; border: 1px solid var(--srm-border-default, #243553); border-radius: 999px; color: var(--srm-text-secondary, #9dacbf); font-size: 11px; }
.crm-duplicate-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px; }
.crm-detail-grid, .crm-merge-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.crm-detail-grid article, .crm-merge-grid article { padding: 14px; }
.crm-timeline { display: grid; gap: 8px; margin: 10px 0; padding: 0; list-style: none; }
.crm-timeline li { padding: 9px 10px; border: 1px solid var(--srm-border-subtle, #1d2a43); border-radius: 8px; color: var(--srm-text-secondary, #9dacbf); }
.crm-timeline li div { display: flex; justify-content: space-between; gap: 10px; }
.crm-timeline strong { color: var(--srm-text-primary, #f5f7ff); }
@media (max-width: 1100px) { .crm-controls { grid-template-columns: 1fr 1fr; } .crm-controls .pricing-tabs { grid-column: 1 / -1; } .crm-row { grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr); } .crm-row-status { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; } }
@media (max-width: 600px) { .crm-toolbar, .crm-duplicate-card { align-items: stretch; flex-direction: column; } .crm-metrics, .crm-controls, .crm-row, .crm-detail-grid, .crm-merge-grid { grid-template-columns: 1fr; } .crm-metrics span + span { border-left: 0; border-top: 1px solid var(--srm-border-subtle, #1d2a43); } .crm-controls .pricing-tabs, .crm-row-status { grid-column: auto; } .crm-row-status { justify-items: stretch; } .crm-row-contact span { white-space: normal; overflow-wrap: anywhere; } }
