/* ============================================
   BURNT PLANET ANALYTICS — Notion style
   Тёплый серый сайдбар, синий акцент, мягкие
   скругления, крупные блоки и таблицы.
   Без эмодзи — только линейные иконки интерфейса.
   ============================================ */
:root {
    --bg-color: #ffffff;
    --sidebar-bg: #f7f6f3;
    --sidebar-hover: #efede8;
    --text-main: #2f2e2a;
    --text-muted: #6b6a67;
    --border-color: #e2e1de;

    --accent-blue: #2383e2;
    --accent-blue-dark: #1a6dc0;
    --blue-bg: #e8f3ff;
    --tag-gray: #ecebe8;

    --green: #16a34a; --green-bg: #dcfce7; --green-text: #166534;
    --yellow: #d97706; --amber-bg: #fef3c7; --amber-text: #92400e;
    --red: #dc2626; --red-bg: #fee2e2; --red-text: #991b1b;

    /* Обратная совместимость со старыми токенами (инлайн-стили) */
    --border: #e2e1de; --accent-tint: #e8f3ff; --muted: #6b6a67; --text: #2f2e2a;
}

* { box-sizing: border-box; margin: 0; padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; }

body { background-color: var(--bg-color); color: var(--text-main);
    display: flex; height: 100vh; width: 100vw; overflow: hidden; font-size: 15px; line-height: 1.5; }

a { color: var(--accent-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Иконки ---------- */
.icon, .ico svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round; fill: none; flex-shrink: 0; }
.ico { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* ============================================
   САЙДБАР
   ============================================ */
.app-shell { display: flex; flex: 1; min-width: 0; height: 100vh; overflow: hidden; }
.sidebar { width: 320px; min-width: 320px; background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color); padding: 16px 12px;
    display: flex; flex-direction: column; justify-content: space-between; overflow-y: auto; }

.brand-header, .sb-brand { display: flex; align-items: center; gap: 12px; padding: 10px;
    font-weight: 700; font-size: 18px; color: var(--accent-blue); margin-bottom: 12px; }
.brand-header .logo, .sb-brand .logo { display: contents; }

.sidebar nav { display: flex; flex-direction: column; }
.menu-section, .nav-group { margin-top: 20px; font-size: 12px; font-weight: 700; color: var(--text-muted);
    padding: 6px 10px; letter-spacing: .5px; text-transform: uppercase; }
.menu-item, .nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px;
    font-size: 15px; color: var(--text-main); border-radius: 6px; cursor: pointer;
    text-decoration: none; font-weight: 500; border: none; background: transparent; width: 100%; text-align: left; }
.menu-item:hover, .nav-item:hover { background-color: var(--sidebar-hover); color: var(--text-main); text-decoration: none; }
.menu-item.active, .nav-item.active { background-color: var(--blue-bg); color: var(--accent-blue); font-weight: 600; }

.sidebar-footer, .sb-footer { padding: 12px 10px; font-size: 13px; color: var(--text-muted);
    border-top: 1px solid var(--border-color); margin-top: 20px; }

/* ============================================
   ОСНОВНАЯ ОБЛАСТЬ
   ============================================ */
.main-wrapper, .main { flex: 1; display: flex; flex-direction: column; height: 100vh; overflow: hidden; min-width: 0; }

.top-nav, .topbar { height: 64px; min-height: 64px; border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: space-between; padding: 0 32px; gap: 16px; }
.page-title-top, .topbar .title, .topbar .brand { font-weight: 700; font-size: 20px; color: var(--text-main); }
.top-right { display: flex; align-items: center; gap: 16px; }

.status-badge { background-color: var(--tag-gray); color: var(--text-muted); padding: 6px 14px;
    border-radius: 4px; font-size: 14px; font-weight: 500; }
.status-badge.ok { background-color: var(--green-bg); color: var(--green-text); }
.status-badge.running { background-color: var(--blue-bg); color: var(--accent-blue); }

.btn-logout { background-color: transparent; border: 1px solid var(--border-color); padding: 8px 18px;
    border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer; color: var(--text-main); }
.btn-logout:hover { background-color: var(--sidebar-bg); }

.main-content, .wrap { flex: 1; padding: 24px 32px; display: flex; flex-direction: column;
    gap: 24px; overflow-y: auto; }

.view { display: none; }
.view.active { display: flex; flex-direction: column; gap: 24px; flex: 1; min-height: 0; }

/* ---------- Блоки ---------- */
.notion-block, .card { background-color: #fff; border: 1px solid var(--border-color);
    border-radius: 8px; padding: 28px; width: 100%; }
.notion-block.fill-height { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.block-header, .card h2 { font-size: 24px; font-weight: 700; margin-bottom: 6px; color: var(--text-main); }
.block-subtitle, .card .hint, .hint { font-size: 15px; color: var(--text-muted); margin-bottom: 24px; line-height: 1.6; }
.notion-block h3, .card h3 { font-size: 16px; font-weight: 700; color: var(--text-main); margin: 24px 0 10px; }
.card .hint:last-child, .block-subtitle:last-child { margin-bottom: 0; }

/* ---------- Метрики ---------- */
.metrics-grid, .grid-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; width: 100%; }
.metric-card, .stat { background-color: var(--sidebar-bg); border-radius: 6px; padding: 20px;
    border: 1px solid var(--border-color); display: flex; flex-direction: column; justify-content: center; }
.metric-label, .stat .label { font-size: 13px; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.metric-value, .stat .value { font-size: 34px; font-weight: 800; color: var(--text-main); }
.metric-value.sm { font-size: 22px; line-height: 1.25; }
.metric-card.span2 { grid-column: span 2; }

/* ---------- Таблицы ---------- */
.table-container, .table-scroll { flex: 1; width: 100%; overflow: auto; margin-top: 12px;
    border: 1px solid var(--border-color); border-radius: 6px; }
.notion-table, table { width: 100%; border-collapse: collapse; font-size: 15px; }
.notion-table th, .notion-table td, table th, table td { border: 1px solid var(--border-color); padding: 16px 20px; text-align: left; }
.notion-table th, table th { background-color: var(--sidebar-bg); color: var(--text-muted);
    font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }
.notion-table tbody tr:hover td, table tbody tr:hover td { background-color: #faf9f7; }
.empty-row { color: var(--text-muted); text-align: center; padding: 50px !important; font-style: italic; font-size: 16px; }

/* ---------- Формы ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin: 16px 0 6px; }
input, select, textarea { width: 100%; padding: 10px 12px; background: #fff; border: 1px solid var(--border-color);
    border-radius: 6px; color: var(--text-main); font-size: 14px; outline: none; font-family: inherit;
    transition: border-color .15s, box-shadow .15s; }
input::placeholder, textarea::placeholder { color: #a9a8a5; }
input:hover, select:hover, textarea:hover { border-color: #cfcec9; }
input:focus, select:focus, textarea:focus { border-color: var(--accent-blue); box-shadow: 0 0 0 2px var(--blue-bg); }
select { cursor: pointer; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b6a67' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent-blue); }
input[type="date"], input[type="time"] { cursor: pointer; }
textarea { resize: vertical; min-height: 90px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 220px; }

/* ---------- Кнопки ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 18px; border: 1px solid var(--accent-blue);
    background: var(--accent-blue); color: #fff; font-weight: 600; font-size: 14px; border-radius: 6px;
    cursor: pointer; font-family: inherit; transition: background .15s, border-color .15s, color .15s; }
.btn:hover { background: var(--accent-blue-dark); border-color: var(--accent-blue-dark); color: #fff; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: transparent; border: 1px solid var(--border-color); color: var(--text-main); }
.btn.secondary:hover { background: var(--sidebar-bg); border-color: #cfcec9; color: var(--text-main); }
.btn.ghost { background: transparent; border: 1px solid var(--border-color); color: var(--accent-blue); }
.btn.ghost:hover { background: var(--blue-bg); border-color: var(--accent-blue); color: var(--accent-blue); }
.btn.danger { background: transparent; border: 1px solid var(--red); color: var(--red-text); }
.btn.danger:hover { background: var(--red); border-color: var(--red); color: #fff; }
.btn.small { padding: 6px 12px; font-size: 13px; }

/* ---------- Бейджи ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 4px;
    font-size: 13px; font-weight: 500; background: var(--tag-gray); color: var(--text-muted); }
.badge.OK, .badge.success, .badge.ok { background: var(--green-bg); color: var(--green-text); }
.badge.EMPTY, .badge.warn { background: var(--amber-bg); color: var(--amber-text); }
.badge.ERROR, .badge.error, .badge.err { background: var(--red-bg); color: var(--red-text); }
.badge.RUNNING { background: var(--blue-bg); color: var(--accent-blue); }
.badge.muted { background: var(--tag-gray); color: var(--text-muted); }

/* ---------- Логи / код ---------- */
.log { background: var(--sidebar-bg); border: 1px solid var(--border-color); border-radius: 6px; padding: 16px 18px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.75;
    max-height: 480px; overflow: auto; color: var(--text-main); white-space: pre-wrap; word-break: break-word; }
.log .l-info { color: #4b4a46; }
.log .l-success { color: var(--green-text); }
.log .l-warn { color: var(--amber-text); }
.log .l-error { color: var(--red-text); }
.log .ts { color: #a9a8a5; margin-right: 6px; }
code.inline { background: var(--tag-gray); border: 1px solid var(--border-color); border-radius: 4px; padding: 2px 6px;
    font-size: 12.5px; color: var(--accent-blue); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------- Выделенные блоки ---------- */
.token-reveal { background: var(--blue-bg); border: 1px solid var(--accent-blue); border-radius: 6px; padding: 14px 16px;
    word-break: break-all; color: var(--text-main); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.alert { padding: 12px 16px; font-size: 14px; margin: 16px 0; display: none; border-radius: 6px;
    border: 1px solid var(--border-color); background: var(--sidebar-bg); color: var(--text-main); }
.alert.show { display: block; }
.alert.err { background: var(--red-bg); color: var(--red-text); border-color: #f3c7c7; }
.alert.ok { background: var(--green-bg); color: var(--green-text); border-color: #bfe8cd; }

/* ---------- Утилиты ---------- */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.muted { color: var(--text-muted); }
.mt { margin-top: 16px; }
.right { text-align: right; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.base { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; color: var(--text-muted); }
ul.muted, ol.muted { margin: 0 0 0 20px; }
ul.muted li, ol.muted li { margin-bottom: 6px; }
details summary { cursor: pointer; color: var(--text-muted); font-size: 13px; font-weight: 600; }
details[open] summary { margin-bottom: 8px; }

/* ---------- Вкладки (табы) ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; border-bottom: 1px solid var(--border-color); }
.tab { padding: 9px 14px; background: transparent; border: none; border-bottom: 2px solid transparent;
    color: var(--text-muted); cursor: pointer; font-size: 14px; font-weight: 600; }
.tab:hover { color: var(--text-main); }
.tab.active { color: var(--accent-blue); border-bottom-color: var(--accent-blue); }

/* ---------- Страница входа ---------- */
.auth-center { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px;
    background: var(--sidebar-bg); overflow-y: auto; }
.auth-box { width: 100%; max-width: 420px; }
.auth-box .logo { text-align: center; font-size: 24px; font-weight: 700; color: var(--accent-blue); margin-bottom: 6px; }
.auth-box h1 { text-align: center; font-size: 15px; font-weight: 600; color: var(--text-main); margin: 0 0 4px; }
.auth-box .sub { text-align: center; color: var(--text-muted); font-size: 14px; margin: 0 0 20px; }
.auth-box .card { padding: 28px; }
.auth-box .card .hint { margin: 16px 0 0; }

/* ---------- Адаптив ---------- */
@media (max-width: 900px) {
    body { overflow: auto; height: auto; }
    .app-shell, body { flex-direction: column; }
    .sidebar { width: 100%; min-width: 0; height: auto; border-right: none; border-bottom: 1px solid var(--border-color); }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; gap: 6px; }
    .menu-item, .nav-item { width: auto; }
    .menu-section, .nav-group { display: none; }
    .sidebar-footer, .sb-footer { display: none; }
    .main-wrapper, .main { height: auto; overflow: visible; }
    .main-content, .wrap { padding: 20px 16px; }
    .metrics-grid, .grid-stats { grid-template-columns: repeat(2, 1fr); }
    .metric-value, .stat .value { font-size: 26px; }
}
