:root {
    --bg-navy: #071427;
    --bg-navy-2: #0c2342;
    --surface: rgba(8, 22, 43, 0.78);
    --surface-solid: #0d2341;
    --surface-soft: rgba(14, 34, 63, 0.62);
    --border: rgba(148, 189, 229, 0.22);
    --text: #f2f7ff;
    --text-muted: #b7c8df;
    --brand: #2a8fd6;
    --brand-strong: #1f6fab;
    --accent: #f2a341;
    --danger: #ef6a6a;
    --warn: #ffbe55;
    --ok: #50c7a8;
    --shadow: 0 16px 40px rgba(1, 8, 20, 0.45);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    color: var(--text);
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    background:
        linear-gradient(135deg, rgba(4, 14, 30, 0.9), rgba(8, 25, 48, 0.82)),
        radial-gradient(circle at 15% 12%, rgba(42, 143, 214, 0.2), transparent 38%),
        radial-gradient(circle at 86% 88%, rgba(242, 163, 65, 0.12), transparent 30%),
        url('/assets/bg.jpg') center/cover no-repeat;
}

a { color: #9ed3ff; }

a:hover { color: #d3ebff; }

.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 28px 20px 36px;
    position: relative;
    z-index: 2;
}

.page-header {
    display: flex;
    gap: 18px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.header-logo-link {
    display: inline-flex;
    align-items: center;
    border-radius: 10px;
    text-decoration: none;
}

.header-logo {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    padding: 6px;
}

.brand-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-logo {
    width: 56px;
    height: 56px;
    object-fit: contain;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    padding: 6px;
}

.brand-title {
    margin: 0;
    font-size: 34px;
    line-height: 1.05;
    letter-spacing: 0.2px;
}

.brand-subtitle {
    margin: 6px 0 0;
    color: var(--text-muted);
    font-size: 14px;
}

.nav {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.nav-toggle {
    display: none !important;
    width: auto;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid rgba(168, 204, 235, 0.25);
    background: rgba(12, 33, 60, 0.8);
    color: #d8e8f9;
    font-weight: 600;
}

.nav-toggle-icon {
    font-size: 18px;
    line-height: 1;
}

.nav a {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 600;
    padding: 6px 8px;
    border-radius: 8px;
    position: relative;
    z-index: 3;
}

.nav-dropdown {
    position: relative;
    padding-bottom: 6px;
}

.nav-dropdown-toggle {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 600;
    padding: 6px 8px;
    border-radius: 8px;
    display: inline-block;
}

.nav-dropdown:hover .nav-dropdown-toggle,
.nav-dropdown.active .nav-dropdown-toggle {
    color: #e8f5ff;
    background: rgba(42, 143, 214, 0.18);
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 180px;
    background: rgba(8, 22, 43, 0.98);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 6px;
    z-index: 20;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
    display: block;
}

.nav-dropdown-menu a {
    display: block;
    width: 100%;
}

.nav a.active,
.nav a:hover {
    color: #e8f5ff;
    background: rgba(42, 143, 214, 0.18);
}

.user-chip {
    border: 1px solid var(--border);
    color: #d4e9ff;
    background: rgba(18, 49, 83, 0.45);
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 12px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    position: relative;
    z-index: 2;
}

.card-title {
    margin: 0 0 12px;
    font-size: 20px;
    font-weight: 700;
}

.title-live-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.4px;
    color: #ffd6d6;
    background: rgba(130, 22, 22, 0.32);
    border: 1px solid rgba(255, 96, 96, 0.45);
    border-radius: 999px;
    padding: 4px 10px;
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff4747;
    box-shadow: 0 0 0 rgba(255, 71, 71, 0.85);
    animation: live-heartbeat 1.1s ease-in-out infinite;
}

@keyframes live-heartbeat {
    0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(255, 71, 71, 0.8); }
    35% { transform: scale(1.25); box-shadow: 0 0 0 8px rgba(255, 71, 71, 0.22); }
    70% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 71, 71, 0); }
    100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(255, 71, 71, 0); }
}

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

.ai-fab {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 68px;
    height: 68px;
    border-radius: 999px;
    padding: 0;
    z-index: 60;
    box-shadow: 0 18px 34px rgba(0, 0, 0, 0.35);
}

.ai-fab-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.6px;
}

.ai-widget-panel {
    position: fixed;
    right: 24px;
    bottom: 104px;
    width: min(420px, calc(100vw - 28px));
    z-index: 60;
    opacity: 0;
    transform: translateY(18px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.ai-widget-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.ai-widget-card {
    background: rgba(8, 22, 43, 0.96);
    border: 1px solid rgba(168, 204, 235, 0.2);
    border-radius: 18px;
    box-shadow: 0 20px 50px rgba(1, 8, 20, 0.55);
    padding: 16px;
    backdrop-filter: blur(10px);
}

.ai-widget-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.ai-widget-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

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

.ai-widget-close {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 999px;
    font-size: 20px;
    line-height: 1;
}

.ai-summary-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 14px 0;
}

.ai-brief-list {
    display: grid;
    gap: 10px;
}

.ai-brief-item {
    display: grid;
    gap: 5px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(6, 18, 34, 0.45);
    border: 1px solid rgba(168, 204, 235, 0.16);
}

.ai-chat-log {
    height: 360px;
    overflow-y: auto;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(168, 204, 235, 0.18);
    background: rgba(4, 14, 28, 0.62);
    display: grid;
    gap: 12px;
    margin: 14px 0;
}

.ai-message {
    max-width: 86%;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(168, 204, 235, 0.18);
}

.ai-message-assistant {
    background: rgba(16, 41, 72, 0.8);
    justify-self: start;
}

.ai-message-user {
    background: rgba(42, 143, 214, 0.18);
    justify-self: end;
}

.ai-message-role {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.ai-message-text {
    color: var(--text);
    line-height: 1.55;
    word-break: break-word;
}

.ai-chat-form {
    display: grid;
    gap: 10px;
}

.ai-chat-form textarea {
    min-height: 110px;
}

.ai-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.ai-suggestion-btn,
.ai-clear-btn {
    width: auto;
}

.ai-suggestion-btn {
    padding: 8px 10px;
    border-radius: 999px;
    background: rgba(12, 33, 60, 0.75);
    color: #d8e8f9;
    border: 1px solid rgba(168, 204, 235, 0.22);
    font-size: 12px;
    font-weight: 700;
}

.metric {
    font-size: 36px;
    font-weight: 700;
    margin-top: 8px;
}

.muted { color: var(--text-muted); }

.row-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.table-wrap { overflow-x: auto; }

.pagination {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

.pagination-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.per-page-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.per-page-label {
    margin: 0;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
}

.per-page-select {
    width: auto;
    min-width: 78px;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid rgba(168, 204, 235, 0.25);
    background: rgba(12, 33, 60, 0.75);
    color: #d8e8f9;
}

.status-summary {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    border: 1px solid rgba(168, 204, 235, 0.25);
    background: rgba(12, 33, 60, 0.75);
    padding: 6px 11px;
    font-size: 12px;
    font-weight: 700;
}

.page-btn {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(168, 204, 235, 0.25);
    background: rgba(12, 33, 60, 0.75);
    color: #d8e8f9;
    text-decoration: none;
    font-size: 13px;
}

.page-btn.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.chart-wrap {
    background: rgba(6, 18, 34, 0.55);
    border: 1px solid rgba(168, 204, 235, 0.2);
    border-radius: 12px;
    padding: 12px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

th, td {
    padding: 10px 10px;
    border-bottom: 1px solid rgba(160, 196, 228, 0.16);
    text-align: left;
    vertical-align: top;
}

th {
    color: #ecf7ff;
    font-weight: 700;
    font-size: 15px;
}

td { color: #d8e8f9; }

.truncate-cell {
    display: block;
    width: 160px;
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 10px;
}

.col-span-2 {
    grid-column: span 2;
}

label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-muted);
    font-size: 13px;
}

input, select, textarea, button {
    width: 100%;
    border-radius: 10px;
    border: 1px solid rgba(168, 204, 235, 0.22);
    padding: 9px 11px;
    color: var(--text);
    background: rgba(8, 20, 38, 0.75);
    font: inherit;
}

textarea { min-height: 76px; resize: vertical; }

button {
    cursor: pointer;
    background: linear-gradient(180deg, var(--brand), var(--brand-strong));
    border: 1px solid rgba(117, 188, 238, 0.5);
    font-weight: 700;
    transition: transform 0.12s ease, filter 0.15s ease;
}

button:hover {
    filter: brightness(1.06);
    transform: translateY(-1px);
}

.btn-inline {
    width: auto;
    padding: 8px 12px;
}

.badge {
    display: inline-block;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    background: rgba(22, 56, 96, 0.75);
    color: #cbe7ff;
}

.code {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    background: rgba(6, 18, 34, 0.8);
    border: 1px solid rgba(168, 204, 235, 0.2);
    border-radius: 10px;
    padding: 12px;
    color: #d7ebff;
    font-family: Consolas, "Courier New", monospace;
    font-size: 13px;
}

ul {
    margin: 8px 0 0 18px;
    color: var(--text-muted);
}

.level-ERROR { color: var(--danger); font-weight: 700; }
.level-WARN { color: var(--warn); font-weight: 700; }
.level-INFO { color: #7ad0ff; font-weight: 700; }
.level-DEBUG { color: #c8adff; font-weight: 700; }
.level-SUCCESS { color: var(--ok); font-weight: 700; }
.level-FAILED { color: var(--danger); font-weight: 700; }
.level-WARNING { color: var(--warn); font-weight: 700; }
.level-UNCLASSIFIED { color: #ffffff; font-weight: 700; }

.login-shell {
    min-height: calc(100vh - 64px);
    display: grid;
    place-items: center;
}

.login-card {
    max-width: 460px;
    width: 100%;
}

.login-logo {
    width: 88px;
    height: 88px;
    object-fit: contain;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    padding: 8px;
    margin-bottom: 12px;
}

.login-title {
    margin: 0;
    font-size: 30px;
}

.error {
    margin-bottom: 12px;
    color: #ffd3d3;
    background: rgba(128, 28, 28, 0.35);
    border: 1px solid rgba(246, 127, 127, 0.42);
    padding: 10px 12px;
    border-radius: 10px;
}

@media (max-width: 700px) {
    .container { padding: 20px 14px 28px; }
    table { min-width: 620px; }
    .ai-fab {
        right: 14px;
        bottom: 14px;
        width: 62px;
        height: 62px;
    }
    .ai-widget-panel {
        right: 14px;
        left: 14px;
        bottom: 88px;
        width: auto;
    }
    .ai-chat-log {
        height: 300px;
    }
    .page-header {
        justify-content: flex-start;
        gap: 10px;
    }
    .pagination-tools {
        width: 100%;
        justify-content: flex-start;
    }
    .header-logo-link {
        order: 1;
    }
    .nav-toggle {
        display: inline-flex !important;
        order: 2;
    }
    .nav {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        background: rgba(8, 22, 43, 0.92);
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: 10px;
        order: 3;
    }
    .nav.open {
        display: flex;
    }
    .nav a {
        width: 100%;
        display: block;
    }
    .nav-dropdown {
        width: 100%;
    }
    .nav-dropdown-toggle {
        width: 100%;
    }
    .nav-dropdown-menu {
        position: static;
        display: block;
        margin-top: 6px;
        box-shadow: none;
    }
    .user-chip {
        width: 100%;
        text-align: center;
    }
}
