/* ============================================================
   Variables — Material Design 3 / Android Monet palette
   ============================================================ */
:root {
    --bg: #FFFFFF;
    --surface: #F8F8F8;
    --surface-2: #F2F2F2;
    --surface-3: #ECECEC;
    --outline: rgba(0, 0, 0, 0.08);
    --outline-strong: rgba(0, 0, 0, 0.16);

    --on-bg: #1A1A1A;
    --on-surface: #1A1A1A;
    --on-surface-variant: #48484A;
    --on-surface-muted: #8E8E93;

    --primary: #1A1A1A;
    --on-primary: #FFFFFF;

    --success: #2E7D32;
    --success-surface: #F1F8F1;
    --warning: #B26A00;
    --warning-surface: #FFF8E1;
    --danger: #C62828;
    --danger-surface: #FFF0F0;
    --info: #0277BD;
    --info-surface: #E8F4FA;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.06);

    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

    --dur-fast: 120ms;
    --dur-med: 240ms;
    --dur-slow: 400ms;
}

/* ============================================================
   Reset
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--on-bg);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
button { font-family: inherit; border: none; background: none; cursor: pointer; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }

/* ============================================================
   App shell
   ============================================================ */
.app-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    background: var(--bg);
    border-right: 1px solid var(--outline);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px 24px;
}

.brand-mark {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: var(--radius-md);
    position: relative;
    flex-shrink: 0;
}
.brand-mark::after {
    content: '';
    position: absolute;
    inset: 8px;
    border: 1.5px solid var(--on-primary);
    border-radius: 4px;
}

.brand-title {
    display: block;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.brand-subtitle {
    display: block;
    font-size: 12px;
    color: var(--on-surface-muted);
    margin-top: 1px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 450;
    color: var(--on-surface-variant);
    transition: background var(--dur-fast) var(--ease-out),
                color var(--dur-fast) var(--ease-out);
    position: relative;
    text-align: left;
    width: 100%;
}
.nav-item:hover {
    background: var(--surface);
    color: var(--on-surface);
}
.nav-item.active {
    background: var(--surface-2);
    color: var(--on-surface);
    font-weight: 550;
}
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    background: var(--primary);
    border-radius: 0 2px 2px 0;
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-badge {
    margin-left: auto;
    font-size: 12px;
    font-weight: 500;
    color: var(--on-surface-muted);
    min-width: 22px;
    text-align: center;
    padding: 2px 6px;
    background: var(--surface-2);
    border-radius: 10px;
}

.nav-chip {
    margin-left: auto;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--on-surface-muted);
    padding: 2px 6px;
    background: var(--surface-2);
    border-radius: 6px;
}

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--outline);
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 12px;
    color: var(--on-surface-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--on-surface-muted);
    transition: background var(--dur-med) var(--ease-out);
}
.connection-status.connected .status-dot { background: var(--success); }
.connection-status.connected .status-text { color: var(--success); }
.connection-status.error .status-dot { background: var(--danger); }
.connection-status.error .status-text { color: var(--danger); }

/* Main content */
.main-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 32px;
    border-bottom: 1px solid var(--outline);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(12px);
    background: rgba(255, 255, 255, 0.85);
}

.topbar-title {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.015em;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Views */
.views-container {
    flex: 1;
    padding: 28px 32px 48px;
    position: relative;
    overflow: hidden;
}

.view {
    display: none;
    animation: viewEnter var(--dur-slow) var(--ease-out);
}
.view.active { display: block; }

@keyframes viewEnter {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.view-header {
    margin-bottom: 24px;
}
.view-description {
    color: var(--on-surface-muted);
    font-size: 14px;
    max-width: 640px;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    transition: background var(--dur-fast) var(--ease-out),
                transform var(--dur-fast) var(--ease-out),
                box-shadow var(--dur-fast) var(--ease-out);
    white-space: nowrap;
    height: 36px;
}
.btn:active { transform: scale(0.98); }
.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--primary);
    color: var(--on-primary);
}
.btn-primary:hover:not(:disabled) {
    background: #2A2A2A;
    box-shadow: var(--shadow-sm);
}

.btn-secondary {
    background: var(--surface-2);
    color: var(--on-surface);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--surface-3);
}

.btn-ghost {
    background: transparent;
    color: var(--on-surface-variant);
}
.btn-ghost:hover:not(:disabled) {
    background: var(--surface);
    color: var(--on-surface);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
}
.btn-danger:hover:not(:disabled) {
    background: var(--danger-surface);
}

.icon-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--on-surface-variant);
    transition: background var(--dur-fast) var(--ease-out),
                color var(--dur-fast) var(--ease-out);
}
.icon-btn:hover { background: var(--surface-2); color: var(--on-surface); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.spinning svg {
    animation: spin 800ms linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   Lists
   ============================================================ */
.list-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.list-item {
    background: var(--bg);
    border: 1px solid var(--outline);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color var(--dur-med) var(--ease-out),
                box-shadow var(--dur-med) var(--ease-out);
}
.list-item:hover {
    border-color: var(--outline-strong);
    box-shadow: var(--shadow-sm);
}

.list-item-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    cursor: pointer;
    user-select: none;
}

.list-item-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.list-item-icon svg {
    width: 20px;
    height: 20px;
    color: var(--on-surface-variant);
}

.list-item-info { flex: 1; min-width: 0; }
.list-item-title {
    font-size: 14px;
    font-weight: 550;
    letter-spacing: -0.01em;
    margin-bottom: 2px;
}
.list-item-subtitle {
    font-size: 12px;
    color: var(--on-surface-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.list-item-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.list-item-chevron {
    width: 20px;
    height: 20px;
    color: var(--on-surface-muted);
    transition: transform var(--dur-med) var(--ease-out);
}
.list-item.expanded .list-item-chevron {
    transform: rotate(90deg);
}

.list-item-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--dur-slow) var(--ease-in-out);
}
.list-item.expanded .list-item-body {
    max-height: 2000px;
}
.list-item-body-inner {
    padding: 0 20px 20px;
    border-top: 1px solid var(--outline);
    margin: 0 16px;
    padding-top: 16px;
}

/* ============================================================
   Status chips & badges
   ============================================================ */
.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 550;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.status-chip::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.status-chip.success { background: var(--success-surface); color: var(--success); }
.status-chip.warning { background: var(--warning-surface); color: var(--warning); }
.status-chip.danger  { background: var(--danger-surface);  color: var(--danger);  }
.status-chip.info    { background: var(--info-surface);    color: var(--info);    }
.status-chip.muted   { background: var(--surface-2);       color: var(--on-surface-muted); }

/* Pulsing dot for active states */
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.5; transform: scale(1.2); }
}
.status-chip.active::before {
    animation: pulse 2s var(--ease-in-out) infinite;
}

/* ============================================================
   Detail sections
   ============================================================ */
.detail-section {
    margin-bottom: 16px;
}
.detail-section:last-child { margin-bottom: 0; }

.detail-label {
    font-size: 11px;
    font-weight: 550;
    color: var(--on-surface-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}

.detail-value {
    font-size: 14px;
    color: var(--on-surface);
    word-break: break-word;
}
.detail-value.mono {
    font-family: 'SF Mono', Menlo, Monaco, Consolas, monospace;
    font-size: 12.5px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.code-block {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    font-family: 'SF Mono', Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    line-height: 1.6;
    overflow-x: auto;
    color: var(--on-surface);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
}

.actions-row {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    flex-wrap: wrap;
}

/* ============================================================
   Skeletons
   ============================================================ */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--surface) 0%,
        var(--surface-2) 50%,
        var(--surface) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.4s var(--ease-in-out) infinite;
    border-radius: var(--radius-sm);
}
@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-list-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--bg);
    border: 1px solid var(--outline);
    border-radius: var(--radius-lg);
    margin-bottom: 8px;
}
.skeleton-avatar { width: 40px; height: 40px; border-radius: var(--radius-md); }
.skeleton-lines { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.skeleton-line { height: 10px; }
.skeleton-line.short { width: 35%; }
.skeleton-line.long { width: 65%; }

/* ============================================================
   Forms & Inputs
   ============================================================ */
.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}
.form-field:last-child { margin-bottom: 0; }

.form-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--on-surface-variant);
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--outline-strong);
    border-radius: var(--radius-md);
    background: var(--bg);
    font-size: 13.5px;
    transition: border-color var(--dur-fast) var(--ease-out),
                box-shadow var(--dur-fast) var(--ease-out);
    outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.08);
}
.form-textarea {
    resize: vertical;
    min-height: 80px;
    font-family: 'SF Mono', Menlo, Monaco, Consolas, monospace;
    font-size: 12.5px;
}
.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M3 4.5l3 3 3-3' stroke='%2348484A' stroke-width='1.5' fill='none'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-hint {
    font-size: 11.5px;
    color: var(--on-surface-muted);
}

/* ============================================================
   Modal
   ============================================================ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn var(--dur-med) var(--ease-out);
}
.modal-backdrop[hidden] { display: none; }

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal {
    background: var(--bg);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: modalEnter var(--dur-slow) var(--ease-out);
}

@keyframes modalEnter {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}
.modal-title {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.modal-close { color: var(--on-surface-muted); }

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}
.modal-footer {
    padding: 16px 24px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid var(--outline);
}

/* ============================================================
   Toast
   ============================================================ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 2000;
    pointer-events: none;
}

.toast {
    background: var(--primary);
    color: var(--on-primary);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 450;
    box-shadow: var(--shadow-md);
    min-width: 240px;
    max-width: 420px;
    pointer-events: auto;
    animation: toastEnter var(--dur-med) var(--ease-out);
}
.toast.error { background: var(--danger); color: #FFFFFF; }
.toast.success { background: var(--success); color: #FFFFFF; }

@keyframes toastEnter {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}
.toast.removing {
    animation: toastExit var(--dur-med) var(--ease-in-out) forwards;
}
@keyframes toastExit {
    to { opacity: 0; transform: translateX(20px); }
}

/* ============================================================
   Empty state
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 80px 24px;
    color: var(--on-surface-muted);
}
.empty-state h3 {
    font-size: 16px;
    color: var(--on-surface);
    margin-bottom: 6px;
    font-weight: 550;
}
.empty-state p {
    font-size: 13.5px;
    max-width: 320px;
    margin: 0 auto;
}
.empty-illustration {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    border-radius: 50%;
    background: var(--surface-2);
    position: relative;
}
.empty-illustration::before,
.empty-illustration::after {
    content: '';
    position: absolute;
    background: var(--on-surface-muted);
    border-radius: 2px;
}
.empty-illustration::before {
    width: 24px; height: 3px;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
}
.empty-illustration::after {
    width: 24px; height: 3px;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
}

/* ============================================================
   Dashboards
   ============================================================ */
.dashboards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 16px;
}

.dashboard-card {
    background: var(--bg);
    border: 1px solid var(--outline);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color var(--dur-med) var(--ease-out),
                box-shadow var(--dur-med) var(--ease-out);
}
.dashboard-card:hover {
    border-color: var(--outline-strong);
    box-shadow: var(--shadow-sm);
}

.dashboard-card-header {
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--outline);
}
.dashboard-card-title {
    font-size: 13.5px;
    font-weight: 550;
    letter-spacing: -0.01em;
}
.dashboard-card-actions {
    display: flex;
    gap: 4px;
}

.dashboard-card-body {
    padding: 16px;
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dashboard-card-body .uplot {
    width: 100%;
    max-width: 100%;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
    }
    .sidebar {
        position: fixed;
        left: 0; top: 0;
        width: 260px;
        transform: translateX(-100%);
        transition: transform var(--dur-med) var(--ease-out);
        z-index: 50;
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { transform: translateX(0); }
    .topbar { padding: 14px 16px; }
    .views-container { padding: 20px 16px 40px; }
    .dashboards-grid {
        grid-template-columns: 1fr;
    }
}
/* ============================================================
   Filter bar
   ============================================================ */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-chip {
    padding: 6px 14px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 500;
    background: var(--surface);
    color: var(--on-surface-variant);
    border: 1px solid var(--outline);
    transition: all var(--dur-fast) var(--ease-out);
}
.filter-chip:hover {
    background: var(--surface-2);
    border-color: var(--outline-strong);
}
.filter-chip.active {
    background: var(--primary);
    color: var(--on-primary);
    border-color: var(--primary);
}

.filter-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--on-surface-muted);
    margin-right: 4px;
}

/* ============================================================
   List item actions (в шапке)
   ============================================================ */
.list-item-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--dur-fast) var(--ease-out);
}
.list-item:hover .list-item-actions {
    opacity: 1;
}

/* ============================================================
   Collapsible sections
   ============================================================ */
.collapsible-section {
    margin-top: 16px;
    border: 1px solid var(--outline);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--surface);
    cursor: pointer;
    user-select: none;
    transition: background var(--dur-fast) var(--ease-out);
}
.collapsible-header:hover {
    background: var(--surface-2);
}

.collapsible-title {
    font-size: 12px;
    font-weight: 550;
    color: var(--on-surface-variant);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.collapsible-chevron {
    width: 16px;
    height: 16px;
    color: var(--on-surface-muted);
    transition: transform var(--dur-med) var(--ease-out);
}
.collapsible-section.expanded .collapsible-chevron {
    transform: rotate(90deg);
}

.collapsible-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--dur-slow) var(--ease-in-out);
}
.collapsible-section.expanded .collapsible-body {
    max-height: 2000px;
}
.collapsible-body-inner {
    padding: 12px 14px;
    border-top: 1px solid var(--outline);
}

/* ============================================================
   AI highlights (первый приоритет)
   ============================================================ */
.ai-highlight {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 12px;
}
.ai-highlight-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--on-surface-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.ai-highlight-label::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
}
.ai-highlight-value {
    font-size: 14px;
    line-height: 1.6;
    color: var(--on-surface);
}

/* ============================================================
   Improved detail grid
   ============================================================ */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.detail-section {
    margin-bottom: 0;
}

/* ============================================================
   Monitoring dashboards (improved)
   ============================================================ */
.dashboard-card {
    background: var(--bg);
    border: 1px solid var(--outline);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color var(--dur-med) var(--ease-out),
                box-shadow var(--dur-med) var(--ease-out);
}
.dashboard-card:hover {
    border-color: var(--outline-strong);
    box-shadow: var(--shadow-sm);
}

.dashboard-card-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--outline);
}
.dashboard-card-title {
    font-size: 14px;
    font-weight: 550;
    letter-spacing: -0.01em;
}

.dashboard-card-body {
    padding: 20px;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dashboard-card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--outline);
    background: var(--surface);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.dashboard-metric-value {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--on-surface);
}
.dashboard-metric-label {
    font-size: 11px;
    color: var(--on-surface-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ============================================================
   Filter bar
   ============================================================ */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-chip {
    padding: 6px 14px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 500;
    background: var(--surface);
    color: var(--on-surface-variant);
    border: 1px solid var(--outline);
    transition: all var(--dur-fast) var(--ease-out);
}
.filter-chip:hover {
    background: var(--surface-2);
    border-color: var(--outline-strong);
}
.filter-chip.active {
    background: var(--primary);
    color: var(--on-primary);
    border-color: var(--primary);
}

.filter-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--on-surface-muted);
    margin-right: 4px;
}

/* ============================================================
   List item actions (в шапке карточки)
   ============================================================ */
.list-item-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--dur-fast) var(--ease-out);
}
.list-item:hover .list-item-actions {
    opacity: 1;
}

/* ============================================================
   Collapsible sections (для логов и событий)
   ============================================================ */
.collapsible-section {
    margin-top: 16px;
    border: 1px solid var(--outline);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--surface);
    cursor: pointer;
    user-select: none;
    transition: background var(--dur-fast) var(--ease-out);
}
.collapsible-header:hover {
    background: var(--surface-2);
}

.collapsible-title {
    font-size: 12px;
    font-weight: 550;
    color: var(--on-surface-variant);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.collapsible-chevron {
    width: 16px;
    height: 16px;
    color: var(--on-surface-muted);
    transition: transform var(--dur-med) var(--ease-out);
}
.collapsible-section.expanded .collapsible-chevron {
    transform: rotate(90deg);
}

.collapsible-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--dur-slow) var(--ease-in-out);
}
.collapsible-section.expanded .collapsible-body {
    max-height: 2000px;
}
.collapsible-body-inner {
    padding: 12px 14px;
    border-top: 1px solid var(--outline);
}

/* ============================================================
   AI highlights (приоритетные блоки)
   ============================================================ */
.ai-highlight {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 12px;
}
.ai-highlight-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--on-surface-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.ai-highlight-label::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
}
.ai-highlight-value {
    font-size: 14px;
    line-height: 1.6;
    color: var(--on-surface);
}

/* ============================================================
   Collapsible sidebar
   ============================================================ */
.sidebar {
    transition: width var(--dur-med) var(--ease-out);
    width: 260px;
    overflow: hidden;
}
.sidebar.collapsed {
    width: 72px;
}
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-item span:not(.brand-title):not(.brand-subtitle),
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .nav-chip,
.sidebar.collapsed .sidebar-footer .status-text {
    display: none;
}
.sidebar.collapsed .sidebar-brand {
    justify-content: center;
    padding: 8px 0 24px;
    flex-direction: column;
    gap: 12px;
}
.sidebar.collapsed .brand-mark {
    margin: 0;
}
.sidebar.collapsed .sidebar-toggle {
    margin: 0;
    align-self: center;
}
.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px 0;
}
.sidebar.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

.sidebar-toggle {
    margin-left: auto;
    opacity: 0.6;
    transition: opacity var(--dur-fast) var(--ease-out);
}
.sidebar-toggle:hover {
    opacity: 1;
}
.sidebar.collapsed .sidebar-toggle {
    margin-left: 0;
}

.app-shell {
    transition: grid-template-columns var(--dur-med) var(--ease-out);
}
.app-shell.sidebar-collapsed {
    grid-template-columns: 72px 1fr;
}

/* ============================================================
   Dashboard card footer
   ============================================================ */
.dashboard-card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--outline);
    background: var(--surface);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.dashboard-metric-value {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--on-surface);
}
.dashboard-metric-label {
    font-size: 11px;
    color: var(--on-surface-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ============================================================
   Mobile menu
   ============================================================ */
.mobile-menu-toggle {
    display: none;
    margin-right: 12px;
}

@media (max-width: 900px) {
    .mobile-menu-toggle {
        display: inline-flex;
    }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    z-index: 40;
    opacity: 0;
    transition: opacity var(--dur-med) var(--ease-out);
}
.sidebar-overlay.visible {
    display: block;
    opacity: 1;
}

@media (max-width: 900px) {
    .mobile-menu-toggle {
        display: inline-flex;
    }
    
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 280px;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform var(--dur-med) var(--ease-out);
        z-index: 50;
        box-shadow: var(--shadow-lg);
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    /* При открытом мобильном меню скрываем toggle в sidebar */
    .sidebar.mobile-open .sidebar-toggle {
        display: none;
    }
    
    .app-shell {
        grid-template-columns: 1fr;
    }
    
    .app-shell.sidebar-collapsed {
        grid-template-columns: 1fr;
    }
    
    .sidebar.collapsed {
        width: 280px;
    }
    
    .sidebar.collapsed .brand-text,
    .sidebar.collapsed .nav-item span:not(.brand-title):not(.brand-subtitle),
    .sidebar.collapsed .nav-badge,
    .sidebar.collapsed .nav-chip,
    .sidebar.collapsed .sidebar-footer .status-text {
        display: block;
    }
    
    .sidebar.collapsed .sidebar-brand {
        justify-content: flex-start;
        padding: 8px 16px 24px;
        flex-direction: row;
    }
    
    .sidebar.collapsed .nav-item {
        justify-content: flex-start;
        padding: 10px 12px;
    }
    
    .sidebar.collapsed .sidebar-toggle svg {
        transform: none;
    }
    
    .topbar {
        padding: 14px 16px;
    }
    
    .views-container {
        padding: 20px 16px 40px;
    }
    
    .dashboards-grid {
        grid-template-columns: 1fr;
    }
    
    /* Скрываем текст кнопок на мобильных */
    .btn-text {
        display: none;
    }
    
    .btn-primary {
        padding: 8px;
    }
}