/* Clever components. Every value comes from tokens.css; the product is chosen by
   <html data-theme="suite-light|suite-dark|ai-light|ai-dark|map-light|map-dark">. */

body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-sans); font-size: 14px; line-height: 21px; -webkit-font-smoothing: antialiased; }
.cl-icon { flex: none; display: block; }
.cl-mark { flex: none; display: block; }
:where(.cl-btn, .cl-nav-item, .cl-tab, .cl-switch-trigger, .cl-switch-item, .cl-input, .cl-check input, .cl-toggle input):focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.cl-dot { width: 6px; height: 6px; border-radius: var(--radius-pill); background: currentColor; flex: none; }
.cl-eyebrow { margin: 0 0 6px; font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--accent-text); }

/* Button */
.cl-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); height: var(--size-control); padding: 0 14px; border-radius: var(--radius-control); border: 1px solid transparent; font: 500 13px/18px var(--font-sans); cursor: pointer; white-space: nowrap; transition: background-color .12s cubic-bezier(.2,0,0,1), border-color .12s; }
.cl-btn:disabled { opacity: .5; cursor: not-allowed; }
.cl-btn-primary { background: var(--accent); color: var(--on-accent); }
.cl-btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.cl-btn-secondary { background: var(--panel-2); color: var(--ink); border-color: var(--line-2); }
.cl-btn-secondary:hover:not(:disabled) { border-color: var(--line-3); }
.cl-btn-ghost { background: transparent; color: var(--ink-2); }
.cl-btn-ghost:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.cl-btn-soft { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-line); }
.cl-btn-danger { background: var(--err-soft); color: var(--err); border-color: var(--err-line); }
.cl-btn-sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.cl-btn-icon { width: var(--size-control); padding: 0; }
.cl-btn-sm.cl-btn-icon { width: 28px; }

/* Badge */
.cl-badge { display: inline-flex; align-items: center; gap: var(--space-1); height: 22px; padding: 0 8px; border-radius: var(--radius-pill); font: 500 12px/16px var(--font-sans); white-space: nowrap; background: var(--panel-3); color: var(--ink-2); }
.cl-badge-accent { background: var(--accent-soft); color: var(--accent-text); }
.cl-badge-ok { background: var(--ok-soft); color: var(--ok); }
.cl-badge-warn { background: var(--warn-soft); color: var(--warn); }
.cl-badge-err { background: var(--err-soft); color: var(--err); }
.cl-badge-info { background: var(--info-soft); color: var(--info); }

/* Fields */
.cl-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cl-label { font: 500 13px/18px var(--font-sans); color: var(--ink); }
.cl-input-wrap, .cl-select-wrap { position: relative; display: flex; }
.cl-input { width: 100%; box-sizing: border-box; height: var(--size-control); padding: 0 12px; border-radius: var(--radius-control); border: 1px solid var(--line-3); background: var(--panel-2); color: var(--ink); font: 400 14px/20px var(--font-sans); }
textarea.cl-input { height: auto; min-height: 84px; padding: 8px 12px; resize: vertical; }
.cl-input::placeholder { color: var(--muted); }
.cl-input:hover { border-color: var(--ink-2); }
.cl-input:focus { border-color: var(--accent-line); outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.cl-input.has-icon { padding-left: 36px; }
.cl-input.is-mono { font-family: var(--font-mono); font-size: 13px; }
.cl-input-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.cl-field.is-error .cl-input { border-color: var(--err); }
.cl-help { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 12px; line-height: 17px; color: var(--muted); }
.cl-help.is-error { color: var(--err); }
.cl-select { appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer; }
.cl-select-chev { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }

/* Checkbox & toggle */
.cl-check, .cl-toggle { position: relative; display: inline-flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 14px; line-height: 20px; color: var(--ink); }
.cl-check input, .cl-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.cl-check-box { width: 18px; height: 18px; margin-top: 1px; box-sizing: border-box; border-radius: 5px; border: 1.5px solid var(--line-3); background: var(--panel); display: grid; place-items: center; color: transparent; flex: none; }
.cl-check input:checked + .cl-check-box { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.cl-check input:focus-visible + .cl-check-box, .cl-toggle input:focus-visible + .cl-toggle-track { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.cl-check-label { display: flex; flex-direction: column; }
.cl-check-label small { font-size: 13px; line-height: 19px; color: var(--muted); }
.cl-toggle-track { width: 34px; height: 20px; margin-top: 0; box-sizing: border-box; border-radius: var(--radius-pill); background: var(--panel-3); border: 1.5px solid var(--line-3); position: relative; flex: none; transition: background-color .15s; }
.cl-toggle-thumb { position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: var(--ink-2); transition: transform .15s cubic-bezier(.2,0,0,1); }
.cl-toggle input:checked + .cl-toggle-track { background: var(--accent); border-color: var(--accent); }
.cl-toggle input:checked + .cl-toggle-track .cl-toggle-thumb { transform: translateX(14px); background: var(--on-accent); }
.is-disabled { opacity: .5; cursor: not-allowed; }

/* Tabs */
.cl-tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--line-2); }
.cl-tab { position: relative; display: inline-flex; align-items: center; gap: 6px; height: var(--size-control); padding: 0 12px; border: 0; background: none; color: var(--ink-2); font: 500 13px/18px var(--font-sans); cursor: pointer; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.cl-tab:hover { color: var(--ink); background: var(--hover); }
.cl-tab.is-active { color: var(--accent-text); }
.cl-tab.is-active::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.cl-tab-count { font: 500 11px/16px var(--font-mono); padding: 0 6px; border-radius: var(--radius-pill); background: var(--panel-3); color: var(--ink-2); }
.cl-tabs.is-segmented { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-control); padding: 3px; background: var(--panel-2); }
.cl-tabs.is-segmented .cl-tab { height: 28px; border-radius: 7px; }
.cl-tabs.is-segmented .cl-tab.is-active { background: var(--panel); color: var(--ink); box-shadow: 0 0 0 1px var(--line-2); }
.cl-tabs.is-segmented .cl-tab.is-active::after { display: none; }

/* Panel */
.cl-panel { background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--radius-card); overflow: hidden; }
.cl-panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: 14px var(--space-pad-card); border-bottom: 1px solid var(--line); }
.cl-panel-title { margin: 0; font: 600 15px/20px var(--font-sans); letter-spacing: -0.01em; color: var(--ink); }
.cl-panel-desc { margin: 2px 0 0; font-size: 13px; line-height: 19px; color: var(--muted); }
.cl-panel-actions { display: flex; gap: var(--space-2); align-items: center; }
.cl-panel-body { padding: var(--space-pad-card); }
.cl-panel.is-flush .cl-panel-body { padding: 0; }

/* Stat */
.cl-stat { background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--radius-card); padding: var(--space-pad-card); display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.cl-stat-label { display: flex; align-items: center; gap: 6px; font-size: 13px; line-height: 18px; color: var(--muted); }
.cl-stat-value { font: 500 28px/32px var(--font-mono); letter-spacing: -0.02em; color: var(--ink); font-variant-numeric: tabular-nums; }
.cl-stat-value small { font-size: 14px; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.cl-stat-note { display: flex; align-items: center; gap: 6px; font-size: 12px; line-height: 17px; color: var(--muted); }
.cl-stat-note.is-ok { color: var(--ok); } .cl-stat-note.is-warn { color: var(--warn); } .cl-stat-note.is-err { color: var(--err); } .cl-stat-note.is-accent { color: var(--accent-text); }

/* Table */
.cl-table-wrap { overflow-x: auto; }
.cl-table { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 19px; }
.cl-table caption { text-align: left; padding: 0 0 8px; color: var(--muted); font-size: 12px; }
.cl-table th { text-align: left; font: 500 12px/16px var(--font-sans); color: var(--muted); background: var(--bg-2); padding: 9px 14px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.cl-table td { padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--ink-2); vertical-align: middle; }
.cl-table tr:last-child td { border-bottom: 0; }
.cl-table tbody tr:hover td { background: var(--hover); }
.cl-table tr.is-selected td { background: var(--accent-soft); }
.cl-table td.is-primary { color: var(--ink); font-weight: 500; }
.cl-table td.is-mono { font-family: var(--font-mono); font-size: 12.5px; }
.cl-table .is-right { text-align: right; }

/* Banner */
.cl-banner { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border-radius: var(--radius-control); border: 1px solid var(--info-line); background: var(--info-soft); color: var(--ink); font-size: 13px; line-height: 19px; }
.cl-banner-icon { margin-top: 1px; color: var(--info); }
.cl-banner-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cl-banner-body strong { font-weight: 600; color: var(--ink); }
.cl-banner-body > div { color: var(--ink-2); }
.cl-banner-ok { border-color: var(--ok-line); background: var(--ok-soft); } .cl-banner-ok .cl-banner-icon { color: var(--ok); }
.cl-banner-warn { border-color: var(--warn-line); background: var(--warn-soft); } .cl-banner-warn .cl-banner-icon { color: var(--warn); }
.cl-banner-err { border-color: var(--err-line); background: var(--err-soft); } .cl-banner-err .cl-banner-icon { color: var(--err); }
.cl-banner-accent { border-color: var(--accent-line); background: var(--accent-soft); } .cl-banner-accent .cl-banner-icon { color: var(--accent-text); }

/* Dialog */
.cl-scrim { position: fixed; inset: 0; background: var(--scrim); display: grid; place-items: center; padding: var(--space-4); z-index: 50; }
.cl-dialog { width: 100%; max-width: 480px; background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--radius-card); box-shadow: var(--shadow-overlay); overflow: hidden; }
.cl-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 14px 14px var(--space-pad-card); border-bottom: 1px solid var(--line); }
.cl-dialog-body { padding: var(--space-pad-card); display: flex; flex-direction: column; gap: var(--space-4); color: var(--ink-2); }
.cl-dialog-foot { display: flex; justify-content: flex-end; gap: var(--space-2); padding: 12px var(--space-pad-card); border-top: 1px solid var(--line); background: var(--bg-2); }

/* Page header */
.cl-pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-6); flex-wrap: wrap; }
.cl-pagehead-title { margin: 0; font: 700 26px/32px var(--font-sans); letter-spacing: -0.025em; color: var(--ink); }
.cl-pagehead-desc { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.cl-pagehead-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* Product switcher */
.cl-switch { position: relative; }
.cl-switch-trigger { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px 6px 6px; border: 1px solid transparent; border-radius: var(--radius-control); background: transparent; color: var(--ink); cursor: pointer; text-align: left; }
.cl-switch-trigger:hover, .cl-switch-trigger[aria-expanded="true"] { background: var(--hover); }
.cl-switch-trigger .cl-icon { color: var(--muted); margin-left: auto; }
.cl-switch-name { display: flex; flex-direction: column; font: 600 15px/19px var(--font-sans); letter-spacing: -0.01em; min-width: 0; }
.cl-switch-name small { font: 500 10px/14px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-switch-menu { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; width: 280px; padding: 6px; background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--radius-control); box-shadow: var(--shadow-menu); }
.cl-switch-head { padding: 6px 8px 8px; font: 500 10px/14px var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.cl-switch-item { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; }
.cl-switch-item:hover { background: var(--hover); }
.cl-switch-item span { display: flex; flex-direction: column; min-width: 0; }
.cl-switch-item strong { font: 600 14px/19px var(--font-sans); }
.cl-switch-item small { font-size: 12px; line-height: 16px; color: var(--muted); }
.cl-switch-item.is-current { background: var(--accent-soft); }
.cl-switch-check { margin-left: auto; color: var(--accent-text); }

/* Sidebar */
.cl-sidebar { width: var(--size-sidebar); box-sizing: border-box; height: 100%; display: flex; flex-direction: column; gap: var(--space-4); padding: 12px 10px; background: var(--sidebar); border-right: 1px solid var(--line-2); }
.cl-sidebar-nav { display: flex; flex-direction: column; gap: var(--space-4); overflow-y: auto; }
.cl-nav-group { display: flex; flex-direction: column; gap: 2px; }
.cl-nav-label { padding: 4px 10px 6px; font: 500 10px/14px var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.cl-nav-item { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: var(--radius-sm); color: var(--ink-2); text-decoration: none; font: 500 13px/18px var(--font-sans); }
.cl-nav-item:hover { background: var(--hover); color: var(--ink); }
.cl-nav-item.is-active { background: var(--accent-soft); color: var(--accent-text); }
.cl-nav-count { margin-left: auto; font: 500 11px/16px var(--font-mono); color: var(--muted); }
.cl-nav-item.is-active .cl-nav-count { color: var(--accent-text); }
.cl-sidebar-foot { margin-top: auto; padding: 12px 10px 4px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }

@media (max-width: 700px) {
  .cl-btn, .cl-input, .cl-tab, .cl-nav-item { min-height: var(--size-touch); }
  .cl-btn-icon { width: var(--size-touch); }
}
