:root {
    --gm3-primary: #0B57D0;
    --gm3-primary-container: #D3E3FD;
    --gm3-on-primary-container: #041E49;
    --gm3-bg: #F4F7FC;
    --gm3-surface: #FFFFFF;
    --gm3-text-main: #1F1F1F;
    --gm3-text-muted: #444746;
    --gm3-border: #E0E2E0;
    --gm3-error: #B3261E;
}

body {
    background-color: var(--gm3-bg);
    font-family: 'Noto Sans TC', sans-serif;
    color: var(--gm3-text-main);
    height: 100vh;
    overflow: hidden;
    margin: 0;
}

.navbar {
    background-color: var(--gm3-bg) !important;
    padding: 12px 24px;
}

.navbar-brand {
    color: var(--gm3-text-main) !important;
    font-weight: 500;
    font-size: 22px;
}

.layout-container {
    display: flex;
    height: calc(100vh - 64px);
    padding: 0 16px 16px 16px;
    gap: 16px;
}

.side-panel {
    width: 400px;
    background: var(--gm3-surface);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow: hidden;
    padding-right: 8px;
}

.gm-card {
    background: var(--gm3-surface);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.chat-history {
    flex-grow: 1;
    overflow-y: auto;
    margin-bottom: 16px;
    padding-right: 8px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.msg-user {
    align-self: flex-end;
    background-color: var(--gm3-primary-container);
    color: var(--gm3-on-primary-container);
    padding: 12px 16px;
    border-radius: 20px 20px 4px 20px;
    max-width: 85%;
    font-size: 14px;
}

.msg-ai {
    align-self: flex-start;
    background-color: #F0F4F9;
    color: var(--gm3-text-main);
    padding: 12px 16px;
    border-radius: 20px 20px 20px 4px;
    max-width: 90%;
    font-size: 14px;
    line-height: 1.6;
}

.input-area {
    background: #F0F4F9;
    border-radius: 28px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
}

.input-area input {
    border: none;
    background: transparent;
    box-shadow: none;
    flex-grow: 1;
}

.input-area input:focus {
    outline: none;
    box-shadow: none;
}

.btn-send {
    background-color: var(--gm3-primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.chart-container {
    min-height: 180px;
    height: 180px;
}

#chartCard {
    flex-shrink: 0;
}

#tableCard {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.table-responsive {
    border-radius: 12px;
    border: 1px solid var(--gm3-border);
    flex-grow: 1;
    overflow-y: auto;
    background-color: var(--gm3-surface);
}

.table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background-color: #F8F9FA;
    border-bottom: 2px solid var(--gm3-border);
    font-weight: 500;
    color: var(--gm3-text-muted);
}

.table tbody td {
    vertical-align: middle;
}

#alertBanner {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1050;
    background-color: var(--gm3-error);
    color: white;
    padding: 12px 24px;
    border-radius: 100px;
    display: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
/* ================================
   System Log Panel（Google Light）
================================ */

.system-log-panel {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin: 12px 0;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    font-size: 13px;
}

/* Header */
.system-log-header {
    padding: 10px 14px;
    color: #1f2937;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f9fafb;
    user-select: none;
}

/* hover：非常淡，不要太誇張 */
.system-log-header:hover {
    background: #f3f4f6;
}

/* 數量 badge（Google 藍） */
.system-log-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    margin-left: 6px;
    border-radius: 999px;
    background: #e8f0fe;
    color: #1a73e8;
    font-size: 11px;
    font-weight: 500;
}

/* Body */
.system-log-body {
    padding: 10px 14px;
    color: #4b5563;
    max-height: 220px;
    overflow-y: auto;
}

/* 收合 */
.system-log-panel.collapsed .system-log-body {
    display: none;
}

/* 每一行 */
.system-log-item {
    padding: 6px 0;
    border-bottom: 1px solid #f1f5f9;
    line-height: 1.5;
    font-size: 12.5px;
}

.system-log-item:last-child {
    border-bottom: none;
}

/* 分類顏色（Google palette） */
.system-log-item.system {
    color: #374151;
}

.system-log-item.success {
    color: #188038; /* Google green */
}

.system-log-item.warning {
    color: #b06000; /* Google amber */
}

.system-log-item.error {
    color: #d93025; /* Google red */
}
/* ================================
   Decision Insight Panel
================================ */

.decision-insight-panel {
    background: #ffffff;
    border: 1px solid var(--gm3-border);
    border-radius: 18px;
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    max-height: 260px;
    overflow-y: auto;
    flex-shrink: 0;
}

.decision-insight-panel.empty {
    display: none;
}

.decision-title {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--gm3-primary);
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 10px;
}

.decision-section {
    background: #f8fafc;
    border-radius: 12px;
    padding: 10px 12px;
    margin-top: 8px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--gm3-text-main);
}

.decision-section-label {
    color: var(--gm3-text-muted);
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 4px;
}
.decision-section.compact-only {
    max-height: 90px;
    overflow-y: auto;
}
.risk-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 700;
}

.risk-high {
    background: #fce8e6;
    color: #d93025;
}

.risk-medium {
    background: #fef7e0;
    color: #b06000;
}

.risk-low {
    background: #e6f4ea;
    color: #188038;
}
.supplier-recommend-item {
    padding: 8px 0;
    border-bottom: 1px solid #eef2f7;
}

.supplier-recommend-item:last-child {
    border-bottom: none;
}
.impact-reply-card {
    max-width: 100%;
}

.impact-reply-title {
    font-weight: 700;
    color: var(--gm3-primary);
    margin-bottom: 8px;
}

.impact-reply-section {
    margin-bottom: 10px;
    line-height: 1.7;
}

.impact-reply-card details {
    margin-top: 8px;
    background: #f8fafc;
    border-radius: 12px;
    padding: 10px 12px;
}

.impact-reply-card summary {
    cursor: pointer;
    color: var(--gm3-primary);
    font-weight: 600;
}

.impact-reply-subtitle {
    font-weight: 700;
    color: var(--gm3-text-muted);
    margin-top: 10px;
    margin-bottom: 4px;
    font-size: 13px;
}

.impact-reply-card ul {
    padding-left: 18px;
    margin-bottom: 6px;
}