@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg:           #0F0F23;
    --bg-card:      #1A1A3E;
    --bg-sidebar:   #12122A;
    --bg-input:     #0F0F23;
    --border:       #2A2A5A;
    --border-hover: #3A3A7A;
    --shadow:       0 4px 24px rgba(0,0,0,.45);
    --shadow-sm:    0 2px 8px rgba(0,0,0,.3);

    --orange:  #FF6B35;
    --cyan:    #2EC4B6;
    --green:   #06D6A0;
    --red:     #EF476F;
    --yellow:  #FFD166;
    --purple:  #A78BFA;

    --text:        #E8E8F0;
    --text-muted:  #9090B0;
    --text-faint:  #5A5A7A;

    --sidebar-w:   248px;
    --radius:      14px;
    --radius-sm:   8px;
    --transition:  0.25s ease;
}

[data-theme="light"] {
    --bg:           #F0F4FF;
    --bg-card:      #FFFFFF;
    --bg-sidebar:   #FFFFFF;
    --bg-input:     #F8FAFF;
    --border:       #DDE3F0;
    --border-hover: #B8C4DF;
    --shadow:       0 4px 24px rgba(30,40,100,.1);
    --shadow-sm:    0 2px 8px rgba(30,40,100,.07);

    --text:        #1E293B;
    --text-muted:  #64748B;
    --text-faint:  #94A3B8;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { color-scheme: dark; }
[data-theme="light"] html,
[data-theme="light"] { color-scheme: light; }

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow: hidden;
    font-size: 14px;
    transition: background var(--transition), color var(--transition);
}

.ticker-wrap {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 32px;
    background: #0A0A1A;
    border-bottom: 1px solid rgba(255,107,53,.25);
    display: flex;
    align-items: center;
    overflow: hidden;
    z-index: 1000;
    font-size: 0.72rem;
    font-weight: 500;
}
[data-theme="light"] .ticker-wrap {
    background: #1A1A2E;
    border-bottom-color: rgba(255,107,53,.3);
}
.ticker-label {
    flex-shrink: 0;
    padding: 0 10px 0 12px;
    color: var(--green);
    font-weight: 700;
    font-size: 0.65rem;
    letter-spacing: .08em;
    border-right: 1px solid rgba(255,107,53,.2);
    height: 100%;
    display: flex; align-items: center;
}
.ticker-track {
    flex: 1;
    overflow: hidden;
    height: 100%;
    display: flex; align-items: center;
}
.ticker-inner {
    display: flex;
    align-items: center;
    gap: 0;
    white-space: nowrap;
    animation: ticker-scroll 40s linear infinite;
    will-change: transform;
}
.ticker-inner:hover { animation-play-state: paused; }
@keyframes ticker-scroll {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}
.ticker-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0 20px;
    border-right: 1px solid rgba(255,255,255,.07);
    color: #C0C0D8;
    cursor: default;
    transition: color .2s;
}
.ticker-item:hover { color: #fff; }
.ticker-name { color: #9090B0; font-weight: 600; font-size: 0.68rem; }
.ticker-price { color: #E8E8F0; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 0.72rem; }
.ticker-chg.up   { color: #06D6A0; }
.ticker-chg.down { color: #EF476F; }
.ticker-chg.flat { color: #9090B0; }
.ticker-loading { padding: 0 20px; color: #5A5A7A; font-size: 0.7rem; }

.ws-status {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #5A5A7A;
    margin: 0 12px;
    flex-shrink: 0;
    transition: background .4s;
}
.ws-status.connected    { background: var(--green); box-shadow: 0 0 6px var(--green); }
.ws-status.disconnected { background: var(--red); }

#app {
    display: flex;
    height: 100vh;
    padding-top: 32px; /* место под тикер */
}

#sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: background var(--transition), border-color var(--transition);
    box-shadow: var(--shadow-sm);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 16px 16px;
    border-bottom: 1px solid var(--border);
}
.brand-icon {
    font-size: 1.6rem;
    filter: drop-shadow(0 0 8px var(--orange));
    flex-shrink: 0;
}
.brand-title { display: block; font-size: 0.9rem; font-weight: 700; color: var(--orange); }
.brand-sub   { display: block; font-size: 0.65rem; color: var(--text-muted); margin-top: 1px; }

/* Nav */
#nav { flex: 1; padding: 8px 0; overflow-y: auto; }

.nav-section-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-faint);
    padding: 10px 16px 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.84rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
    user-select: none;
    margin-right: 8px;
}
.nav-link:hover {
    background: rgba(255,107,53,.09);
    color: var(--text);
}
.nav-link.active {
    background: rgba(255,107,53,.14);
    color: var(--orange);
    border-left-color: var(--orange);
    font-weight: 600;
}
[data-theme="light"] .nav-link.active { background: rgba(255,107,53,.1); }
.nav-icon { font-size: 1rem; flex-shrink: 0; }

/* Theme toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: color var(--transition);
    user-select: none;
}
.theme-toggle:hover { color: var(--text); }

.toggle-track {
    width: 40px; height: 22px;
    background: var(--border);
    border-radius: 11px;
    position: relative;
    transition: background var(--transition);
    flex-shrink: 0;
}
.toggle-thumb {
    position: absolute;
    top: 3px; left: 3px;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: transform 0.25s ease, background 0.25s ease;
}
[data-theme="light"] .toggle-track { background: rgba(255,107,53,.25); }
[data-theme="light"] .toggle-thumb { background: var(--orange); transform: translateX(18px); }

.theme-toggle-label { display: flex; align-items: center; gap: 6px; }

/* Sidebar footer */
.sidebar-footer {
    padding: 12px 16px 16px;
    border-top: 1px solid var(--border);
}
.sf-name { font-size: 0.71rem; color: var(--text); font-weight: 500; }
.sf-info { font-size: 0.64rem; color: var(--text-muted); margin-top: 2px; }

#main { flex: 1; overflow-y: auto; overflow-x: hidden; background: var(--bg); transition: background var(--transition); }

.page {
    display: none;
    padding: 26px;
    min-height: 100%;
    animation: pageFadeIn 0.2s ease;
}
.page.active { display: block; }

@keyframes pageFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h1 { font-size: 1.3rem; font-weight: 700; margin-bottom: 3px; }
.page-header p  { font-size: 0.79rem; color: var(--text-muted); }

.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.live-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(6,214,160,.08);
    border: 1px solid rgba(6,214,160,.25);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 0.77rem;
    color: var(--green);
    font-weight: 600;
}
[data-theme="light"] .live-badge {
    background: rgba(6,214,160,.1);
    border-color: rgba(6,214,160,.35);
}
.live-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--green);
    animation: pulse 1.5s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.25} }
.live-ts { color: var(--text-muted); font-weight: 400; }

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow);
}
.card h3 { font-size: 0.88rem; font-weight: 600; margin-bottom: 14px; color: var(--text); }

.card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.card-top h3 { margin-bottom: 0; }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    cursor: default;
    transition: border-color var(--transition), box-shadow var(--transition), transform 0.2s ease;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--orange), var(--yellow));
    opacity: 0;
    transition: opacity var(--transition);
}
.kpi-card:hover {
    border-color: var(--orange);
    box-shadow: 0 4px 20px rgba(255,107,53,.15);
    transform: translateY(-2px);
}
.kpi-card:hover::before { opacity: 1; }

.kpi-icon  { font-size: 1.4rem; margin-bottom: 8px; }
.kpi-name  { font-size: 0.67rem; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; text-transform: uppercase; letter-spacing: .03em; }
.kpi-price { font-size: 1.5rem; font-weight: 700; color: var(--orange); line-height: 1.1; }
.kpi-unit  { font-size: 0.64rem; color: var(--text-muted); margin-top: 1px; }
.kpi-change {
    display: inline-flex; align-items: center; gap: 2px;
    font-size: 0.76rem; font-weight: 600;
    margin-top: 6px; padding: 2px 8px; border-radius: 10px;
}
.kpi-change.up   { color: var(--green); background: rgba(6,214,160,.12); }
.kpi-change.down { color: var(--red);   background: rgba(239,71,111,.12); }
.kpi-ts { font-size: 0.59rem; color: var(--text-faint); margin-top: 4px; }

/* Анимация вспышки при изменении цены */
@keyframes flash-up {
    0%   { background: rgba(6,214,160,.35); border-color: rgba(6,214,160,.6); }
    100% { background: var(--bg-card);      border-color: var(--border); }
}
@keyframes flash-down {
    0%   { background: rgba(239,71,111,.35); border-color: rgba(239,71,111,.6); }
    100% { background: var(--bg-card);       border-color: var(--border); }
}
.kpi-card.flash-up   { animation: flash-up   0.8s ease-out forwards; }
.kpi-card.flash-down { animation: flash-down 0.8s ease-out forwards; }

/* Анимация числа при изменении цены */
@keyframes number-pop {
    0%   { transform: scale(1.15); }
    100% { transform: scale(1); }
}
.kpi-price.pop { animation: number-pop 0.35s ease-out forwards; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.mt-1 { margin-top: 12px; }
.mt-2 { margin-top: 20px; }
.mb-1 { margin-bottom: 12px; }

.btn, .btn-primary, .btn-outline, .btn-danger {
    display: inline-flex; align-items: center; gap: 6px;
    border-radius: var(--radius-sm); padding: 8px 16px;
    font-size: 0.81rem; font-weight: 600;
    cursor: pointer; font-family: inherit;
    border: none;
    transition: opacity .2s, transform .15s, box-shadow .2s;
    white-space: nowrap;
}
.btn-primary {
    background: linear-gradient(135deg, var(--orange), #FF8C5A);
    color: #fff;
    box-shadow: 0 2px 10px rgba(255,107,53,.3);
}
.btn-primary:hover {
    opacity: .9;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(255,107,53,.4);
}
.btn-primary:active { transform: translateY(0); }

.btn-outline {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-outline:hover {
    border-color: var(--orange);
    color: var(--orange);
    background: rgba(255,107,53,.06);
}

.btn-danger {
    background: var(--red);
    color: #fff;
    box-shadow: 0 2px 10px rgba(239,71,111,.25);
}
.btn-danger:hover { opacity: .87; transform: translateY(-1px); }

.btn-sm { padding: 4px 10px; font-size: 0.74rem; }
.btn-success {
    background: var(--green);
    color: #fff;
    box-shadow: 0 2px 10px rgba(6,214,160,.2);
}
.btn-success:hover { opacity: .87; transform: translateY(-1px); }
.full-w { width: 100%; justify-content: center; }

/* utility */
.mb-1 { margin-bottom: 8px; }
.input-field {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 8px 12px;
    font-size: .85rem;
    font-family: inherit;
    outline: none;
    transition: border-color .2s;
    box-sizing: border-box;
}
.input-field:focus { border-color: var(--accent); }

.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    font-size: 0.74rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 5px;
}
input[type="text"],
input[type="number"],
input[type="password"],
select {
    width: 100%;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 0.83rem;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}
input:focus, select:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(255,107,53,.12);
}
input::placeholder { color: var(--text-faint); }
select option { background: var(--bg-card); color: var(--text); }

.data-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.data-table th {
    text-align: left;
    padding: 9px 12px;
    color: var(--text-muted);
    font-size: 0.69rem;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: .05em;
    background: transparent;
}
.data-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
    transition: background var(--transition);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td {
    background: rgba(255,107,53,.05);
}
[data-theme="light"] .data-table tbody tr:hover td {
    background: rgba(255,107,53,.04);
}
.data-table tbody tr:nth-child(even) td {
    background: rgba(0,0,0,.015);
}
[data-theme="light"] .data-table tbody tr:nth-child(even) td {
    background: rgba(0,0,80,.025);
}

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: .02em;
}
.badge-active    { background: rgba(6,214,160,.15); color: var(--green); }
.badge-triggered { background: rgba(239,71,111,.15); color: var(--red); }

.msg-ok {
    background: rgba(6,214,160,.1);
    border: 1px solid rgba(6,214,160,.3);
    color: var(--green);
    padding: 8px 14px; border-radius: var(--radius-sm); font-size: 0.8rem;
}
.msg-err {
    background: rgba(239,71,111,.1);
    border: 1px solid rgba(239,71,111,.3);
    color: var(--red);
    padding: 8px 14px; border-radius: var(--radius-sm); font-size: 0.8rem;
}
.msg-loading { color: var(--text-muted); font-size: 0.8rem; padding: 8px 0; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.78rem; }

.login-wrap { display: flex; justify-content: center; padding-top: 40px; }
.login-card {
    width: 100%; max-width: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    box-shadow: var(--shadow);
}
.login-icon { font-size: 3rem; margin-bottom: 14px; }
.login-card h3 { color: var(--orange); font-size: 1.15rem; margin-bottom: 6px; }
.login-card > p { color: var(--text-muted); font-size: 0.82rem; margin-bottom: 22px; }
.login-card .form-group { text-align: left; }
.login-err { color: var(--red); font-size: 0.8rem; margin-top: 8px; min-height: 18px; }

.admin-banner {
    background: rgba(6,214,160,.07);
    border: 1px solid rgba(6,214,160,.25);
    border-radius: 12px;
    padding: 11px 18px;
    color: var(--green);
    font-size: 0.85rem;
    font-weight: 500;
}

.empty {
    color: var(--text-muted);
    font-size: 0.82rem;
    padding: 28px;
    text-align: center;
}
.empty::before { content: '—'; display: block; font-size: 1.5rem; margin-bottom: 6px; opacity: .4; }

/* Skeleton loader */
.skeleton {
    background: linear-gradient(90deg, var(--border) 25%, var(--border-hover) 50%, var(--border) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    border-radius: 6px;
    height: 14px;
    margin: 6px 0;
}
@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 20px;
}
.spinner::before {
    content: '';
    width: 16px; height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--orange);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

.hamburger {
    display: none;
    position: fixed;
    top: 46px; left: 14px;
    z-index: 1100;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 11px;
    cursor: pointer;
    flex-direction: column;
    gap: 4px;
    box-shadow: var(--shadow-sm);
    transition: background var(--transition), border-color var(--transition);
}
.hamburger span {
    display: block;
    width: 20px; height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: transform 0.25s ease, opacity 0.2s ease;
}
.hamburger.open span:nth-child(1) { transform: rotate(45deg) translate(4px, 4px); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: rotate(-45deg) translate(4px, -4px); }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 999;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.visible { display: block; }

.live-countdown {
    font-size: 0.72rem;
    color: var(--text-faint);
    font-weight: 400;
    font-variant-numeric: tabular-nums;
}

.about-text {
    font-size: 0.85rem;
    line-height: 1.65;
    color: var(--text);
}
.about-author {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 10px;
}
.about-avatar {
    width: 56px; height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--orange), var(--yellow));
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.about-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}
.about-info {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.arch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}
.arch-block {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    transition: border-color var(--transition), transform 0.2s ease;
}
.arch-block:hover {
    border-color: var(--orange);
    transform: translateY(-2px);
}
.arch-icon { font-size: 1.5rem; margin-bottom: 8px; }
.arch-title { font-size: 0.82rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.arch-desc { font-size: 0.74rem; color: var(--text-muted); line-height: 1.5; }

.tech-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.tech-badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid var(--border);
}
.tech-python  { background: rgba(55,118,171,.12); color: #3776AB; border-color: rgba(55,118,171,.3); }
.tech-fastapi { background: rgba(0,150,136,.12); color: #009688; border-color: rgba(0,150,136,.3); }
.tech-sql     { background: rgba(167,139,250,.12); color: var(--purple); border-color: rgba(167,139,250,.3); }
.tech-js      { background: rgba(255,209,102,.15); color: #B8860B; border-color: rgba(255,209,102,.4); }
[data-theme="light"] .tech-python  { background: rgba(55,118,171,.08); }
[data-theme="light"] .tech-fastapi { background: rgba(0,150,136,.08); }
[data-theme="light"] .tech-sql     { background: rgba(167,139,250,.08); }
[data-theme="light"] .tech-js      { background: rgba(255,209,102,.1); color: #8B6914; }

.error-state {
    text-align: center;
    padding: 30px;
    color: var(--red);
    font-size: 0.85rem;
}
.error-state::before {
    content: '⚠';
    display: block;
    font-size: 2rem;
    margin-bottom: 8px;
    opacity: 0.7;
}
.retry-btn {
    margin-top: 12px;
    background: transparent;
    border: 1px solid var(--red);
    color: var(--red);
    padding: 6px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    font-family: inherit;
    transition: background 0.2s, color 0.2s;
}
.retry-btn:hover { background: var(--red); color: #fff; }

@media (max-width: 900px) {
    .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .hamburger { display: flex; }

    #sidebar {
        position: fixed;
        top: 32px; left: 0; bottom: 0;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease, background var(--transition);
        width: 260px;
        min-width: 260px;
    }
    #sidebar.open { transform: translateX(0); }

    #main { margin-left: 0; }
    .page { padding: 60px 16px 16px; }
    .kpi-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .page-header { flex-direction: column; }
    .arch-grid { grid-template-columns: 1fr; }
    .news-grid { grid-template-columns: 1fr; }
    .chat-widget { width: calc(100vw - 24px); right: 12px; }
}

/* NEWS */
.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.news-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition), transform 0.2s;
    box-shadow: var(--shadow-sm);
}
.news-card:hover {
    border-color: var(--orange);
    box-shadow: 0 6px 24px rgba(255,107,53,.18);
    transform: translateY(-3px);
}

.news-img {
    width: 100%;
    height: 160px;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
}
.news-img-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}
.news-img-placeholder::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.25);
}
.news-placeholder-icon {
    font-size: 2.6rem;
    z-index: 1;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,.4));
}
.news-placeholder-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: rgba(255,255,255,.9);
    z-index: 1;
}

.news-card-body {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 14px 16px 16px;
    flex: 1;
}
.news-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.news-source-badge {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--orange);
    background: rgba(255,107,53,.1);
    border: 1px solid rgba(255,107,53,.2);
    border-radius: 5px;
    padding: 2px 7px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}
.news-time {
    font-size: 0.61rem;
    color: var(--text-faint);
    white-space: nowrap;
}
.news-title {
    font-size: 0.87rem;
    font-weight: 600;
    line-height: 1.45;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.news-summary {
    font-size: 0.77rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* CHAT WIDGET */
.chat-widget {
    position: fixed;
    bottom: 0;
    right: 24px;
    width: 360px;
    z-index: 900;
    border-radius: 14px 14px 0 0;
    overflow: hidden;
    box-shadow: 0 -4px 32px rgba(0,0,0,.4);
    border: 1px solid var(--border);
    border-bottom: none;
}
.chat-header {
    background: linear-gradient(135deg, #1A1A3E, #2A1A4E);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid rgba(255,107,53,.2);
}
[data-theme="light"] .chat-header { background: linear-gradient(135deg, #1E293B, #334155); }
.chat-header-icon { font-size: 1.1rem; }
.chat-header-title { flex: 1; font-size: 0.85rem; font-weight: 600; color: #fff; }
.chat-toggle-icon { font-size: 0.7rem; color: rgba(255,255,255,.6); }

.chat-body {
    display: none;
    flex-direction: column;
    background: var(--bg-card);
    height: 420px;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.chat-msg { display: flex; }
.chat-msg.user { justify-content: flex-end; }
.chat-msg.assistant { justify-content: flex-start; }

.chat-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.83rem;
    line-height: 1.5;
}
.chat-msg.user .chat-bubble {
    background: linear-gradient(135deg, var(--orange), #FF8C5A);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg.assistant .chat-bubble {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.chat-typing-dots {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 12px 16px;
}
.chat-typing-dots span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typing-bounce 1.2s infinite;
}
.chat-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: .5; }
    40% { transform: translateY(-6px); opacity: 1; }
}

.chat-input-row {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
}
.chat-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 0.83rem;
    color: var(--text);
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition);
}
.chat-input:focus { border-color: var(--orange); }
.chat-send {
    background: var(--orange);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    transition: opacity .2s;
    flex-shrink: 0;
}
.chat-send:hover { opacity: .85; }
