/* CRM Toolbox UX system — shared tokens and interface patterns. */
:root {
  --primary: #087b68;
  --brand-green: #00a88f;
  --ink: #17332d;
  --muted: #61756e;
  --border: #d9e4dd;
  --panel: #fff;
  --canvas: #f4f7f3;
  --nav: #102f28;
  --nav-hover: #204a3e;
  --surface-soft: #f8faf7;
  --ring: #9ce6d3;
  --danger: #ad332d;
  --warn: #a46717;
  --ok: #08754e;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-lift: 0 14px 36px #143d3014;
  color: var(--ink);
  background: var(--canvas);
}
body { background: var(--canvas); font-size: 14px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
button, input, select, textarea { font: inherit; }
button { transition: background .16s, border-color .16s, box-shadow .16s, transform .16s; }
button:not(:disabled):hover { filter: brightness(1.07); }
button:disabled { opacity: .58; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--ring); outline-offset: 2px;
}
input, select, textarea { border-color: #cbd9d0; border-radius: var(--radius-sm); color: var(--ink); }
input:hover, select:hover, textarea:hover { border-color: #91b3a4; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--ring); outline-offset: 1px; border-color: var(--primary); }
input::placeholder, textarea::placeholder { color: #82938c; }
.field { gap: 7px; min-width: 0; margin-bottom: 16px; }
.field label, .library-search label { color: #34564b; font-size: 12px; font-weight: 700; }
.field > small, .field > p { color: var(--muted); }
.panel { border-color: var(--border); border-radius: var(--radius-lg); padding: 22px; box-shadow: 0 1px 2px #143d3008; }
.panel h3 { color: var(--ink); letter-spacing: -.02em; }
.panel > p:first-of-type { color: var(--muted); }
.toolbar { gap: 9px; }
.secondary, button.secondary { background: #ebf3ee; color: #205a48; }
.secondary:not(:disabled):hover, button.secondary:not(:disabled):hover { background: #dceee3; }
.example-btn { background: #e1f4e9; color: #09634f; }
.danger, button.danger { background: var(--danger); }
.badge, .pill { font-weight: 650; letter-spacing: .005em; }
.pill { background: #eef4ef; color: #3b6454; border: 1px solid #e0ebe2; }
.note { background: #f2f8f3; border-color: #dcebe0; color: #456258; border-radius: var(--radius-md); line-height: 1.55; }
.access-empty { color: #58736a; border-color: #b9d3c5; background: #fbfdfb; line-height: 1.55; }
.status-state { display: flex; align-items: flex-start; gap: 11px; padding: 16px 18px; border: 1px solid #d8e7dc; border-radius: var(--radius-md); background: #f7fbf7; color: #365e4b; }
.status-state strong { display: block; font-size: 13px; }
.status-state small { display: block; margin-top: 3px; color: var(--muted); line-height: 1.45; }
.status-state.warning { background: #fffaf0; border-color: #efdfbf; color: #926020; }
.status-state.error { background: #fff6f5; border-color: #eaccca; color: #a7342f; }
.status-state.success { background: #f0faf3; border-color: #bfe2c9; color: #0e704d; }
.status-state.empty, .status-state.no-results { background: #fbfdfb; border-style: dashed; }
.status-spinner { flex: none; width: 17px; height: 17px; border: 2px solid #b8d4c0; border-top-color: var(--primary); border-radius: 50%; animation: status-spin .8s linear infinite; }
@keyframes status-spin { to { transform: rotate(360deg); } }
.issue { border-radius: var(--radius-md); background: #fff; line-height: 1.5; }
.issue strong { margin-bottom: 2px; }
.metric { border-radius: var(--radius-md); background: var(--surface-soft); }
.metric strong { color: var(--ink); }
.table-wrap { border-color: var(--border); border-radius: var(--radius-md); background: #fff; }
.table { font-size: 12.5px; }
.table th { background: #f1f6f1; color: #45675b; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; border-bottom-color: #d8e5da; }
.table td { border-bottom-color: #e7eee8; }
.table tbody tr:hover { background: #f7fbf7; }
.table tbody tr:last-child td { border-bottom: 0; }
.data-table-controls { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 9px; margin: 0 0 10px; }
.data-table-controls label { display: grid; gap: 5px; min-width: 160px; color: #45675b; font-size: 11px; font-weight: 700; }
.data-table-controls label:first-child { flex: 1 1 240px; }
.data-table-controls input, .data-table-controls select { min-height: 36px; padding: 7px 9px; font-size: 12px; }
.data-table-controls .dt-direction { min-height: 36px; }
.data-table-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0 17px; color: var(--muted); font-size: 11px; }
.data-table-footer .inline { flex-wrap: nowrap; }
.data-table-footer button { min-width: 67px; }
.data-table-footer button:disabled { opacity: .45; }
.code { background: #152b27; color: #d7efe0; border: 1px solid #294d3d; border-radius: var(--radius-md); line-height: 1.6; }
.toast { border: 1px solid #3b6853; background: #12362c; box-shadow: var(--shadow-lift); }
.modal-backdrop { background: #0a241caa; }
.modal-card { border-radius: var(--radius-lg); padding: 26px; box-shadow: 0 24px 70px #071d1b55; }
.modal-head { padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.permission-item { border-color: var(--border); border-radius: var(--radius-sm); }
.permission-item:has(input:checked) { background: #f0faf3; border-color: #9ccdb2; }

/* Shell and navigation */
.topbar { min-height: 76px; height: auto; padding: 12px 24px; gap: 16px; border-bottom: 2px solid var(--brand-green); background: #0c3027; }
.brand { gap: 12px; min-width: 0; }
.brand strong { font-size: 16px; letter-spacing: -.025em; }
.brand small { color: #a9d5c2; }
.overlabs-logo { width: 92px; height: 34px; }
.sidebar-toggle { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; flex: none; border: 1px solid #427968; border-radius: var(--radius-sm); background: #1c493b; color: #eaf8ef; font-size: 18px; line-height: 1; }
.sidebar-toggle:hover { background: #2a5e4b; }
.top-actions { gap: 8px; }
.top-actions > button { white-space: nowrap; }
.top-actions .secondary { background: #204c3e; color: #e7f3e9; border: 1px solid #41745f; }
.top-actions .secondary:hover { background: #2c624e; }
.top-actions button.secondary:not(:disabled):hover { background: #2c624e; color: #fff; }
.top-actions #mceLoginBtn { border-color: #78bd9b; color: #fff; font-weight: 700; }
.top-actions #mceLoginBtn:disabled { opacity: .55; }
.mce-login-settings { display: grid; gap: 12px; margin: 18px 0; }
.mce-login-setting { display: grid; grid-template-columns: minmax(145px, 210px) minmax(260px, 1fr) auto; gap: 14px; align-items: end; padding: 14px; border: 1px solid #d5e6df; border-radius: 10px; background: #f9fcfa; }
.mce-login-setting strong,.mce-login-setting small { display: block; }
.mce-login-setting small { margin-top: 5px; color: #58746c; }
.mce-login-setting .field { margin: 0; }
.mce-login-setting button { min-height: 40px; }
@media(max-width:760px){.mce-login-setting{grid-template-columns:1fr}.mce-login-setting button{justify-self:start}}
.bu-field { min-width: 180px; max-width: 250px; }
.bu-field label { color: #a9d5c2; }
.bu-field select { background: #fafffa; }
.user-badge { color: #d6eadb; max-width: 150px; }
.shell { grid-template-columns: 264px minmax(0,1fr); min-height: calc(100vh - 122px); }
.sidebar { position: sticky; top: 76px; height: calc(100vh - 76px); overflow-y: auto; padding: 20px 12px 26px; background: var(--nav); scrollbar-width: thin; scrollbar-color: #447363 transparent; }
.sidebar-heading { display: flex; justify-content: space-between; align-items: center; padding: 0 10px 12px; color: #f2fff5; font-weight: 750; letter-spacing: -.01em; }
.sidebar-heading span:last-child { color: #9ed7bc; font-size: 11px; font-weight: 650; }
.menu-search { width: 100%; margin-bottom: 12px; background: #1a4034; border-color: #3a6e58; color: #f5fff6; }
.menu-search::placeholder { color: #a3c7b5; }
.nav-group { margin: 10px 0 14px; }
.menu-group { display: flex; justify-content: space-between; gap: 6px; padding: 13px 10px 7px; color: #8fbda4; font-size: 10px; letter-spacing: .09em; border-top: 1px solid #2b5142; }
.menu-group span:last-child { color: #7fa88f; }
.menu-item { align-items: center; min-height: 42px; padding: 7px 9px; margin: 1px 0; gap: 9px; border-radius: var(--radius-sm); color: #d4e9da; }
.menu-item:hover { background: var(--nav-hover); }
.menu-item.active { background: #235a47; box-shadow: inset 3px 0 var(--brand-green); color: #fff; }
.tool-icon, .group-mark { display: grid; place-items: center; flex: none; min-width: 27px; width: 27px; height: 27px; padding: 1px; border-radius: 7px; background: #275b47; color: #adf0c9; font: 800 9px/1 ui-sans-serif,system-ui,sans-serif; letter-spacing: -.03em; }
.nav-label { display: block; min-width: 0; }
.nav-label strong { display: block; font-size: 11.5px; font-weight: 650; line-height: 1.25; }
.menu-capability { margin-top: 3px; color: #92bba4; font-size: 10px; line-height: 1.25; }
.nav-empty { padding: 16px 10px; color: #abcab6; font-size: 12px; }
.main { width: 100%; max-width: 1640px; min-width: 0; padding: 28px clamp(18px,2.6vw,42px) 42px; }
.app-footer { display: flex; justify-content: center; align-items: center; gap: 8px; padding: 10px 16px; background: #0c3027; color: #c6e2d2; border-top: 1px solid #2e5947; font-size: 11px; }
.app-footer .app-version { color: #85e7b3; }
.sidebar-collapsed .shell { grid-template-columns: 60px minmax(0,1fr); }
.sidebar-collapsed .sidebar { padding: 14px 5px; }
.sidebar-collapsed .sidebar-heading, .sidebar-collapsed .menu-search, .sidebar-collapsed .menu-group, .sidebar-collapsed .nav-label { display: none; }
.sidebar-collapsed .nav-group { margin: 0 0 10px; }
.sidebar-collapsed .menu-item { justify-content: center; padding: 7px 0; }
.sidebar-collapsed .tool-icon { width: 32px; height: 32px; }
.admin-mode .shell { grid-template-columns: minmax(0,1fr); }
.admin-mode .sidebar, .admin-mode .sidebar-toggle { display: none; }
.admin-mode .main { max-width: 1640px; margin: 0 auto; }

/* Dashboard library */
.hero { display: flex; align-items: flex-end; justify-content: space-between; min-height: 202px; padding: 30px 34px; border-radius: var(--radius-lg); border: 1px solid #d2e4d5; background: radial-gradient(circle at 92% 16%,#b8e9ca 0,transparent 30%), linear-gradient(130deg,#fbfdf9 0,#e9f3e9 100%); }
.hero h1 { max-width: 670px; margin: 9px 0 10px; font-size: clamp(28px,3.1vw,40px); line-height: 1.12; letter-spacing: -.045em; color: #12392c; }
.hero p { max-width: 610px; margin: 0; color: #537268; font-size: 14px; line-height: 1.5; }
.eyebrow { color: #177b5c; font-size: 10px; letter-spacing: .11em; }
.eyebrow-dot { padding: 0 4px; color: #86ae96; }
.hero-count { display: flex; align-items: center; gap: 12px; min-width: 170px; padding-left: 20px; border-left: 1px solid #adcdb9; }
.hero-count strong { font-size: 50px; line-height: 1; letter-spacing: -.07em; color: #176d50; }
.hero-count span { color: #527363; font-size: 11px; line-height: 1.4; }
.library-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 30px 0 20px; }
.library-head h2 { margin: 5px 0 2px; font-size: 24px; letter-spacing: -.035em; }
.library-head p { margin: 0; color: var(--muted); font-size: 12px; }
.library-search { display: grid; gap: 6px; width: min(100%,310px); }
.library-search input { background: #fff; }
#dashboardResults { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-items: start; gap: 22px; }
#dashboardResults > .access-empty { grid-column: 1/-1; }
.library-group { min-width: 0; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: 0 1px 2px #143d3008; }
.library-group-head { display: flex; align-items: center; gap: 10px; padding: 17px 18px 14px; background: #f8fbf7; border-bottom: 1px solid #e5ede5; }
.library-group-head .group-mark { width: 38px; height: 38px; background: #dcefe2; color: #176c4f; font-size: 11px; }
.library-group-head h3 { margin: 0; font-size: 14px; line-height: 1.25; }
.library-group-head small { color: var(--muted); font-size: 11px; }
.library-list { display: grid; }
.library-tool { display: flex; width: 100%; min-height: 68px; align-items: center; justify-content: space-between; gap: 12px; text-align: left; border: 0; border-bottom: 1px solid #edf1ed; border-radius: 0; background: #fff; color: var(--ink); padding: 12px 18px; }
.library-tool:last-child { border-bottom: 0; }
.library-tool:hover { background: #f3faf4; filter: none; }
.library-tool-main { display: grid; gap: 3px; min-width: 0; }
.library-tool-main strong { font-size: 12.5px; font-weight: 750; }
.library-tool-main small { color: var(--muted); font-size: 11px; line-height: 1.4; font-weight: 450; }
.library-tool-side { display: flex; align-items: center; gap: 10px; flex: none; }
.library-tool-side .pill { font-size: 10px; white-space: nowrap; }
.library-arrow { color: #3d8b65; font-size: 18px; }

/* Workspaces, technical controls and administration */
.workspace-head { display: flex; gap: 16px; padding: 2px 0 22px; margin-bottom: 22px; border-bottom: 1px solid var(--border); }
.workspace-head h1 { margin: 6px 0 7px; color: #173a2b; font-size: clamp(24px,2.2vw,32px); letter-spacing: -.04em; line-height: 1.14; }
.workspace-head p { color: var(--muted); font-size: 13px; line-height: 1.5; }
.workspace-actions { justify-content: flex-end; }
.workspace-actions button { white-space: nowrap; }
.capabilities { margin-top: 13px; gap: 5px; }
.admin-tabs { gap: 4px; flex-wrap: nowrap; max-width: 100%; overflow-x: auto; padding: 0 0 1px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.admin-tabs button { flex: none; border-radius: 8px 8px 0 0; background: transparent; color: #517065; border-bottom: 3px solid transparent; padding: 10px 13px; }
.admin-tabs button:hover { background: #eaf4eb; }
.admin-tabs button.active { background: #e5f4e9; color: #0d6b4f; border-bottom-color: var(--brand-green); }
.admin-user-row { border-bottom-color: #e8eee8; }
.admin-user-row.header { background: #f2f7f2; color: #496457; }
.feedback-card { border-color: var(--border); }

/* Representative editor / result pattern */
.sql-workbench { padding: 0; overflow: hidden; }
.sql-workbench.is-expanded { position: fixed; inset: 20px; z-index: 70; display: flex; flex-direction: column; overflow: auto; margin: 0; box-shadow: 0 25px 70px #09251e55; }
.sql-workbench.is-expanded .workbench-sides { flex: 1; }
.workbench-intro { display: flex; justify-content: space-between; gap: 18px; align-items: center; padding: 19px 22px; border-bottom: 1px solid var(--border); background: #f8fbf7; }
.workbench-intro h3 { margin: 3px 0 2px; font-size: 17px; }
.workbench-intro p { margin: 0; font-size: 12px; color: var(--muted); }
.workbench-intro button { flex: none; }
.workbench-sides { display: grid; grid-template-columns: 1fr 1fr; min-height: 440px; }
.workbench-pane { min-width: 0; display: flex; flex-direction: column; }
.workbench-pane + .workbench-pane { border-left: 1px solid var(--border); }
.workbench-pane-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.workbench-pane-head strong { font-size: 12px; }
.workbench-pane-head small { color: var(--muted); font-size: 10px; }
.workbench-pane textarea { display: block; width: calc(100% - 36px); min-height: 295px; flex: 1; margin: 18px; padding: 17px; border: 1px solid #cbdad0; background: #fbfdfb; color: #203c32; font-size: 12px; line-height: 1.65; tab-size: 2; }
.workbench-output { flex: 1; margin: 18px; min-height: 295px; overflow: auto; }
.workbench-output.empty { display: grid; place-items: center; background: #f8faf7; border: 1px dashed #bfd5c4; color: #718d7a; font: 12px/1.5 ui-sans-serif,system-ui,sans-serif; text-align: center; }
.workbench-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-height: 69px; padding: 12px 18px; border-top: 1px solid var(--border); background: #f8fbf7; }
.workbench-actions button { white-space: nowrap; }
.workbench-actions .spacer { flex: 1; }
.workbench-actions .secondary { background: #e7f2e9; }
.sa-setup, #toolRoot > .panel { scroll-margin-top: 100px; }
.sa-setup { border-top: 3px solid #38ae77; }
.sa-setup-options { background: #f8fbf8; border: 1px solid #e3ede4; border-radius: var(--radius-md); padding: 10px; }
.sa-review-item { border-color: var(--border); }
.sa-stage > .eyebrow { margin-bottom: 7px; }
.sa-stage > h3 { margin-bottom: 12px; }
.sa-stage .workspace-actions { justify-content: flex-start; margin-bottom: 14px; }
.sa-stage .workspace-actions h3 { margin-right: auto !important; }
.advanced-section { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 13px; }
.advanced-section summary { cursor: pointer; color: #15694d; font-size: 12px; font-weight: 750; }
.advanced-section[open] summary { margin-bottom: 13px; }
.advanced-section .field { max-width: 450px; margin-bottom: 0; }
.processing-state { padding: 12px 14px; color: #557164; background: #f5faf5; border: 1px solid #deebe1; border-radius: var(--radius-sm); }
.data360-guide-disclosure { margin: 0 0 16px; }
.data360-guide-disclosure > summary { cursor: pointer; padding: 13px 17px; border: 1px solid var(--border); border-radius: var(--radius-md); background: #f8fbf8; color: #22654b; font-size: 12px; font-weight: 750; }
.data360-guide-disclosure[open] > summary { margin-bottom: 12px; }

@media (max-width: 1180px) {
  .topbar { padding: 10px 18px; flex-wrap: nowrap; }
  .brand small, .top-actions .badge, .user-badge { display: none; }
  .top-actions { justify-content: flex-start; }
  .shell { grid-template-columns: 228px minmax(0,1fr); }
  .library-tool-side .pill { display: none; }
  .workspace-head { flex-wrap: wrap; }
  .workspace-actions { justify-content: flex-start; }
}
@media (max-width: 900px) {
  .topbar { position: sticky; top: 0; flex-wrap: wrap; }
  .shell { display: block; position: relative; }
  .sidebar { position: absolute; top: 0; left: 0; z-index: 19; width: min(320px,100%); height: min(72vh,610px); max-height: none; border: 1px solid #315a46; border-top: 0; border-radius: 0 0 14px 0; box-shadow: 12px 20px 36px #0c302733; }
  .sidebar-collapsed .shell { grid-template-columns: minmax(0,1fr); }
  .sidebar-collapsed .sidebar { display: none; }
  .sidebar:not(.hidden) .sidebar-heading, .sidebar:not(.hidden) .menu-search, .sidebar:not(.hidden) .menu-group, .sidebar:not(.hidden) .nav-label { display: revert; }
  .sidebar:not(.hidden) .sidebar-heading { display: flex; }
  .sidebar:not(.hidden) .menu-group { display: flex; }
  .sidebar:not(.hidden) .menu-item { justify-content: flex-start; padding: 7px 9px; }
  .main { padding: 22px 20px 38px; }
  #dashboardResults { grid-template-columns: 1fr; }
  .workbench-sides { grid-template-columns: 1fr; }
  .workbench-pane + .workbench-pane { border-left: 0; border-top: 1px solid var(--border); }
}
@media (max-width: 680px) {
  .topbar { padding: 9px 14px; gap: 10px; }
  .overlabs-logo { width: 72px; }
  .brand strong { font-size: 14px; }
  .top-actions { width: 100%; gap: 7px; }
  .bu-field { flex: 1 1 190px; min-width: 160px; }
  .top-actions .badge { display: none; }
  .top-actions button { min-height: 36px; padding: 7px 9px; }
  .main { padding: 18px 14px 30px; }
  .hero { min-height: 0; display: block; padding: 23px; }
  .hero h1 { font-size: 29px; }
  .hero-count { margin-top: 23px; padding: 14px 0 0; border-left: 0; border-top: 1px solid #adcdb9; }
  .hero-count strong { font-size: 40px; }
  .library-head { display: grid; margin-top: 25px; }
  .library-search { width: 100%; }
  .library-tool { padding: 12px 14px; }
  .library-tool-side { gap: 0; }
  .workspace-head { padding-bottom: 17px; }
  .workspace-actions { width: 100%; }
  .workspace-actions button { flex: 1; }
  .panel { padding: 16px; }
  .workbench-intro { padding: 16px; }
  .workbench-intro { align-items: flex-start; flex-direction: column; }
  .sql-workbench.is-expanded { inset: 8px; }
  .workbench-pane textarea, .workbench-output { margin: 12px; width: calc(100% - 24px); min-height: 230px; }
  .metric-row { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .modal-card { padding: 17px; }
}
@media (prefers-reduced-motion: reduce) { *,*::before,*::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
