/*
 * Canonical dashboard design-system components (.sg-*).
 * SINGLE SOURCE OF TRUTH — do not fork these styles into individual dashboards.
 * Documented/demoed by dashboards/style-guide.html; consumed by conformant dashboards.
 * Depends on tokens (var(--bg-primary), --border-color, --radius-*, etc.) from css/styles.css,
 * so link order must be: styles.css -> layout.css -> style-guide.css.
 */
        /* ── Style Guide page-specific layout ── */
        .sg-section {
            background: var(--bg-primary);
            border: 1px solid var(--border-color);
            border-radius: 12px;
            padding: 20px;
            margin-bottom: 16px;
        }
        .sg-section h2 {
            margin: 0 0 14px;
            font-size: 1.1rem;
            font-weight: 700;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .sg-section h3 {
            margin: 18px 0 10px;
            font-size: 0.95rem;
            font-weight: 700;
        }
        /* Direct-child only: section body copy. Must NOT reach into nested
           component paragraphs (e.g. .kpi-value/.kpi-label inside a card), which
           carry their own sizing/colour — a descendant selector here (0,1,1) would
           outrank a component's single-class rule (0,1,0) and clobber it. */
        .sg-section > p {
            color: var(--text-secondary);
            font-size: 0.88rem;
            line-height: 1.55;
            max-width: 80ch;
        }
        .sg-section > p + p { margin-top: 6px; }

        /* Color swatches */
        .sg-color-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
            gap: 12px;
            margin-top: 12px;
        }
        .sg-swatch {
            border: 1px solid var(--border-color);
            border-radius: 10px;
            overflow: hidden;
        }
        .sg-swatch-color {
            height: 56px;
        }
        .sg-swatch-info {
            padding: 8px 10px;
            font-size: 0.78rem;
        }
        .sg-swatch-label {
            font-weight: 700;
            color: var(--text-primary);
            margin-bottom: 2px;
        }
        .sg-swatch-hex {
            font-family: monospace;
            color: var(--text-secondary);
        }

        /* Token table */
        .sg-token-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 0.84rem;
            margin-top: 10px;
        }
        .sg-token-table th {
            text-align: left;
            padding: 8px 12px;
            background: color-mix(in srgb, #7c5cf8 7%, white);
            color: color-mix(in srgb, #7c5cf8 75%, black);
            font-weight: 700;
            font-size: 0.82rem;
        }
        .sg-token-table td {
            padding: 8px 12px;
            border-top: 1px solid var(--border-color);
            color: var(--text-primary);
        }
        .sg-token-table code {
            font-family: monospace;
            background: rgba(124, 92, 248, 0.08);
            border: 1px solid rgba(124, 92, 248, 0.18);
            color: #7c5cf8;
            padding: 1px 6px;
            border-radius: 4px;
            font-size: 0.82rem;
        }

        /* Live component demos */
        .sg-demo {
            margin: 12px 0;
            padding: 16px;
            border: 1px solid var(--border-color);
            border-radius: 10px;
            background: var(--bg-primary);
        }
        .sg-demo-label {
            font-size: 0.72rem;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.04em;
            color: var(--text-secondary);
            margin-bottom: 10px;
        }
        .sg-demo-row {
            display: flex;
            gap: 12px;
            flex-wrap: wrap;
            align-items: center;
        }

        /* Summary card demos */
        .sg-card-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
            gap: 12px;
            margin-top: 12px;
        }
        .sg-summary-card {
            --group-color: #94a3b8;
            border-radius: 12px;
            padding: 16px;
            text-align: left;
            background: color-mix(in srgb, var(--group-color) 7%, var(--bg-primary, #fff));
            border: 1px solid color-mix(in srgb, var(--group-color) 18%, var(--bg-primary, #fff));
            border-bottom: 3px solid var(--group-color);
            transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
        }
        .sg-summary-card:hover {
            background: color-mix(in srgb, var(--group-color) 12%, var(--bg-primary, #fff));
            border-color: color-mix(in srgb, var(--group-color) 35%, var(--bg-primary, #fff));
            box-shadow: 0 2px 8px rgba(0,0,0,0.06);
        }
        .sg-summary-icon {
            width: 28px;
            height: 28px;
            flex-shrink: 0;
            margin-bottom: 6px;
        }
        .sg-summary-icon svg {
            width: 100%;
            height: 100%;
        }
        .sg-summary-count {
            font-size: 1.7rem;
            font-weight: 800;
            line-height: 1;
            color: var(--group-color, var(--text-primary));
        }
        .sg-summary-label {
            font-size: 0.72rem;
            font-weight: 600;
            color: var(--text-secondary);
            text-transform: uppercase;
            letter-spacing: 0.04em;
            margin-top: 4px;
        }

        /* Pill demos */
        .sg-pill {
            display: inline-flex;
            align-items: center;
            padding: 6px 14px;
            font-size: 0.82rem;
            font-weight: 600;
            border-radius: 8px;
            border: 1px solid var(--border-color);
            background: var(--bg-secondary);
            color: var(--text-primary);
            transition: all 0.15s ease;
            cursor: pointer;
        }
        .sg-pill-active {
            background: #7c5cf8;
            border-color: #7c5cf8;
            color: #fff;
        }
        .sg-pill-category {
            border-radius: 8px;
        }
        .sg-meta-pill {
            padding: 4px 12px;
            border-radius: 999px;
            font-size: 0.78rem;
        }

        /* Button demos */
        .sg-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 8px 18px;
            border-radius: 8px;
            font-size: 0.85rem;
            font-weight: 600;
            cursor: pointer;
            border: 1px solid;
            transition: all 0.15s ease;
            line-height: 1;
        }
        .sg-btn-primary {
            background: #7c5cf8;
            border-color: #7c5cf8;
            color: #fff;
        }
        .sg-btn-primary:hover {
            background: #6d4ee5;
            border-color: #6d4ee5;
        }
        .sg-btn-secondary {
            background: var(--bg-secondary);
            border-color: var(--border-color);
            color: var(--text-primary);
        }
        .sg-btn-secondary:hover {
            border-color: #7c5cf8;
            background: rgba(124, 92, 248, 0.06);
        }

        /* Filter bar demo (Feedback Analysis canon) */
        .sg-filterbar {
            display: block;
            width: 100%;
            border: 1px solid #d7e2ee;
            border-radius: 12px;
            background: rgba(255, 255, 255, 0.97);
            box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
            padding: 0.65rem 0.8rem;
        }
        .sg-filterbar-row {
            display: grid;
            grid-template-columns: minmax(0, 1fr) auto;
            align-items: end;
            column-gap: 0.55rem;
            row-gap: 0.45rem;
            width: 100%;
        }
        .sg-filterbar-wrap {
            display: flex;
            align-items: center;
            gap: 0.45rem;
            flex-wrap: wrap;
            padding: 0.22rem 0.4rem;
            border: 1px solid #bfdbfe;
            background: #eff6ff;
            border-radius: 10px;
            min-width: 0;
        }
        .sg-filterbar-label {
            color: #1e3a8a;
            font-size: 0.78rem;
            font-weight: 700;
            margin: 0;
            white-space: nowrap;
        }
        .sg-filterbar-select,
        .sg-filterbar-input {
            border: 1px solid #cbd5e1;
            border-radius: 8px;
            background: #ffffff;
            color: #0f172a;
            font-weight: 600;
            padding: 0.35rem 0.55rem;
            font-size: 0.82rem;
            min-height: 32px;
        }
        .sg-filterbar-select {
            min-width: 9rem;
        }
        .sg-filterbar-input {
            min-width: 16rem;
            width: 100%;
        }
        .sg-filterbar-select:focus-visible,
        .sg-filterbar-input:focus-visible {
            outline: 2px solid #2563eb;
            outline-offset: 2px;
        }
        .sg-filterbar-pills {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
        }
        @media (max-width: 900px) {
            .sg-filterbar-row {
                grid-template-columns: minmax(0, 1fr);
            }
            .sg-filterbar-input {
                min-width: 0;
            }
        }

        /* Group header demo */
        .sg-group-header {
            border-radius: 10px;
            padding: 10px 16px;
            display: flex;
            align-items: center;
            gap: 10px;
            font-size: 0.95rem;
            font-weight: 700;
        }
        .sg-group-icon {
            width: 22px;
            height: 22px;
            flex-shrink: 0;
        }
        .sg-group-icon svg {
            width: 100%;
            height: 100%;
        }
        .sg-group-badge {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-width: 22px;
            height: 20px;
            padding: 0 7px;
            border-radius: 999px;
            color: #fff;
            font-size: 0.75rem;
            font-weight: 700;
        }

        /* Banner demos */
        .sg-banner-amber {
            border-radius: 12px;
            background: rgba(234, 179, 8, 0.06);
            border: 1px solid rgba(234, 179, 8, 0.35);
            padding: 20px;
        }
        .sg-banner-amber h4 {
            margin: 0;
            font-size: 1rem;
            font-weight: 700;
            color: #92400e;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .sg-banner-accent {
            border-radius: 12px;
            padding: 20px;
            border-left: 4px solid;
        }

        /* Code block */
        .sg-code {
            margin: 10px 0;
            padding: 14px 16px;
            background: #1e1e2e;
            color: #cdd6f4;
            border-radius: 8px;
            font-family: monospace;
            font-size: 0.82rem;
            line-height: 1.65;
            overflow-x: auto;
            white-space: pre;
        }
        .sg-code .c { color: #6c7086; }
        .sg-code .p { color: #cba6f7; }
        .sg-code .v { color: #a6e3a1; }
        .sg-code .n { color: #f9e2af; }

        /* ── Enhanced Table: sortable, resizable, collapsible ── */
        .sg-table-group {
            border-radius: 10px;
            overflow: hidden;
            margin: 12px 0;
            border: 1px solid var(--border-color);
        }
        .sg-table-group-header {
            padding: 10px 16px;
            display: flex;
            align-items: center;
            gap: 10px;
            font-weight: 700;
            font-size: 0.95rem;
            cursor: pointer;
            user-select: none;
        }
        .sg-table-group-header:hover { filter: brightness(0.97); }
        .sg-table-group-header .sg-collapse-icon {
            font-size: 0.7rem;
            transition: transform 0.2s ease;
            display: inline-block;
        }
        .sg-table-group.sg-collapsed .sg-collapse-icon { transform: rotate(-90deg); }
        .sg-table-group.sg-collapsed .sg-table-group-body { display: none; }
        .sg-table-enhanced {
            width: 100%;
            border-collapse: collapse;
            font-size: 0.84rem;
        }
        .sg-table-enhanced th {
            position: relative;
            text-align: left;
            padding: 8px 14px;
            font-weight: 700;
            font-size: 0.82rem;
            cursor: pointer;
            user-select: none;
            white-space: nowrap;
        }
        .sg-table-enhanced th .sg-sort-icon { margin-left: 4px; opacity: 0.35; font-size: 0.7rem; }
        .sg-table-enhanced th.sg-sort-asc .sg-sort-icon,
        .sg-table-enhanced th.sg-sort-desc .sg-sort-icon { opacity: 1; }
        .sg-table-enhanced th .sg-resize-handle {
            position: absolute;
            right: 0; top: 4px; bottom: 4px;
            width: 4px; border-radius: 2px;
            cursor: col-resize;
            background: transparent;
            transition: background 0.15s;
        }
        .sg-table-enhanced th .sg-resize-handle:hover,
        .sg-table-enhanced th .sg-resize-handle.sg-resizing { background: rgba(124,92,248,0.35); }
        .sg-table-enhanced tbody tr { transition: background 0.1s; }
        .sg-table-enhanced tbody tr:hover { background: rgba(0,0,0,0.02); }
        .sg-table-enhanced tbody td {
            padding: 9px 14px;
            border-top: 1px solid color-mix(in srgb, var(--table-accent) 12%, white);
            color: var(--text-primary);
            font-size: 0.84rem;
        }
        .sg-table-enhanced tbody td:first-child {
            border-left: 3px solid color-mix(in srgb, var(--table-accent) 30%, white);
            padding-left: 20px;
        }
        .sg-table-enhanced tbody td:last-child {
            border-right: 3px solid color-mix(in srgb, var(--table-accent) 30%, white);
            padding-right: 20px;
        }
        .sg-table-enhanced tbody tr:last-child td:first-child { border-bottom-left-radius: 8px; }
        .sg-table-enhanced tbody tr:last-child td:last-child { border-bottom-right-radius: 8px; }
        .sg-table-show-more {
            text-align: center;
            padding: 10px;
            font-size: 0.82rem;
            color: var(--text-secondary);
            border-top: 1px solid color-mix(in srgb, var(--table-accent) 10%, white);
        }
        .sg-table-show-more a {
            color: var(--accent-color, #7c5cf8);
            text-decoration: none;
            cursor: pointer;
        }
        .sg-table-show-more a:hover { text-decoration: underline; }

        /* Spacing demos */
        .sg-spacing-row {
            display: flex;
            gap: 16px;
            flex-wrap: wrap;
            margin-top: 10px;
        }
        .sg-spacing-box {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 6px;
        }
        .sg-spacing-visual {
            background: rgba(124, 92, 248, 0.12);
            border: 1px solid rgba(124, 92, 248, 0.3);
            border-radius: 4px;
        }
        .sg-spacing-label {
            font-size: 0.72rem;
            color: var(--text-secondary);
            font-weight: 600;
        }

        /* Typography demos */
        .sg-type-sample {
            margin: 6px 0;
            color: var(--text-primary);
        }

        .page-breadcrumb { margin: 0 0 10px 0; font-size: 0.85rem; color: var(--text-secondary); }
        .page-breadcrumb a { color: var(--accent-color); text-decoration: none; }
        .page-breadcrumb a:hover { text-decoration: underline; }
        .page-breadcrumb .sep { margin: 0 6px; color: var(--text-muted); }
