/* Stock Research Agent - Dark Theme */

/* ========== CSS Variables (Phase 20) ========== */
:root {
    /* 배경 */
    --color-bg-primary:    #0d0d1a;
    --color-bg-secondary:  #12122a;
    --color-bg-tertiary:   #16162e;
    --color-bg-row-hover:  #161628;

    /* 보더 */
    --color-border-primary:  #1e1e3f;
    --color-border-active:   #1e1e4f;
    --color-border-secondary: #2a2a4a;

    /* 텍스트 */
    --color-text-primary:   #e0e0e0;
    --color-text-secondary: #c0c0d8;
    --color-text-muted:     #a0a0c0;
    --color-text-subtle:    #5a5a7a;
    --color-text-dim:       #4a4a6a;
    --color-text-faint:     #7a7a9a;
    --color-text-github:    #8b949e;

    /* 액센트 */
    --color-accent:         #7aa2f7;
    --color-accent-hover:   #9ab8ff;

    /* 버튼 */
    --color-btn-primary:       #3b5bdb;
    --color-btn-primary-hover: #4c6ef5;
    --color-btn-danger:        #c92a2a;
    --color-btn-danger-hover:  #e03131;

    /* 상태 */
    --color-success:      #2ecc71;
    --color-warning:      #f39c12;
    --color-danger:       #e74c3c;
    --color-warning-alt:  #e67e22;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    font-family: 'Noto Sans KR', 'Apple SD Gothic Neo', sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

/* ========== Top Navigation (Phase 20) ========== */
.topnav {
    background: var(--color-bg-secondary);
    height: 48px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--color-border-primary);
    z-index: 200;
    gap: 1.5rem;
}

.topnav-logo a {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-accent);
    text-decoration: none;
    white-space: nowrap;
}

.topnav-tabs {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
}

.topnav-tab {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
}

.topnav-tab:hover,
.topnav-tab-group:hover > .topnav-tab {
    color: var(--color-text-primary);
    background: var(--color-border-primary);
}

.topnav-tab-group.active > .topnav-tab,
a.topnav-tab.active {
    color: var(--color-accent);
    background: var(--color-border-active);
}

/* Dropdown submenu */
.topnav-tab-group {
    position: relative;
}

.topnav-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    padding-top: 4px;
    left: 0;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-primary);
    border-radius: 8px;
    padding: 0.5rem 0;
    min-width: 160px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 300;
}

.topnav-tab-group:hover .topnav-dropdown {
    display: block;
}

.topnav-dropdown-item {
    display: block;
    color: var(--color-text-muted);
    text-decoration: none;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    transition: background 0.1s, color 0.1s;
}

.topnav-dropdown-item:hover {
    background: var(--color-border-primary);
    color: var(--color-text-primary);
    text-decoration: none;
}

.topnav-dropdown-item--disabled {
    color: var(--color-text-subtle);
    cursor: default;
}

.topnav-dropdown-item--disabled:hover {
    background: none;
    color: var(--color-text-subtle);
}

/* Hamburger button */
.topnav-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
}

.topnav-hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--color-text-muted);
    border-radius: 2px;
    transition: background 0.15s;
}

.topnav-hamburger:hover span {
    background: var(--color-text-primary);
}

/* Mobile overlay */
.topnav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 400;
}

.topnav-overlay.is-open {
    display: block;
}

.overlay-panel {
    background: var(--color-bg-secondary);
    width: 280px;
    height: 100%;
    padding: 1rem;
    overflow-y: auto;
    animation: slideIn 0.25s ease;
}

@keyframes slideIn {
    from { transform: translateX(-280px); }
    to   { transform: translateX(0); }
}

.overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border-primary);
}

.overlay-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-accent);
}

.overlay-close {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

.overlay-close:hover {
    color: var(--color-text-primary);
}

/* Direct link items (no submenu) */
.overlay-direct-link {
    display: block;
    padding: 0.625rem 0.75rem;
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.overlay-direct-link:hover {
    background: var(--color-border-primary);
    color: var(--color-text-primary);
    text-decoration: none;
}

.overlay-direct-link.active {
    color: var(--color-accent);
    background: var(--color-border-active);
}

/* Accordion groups */
.overlay-group {
    margin-bottom: 0.125rem;
}

.overlay-group-header {
    display: block;
    width: 100%;
    padding: 0.625rem 0.75rem;
    color: var(--color-text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.overlay-group-header:hover {
    background: var(--color-border-primary);
    color: var(--color-text-primary);
}

.overlay-group-header::after {
    content: " \25be";
    float: right;
    color: var(--color-text-subtle);
}

.overlay-group.is-expanded > .overlay-group-header::after {
    content: " \25b4";
}

.overlay-group-items {
    display: none;
    padding-left: 1rem;
}

.overlay-group.is-expanded > .overlay-group-items {
    display: block;
}

.overlay-group-items a {
    display: block;
    padding: 0.5rem 0.75rem;
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 0.8125rem;
    border-radius: 4px;
    transition: background 0.1s, color 0.1s;
}

.overlay-group-items a:hover {
    background: var(--color-border-primary);
    color: var(--color-text-primary);
    text-decoration: none;
}

.overlay-disabled-item {
    display: block;
    padding: 0.5rem 0.75rem;
    color: var(--color-text-subtle);
    font-size: 0.8125rem;
    cursor: default;
}

/* ========== Main Content ========== */
.content {
    margin-left: 0;
    padding-top: calc(48px + 1.5rem);
    padding-left: 2rem;
    padding-right: 2rem;
    padding-bottom: 2rem;
    min-height: 100vh;
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: 1.5rem;
}

h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 1rem;
}

h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
}

p {
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
}

a {
    color: var(--color-accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
    color: var(--color-accent-hover);
}

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    border: none;
    transition: background 0.15s, opacity 0.15s;
}

.btn-primary {
    background: var(--color-btn-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--color-btn-primary-hover);
    color: #fff;
    text-decoration: none;
}

.btn-secondary {
    background: var(--color-border-primary);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border-secondary);
}

.btn-secondary:hover {
    background: var(--color-border-secondary);
    color: var(--color-text-primary);
    text-decoration: none;
}

.btn-danger {
    background: var(--color-btn-danger);
    color: #fff;
}

.btn-danger:hover {
    background: var(--color-btn-danger-hover);
    color: #fff;
    text-decoration: none;
}

/* ========== Forms ========== */
.form-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-primary);
    border-radius: 10px;
    padding: 2rem;
    max-width: 640px;
}

.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: 0.375rem;
}

input[type="text"],
input[type="date"],
input[type="search"],
select,
textarea {
    width: 100%;
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border-secondary);
    border-radius: 6px;
    color: var(--color-text-primary);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-family: inherit;
    transition: border-color 0.15s;
    outline: none;
}

input[type="text"]:focus,
input[type="date"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
    border-color: var(--color-btn-primary);
    box-shadow: 0 0 0 2px rgba(59, 91, 219, 0.2);
}

input::placeholder,
textarea::placeholder {
    color: var(--color-text-dim);
}

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

.form-hint {
    font-size: 0.75rem;
    color: var(--color-text-subtle);
    margin-top: 0.25rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* ========== Tables ========== */
.table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--color-border-primary);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-bg-secondary);
}

thead {
    background: var(--color-bg-tertiary);
}

th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-faint);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--color-border-primary);
}

td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-bg-row-hover);
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: var(--color-bg-row-hover);
}

/* ========== Cards ========== */
.card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-primary);
    border-radius: 10px;
    padding: 1.5rem;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-primary);
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
}

.stat-card .stat-label {
    font-size: 0.75rem;
    color: var(--color-text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-accent);
}

/* ========== Collector Status Cards ========== */
.collector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.collector-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-primary);
    border-radius: 10px;
    padding: 1.25rem;
}

.collector-card .collector-header {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-bottom: 0.75rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.ok {
    background: var(--color-success);
    box-shadow: 0 0 6px rgba(46, 204, 113, 0.5);
}

.status-dot.warning {
    background: var(--color-warning);
    box-shadow: 0 0 6px rgba(243, 156, 18, 0.5);
}

.status-dot.error {
    background: var(--color-danger);
    box-shadow: 0 0 6px rgba(231, 76, 60, 0.5);
}

.collector-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

.collector-meta {
    font-size: 0.75rem;
    color: var(--color-text-subtle);
    margin-top: 0.25rem;
}

.collector-error {
    font-size: 0.75rem;
    color: var(--color-danger);
    margin-top: 0.375rem;
    word-break: break-word;
}

/* ========== Search Bar ========== */
.search-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    align-items: center;
}

.search-bar input {
    max-width: 360px;
}

/* ========== Page Header ========== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    margin-bottom: 0;
}

/* ========== Status Badges ========== */
.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-ok {
    background: rgba(46, 204, 113, 0.15);
    color: var(--color-success);
}

.badge-warning {
    background: rgba(243, 156, 18, 0.15);
    color: var(--color-warning);
}

.badge-error {
    background: rgba(231, 76, 60, 0.15);
    color: var(--color-danger);
}

.badge-neutral {
    background: rgba(160, 160, 192, 0.12);
    color: var(--color-text-muted);
}

/* Phase 18: Earnings D-N badge */
.badge-earnings {
    background: rgba(243, 156, 18, 0.2);
    color: var(--color-warning);
    border: 1px solid rgba(243, 156, 18, 0.3);
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: 600;
}

/* Phase 18 D-11: D-3~D-1 urgent (orange) */
.badge-earnings-urgent {
    background: rgba(230, 126, 34, 0.2);
    color: var(--color-warning-alt);
    border: 1px solid rgba(230, 126, 34, 0.3);
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: 600;
}

/* Phase 18 D-11: D-DAY critical (red) */
.badge-earnings-critical {
    background: rgba(231, 76, 60, 0.2);
    color: var(--color-danger);
    border: 1px solid rgba(231, 76, 60, 0.3);
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: 600;
}

/* Phase 18 D-13: mobile badge inline container (hidden on desktop) */
.mobile-badges {
    display: none;
}

/* Phase 18: +new document badge (JS-injected) */
.badge-new {
    background: rgba(122, 162, 247, 0.2);
    color: var(--color-accent);
    border: 1px solid rgba(122, 162, 247, 0.4);
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: 600;
    margin-left: 0.25rem;
}

/* ========== Alerts ========== */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.alert-error {
    background: rgba(231, 76, 60, 0.1);
    border: 1px solid rgba(231, 76, 60, 0.3);
    color: var(--color-danger);
}

.alert-success {
    background: rgba(46, 204, 113, 0.1);
    border: 1px solid rgba(46, 204, 113, 0.3);
    color: var(--color-success);
}

/* ========== Section Separator ========== */
.section {
    margin-bottom: 2.5rem;
}

.section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border-primary);
}

/* ========== Phase 3: Report Styles ========== */
.conflict-block {
    background: rgba(243, 156, 18, 0.07);
    border: 1px solid rgba(243, 156, 18, 0.25);
    border-radius: 6px;
    padding: 0.5rem 1rem;
    margin: 0.5rem 0;
}

.conflict-block .conflict-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-warning);
    margin-bottom: 0.5rem;
}

/* ========== Phase 12: Conflict Severity ========== */
.conflict-block--critical {
    background: rgba(231, 76, 60, 0.08);
    border-color: rgba(231, 76, 60, 0.25);
}
.conflict-block--critical .conflict-label {
    color: var(--color-danger);
}

.conflict-block--minor {
    background: rgba(139, 148, 158, 0.08);
    border-color: rgba(139, 148, 158, 0.2);
}
.conflict-block--minor .conflict-label {
    color: var(--color-text-github);
}

.conflict-severity-heading {
    font-size: 0.875rem;
    font-weight: 700;
    margin: 1rem 0 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--color-border-primary);
}

.citation-ref {
    color: var(--color-accent);
    font-size: 0.75rem;
    vertical-align: super;
    cursor: pointer;
    text-decoration: none;
}

.citation-ref a {
    color: var(--color-accent);
    text-decoration: none;
}

.citation-ref a:hover {
    text-decoration: underline;
}

.citation-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.citation-list li {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-bg-row-hover);
}

.citation-list li:last-child {
    border-bottom: none;
}

/* Alert info style for queue confirmation */
.alert-info {
    background: rgba(122, 162, 247, 0.1);
    border: 1px solid rgba(122, 162, 247, 0.3);
    color: var(--color-accent);
}

/* ========== Phase 4: Chart Container ========== */
.chart-container {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-primary);
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.chart-container canvas {
    min-height: 300px;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .topnav-tabs { display: none; }
    .topnav-hamburger { display: flex; margin-left: auto; }

    .content {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Phase 18 D-13: hide badge column header and cells on mobile */
    th.badge-col-header,
    td.badge-col-cell {
        display: none;
    }

    /* Phase 18 D-13: show inline badges after company name on mobile */
    .mobile-badges {
        display: inline-flex;
        gap: 0.25rem;
        margin-left: 0.5rem;
    }
}

/* ========== Phase 5: Reliability ========== */
.reliability-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    vertical-align: middle;
    margin-right: 4px;
}
.reliability-dot--ok      { background: var(--color-success); box-shadow: 0 0 6px rgba(46,204,113,0.5); }
.reliability-dot--warning { background: var(--color-warning); box-shadow: 0 0 6px rgba(243,156,18,0.5); }
.reliability-dot--error   { background: var(--color-danger); box-shadow: 0 0 6px rgba(231,76,60,0.5); }

.reliability-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}
.reliability-badge--ok      { background: rgba(46,204,113,0.15); color: var(--color-success); }
.reliability-badge--warning { background: rgba(243,156,18,0.15);  color: var(--color-warning); }
.reliability-badge--error   { background: rgba(231,76,60,0.15);   color: var(--color-danger); }

.source-tabs {
    display: flex;
    border-bottom: 1px solid var(--color-border-primary);
    margin-bottom: 16px;
    gap: 0;
}
.source-tab {
    padding: 8px 16px;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    user-select: none;
    transition: color 0.15s;
}
.source-tab:hover         { color: var(--color-text-primary); }
.source-tab--active       { color: var(--color-accent); font-weight: 700; border-bottom-color: var(--color-accent); }

.source-tab-panel         { display: none; }
.source-tab-panel.active  { display: block; }

.source-doc-item          { display: flex; justify-content: space-between; align-items: flex-start; padding: 16px 0; border-bottom: 1px solid var(--color-bg-row-hover); }
.source-doc-item:last-child { border-bottom: none; }
.source-doc-title         { font-weight: 700; color: var(--color-text-secondary); font-size: 0.875rem; }
.source-doc-preview       { font-size: 0.75rem; color: var(--color-text-subtle); margin-top: 4px; }
.source-doc-meta          { font-size: 0.75rem; color: var(--color-text-subtle); text-align: right; flex-shrink: 0; margin-left: 16px; }

/* ========== Phase 6: Sector Tree ========== */
.sector-tree { margin-bottom: 1.5rem; }
.sector-node { margin-bottom: 0.5rem; border: 1px solid var(--color-border-primary); border-radius: 8px; overflow: hidden; }
.sector-node__header { display: flex; align-items: center; gap: 0.5rem; padding: 0.75rem 1rem; cursor: pointer; background: var(--color-bg-secondary); min-height: 44px; }
.sector-node__header:hover { background: var(--color-bg-row-hover); }
.sector-node__toggle { color: var(--color-text-muted); font-size: 0.75rem; cursor: pointer; user-select: none; width: 1rem; text-align: center; background: none; border: none; padding: 0; font-family: inherit; }
.sector-node__name { font-size: 0.875rem; font-weight: 700; color: var(--color-text-secondary); }
.sector-node__meta { font-size: 0.75rem; color: var(--color-text-subtle); }
.sector-node__companies { padding: 0 0.5rem 0.5rem 0.5rem; }
.sector-node__companies table { width: 100%; }

.conflict-reason          { font-size: 0.75rem; color: var(--color-text-subtle); margin-top: 8px; font-style: italic; }
.empty-tab-message        { text-align: center; padding: 24px; color: var(--color-text-subtle); font-size: 0.875rem; }

/* === Phase 7: Industry Report === */

.industry-report-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.compare-col {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-primary);
    border-radius: 10px;
    padding: 1.5rem;
}

.compare-col__header {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--color-text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border-primary);
}

/* ========== Search Page (Phase 10) ========== */
.search-page-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.search-page-bar input[type="text"] {
    flex: 1;
    max-width: 480px;
}

.filter-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.filter-bar select {
    max-width: 200px;
}

.filter-bar input[type="date"] {
    max-width: 140px;
}

.sort-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.sort-btn {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    text-decoration: none;
}

.sort-btn.active {
    color: var(--color-accent);
    background: rgba(122, 162, 247, 0.1);
}

.sort-btn:hover {
    color: var(--color-accent);
}

.search-results-list {
    border-top: 1px solid var(--color-border-primary);
}

.search-result-item {
    padding: 16px 0;
    border-bottom: 1px solid var(--color-bg-row-hover);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-title {
    font-size: 0.875rem;
    font-weight: 700;
}

.search-result-title a {
    color: var(--color-text-secondary);
    text-decoration: none;
}

.search-result-title a:hover {
    color: var(--color-accent);
    text-decoration: underline;
}

.search-result-snippet {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    line-height: 1.6;
}

.search-result-snippet mark {
    background: rgba(122, 162, 247, 0.25);
    color: var(--color-accent);
    border-radius: 2px;
    padding: 0 4px;
}

.search-result-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.75rem;
    color: var(--color-text-subtle);
}

.pagination-bar {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.page-btn {
    min-width: 36px;
    text-align: center;
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-primary);
    border-radius: 4px;
    text-decoration: none;
}

.page-btn:hover {
    color: var(--color-accent);
    border-color: var(--color-btn-primary);
}

.page-btn.current {
    background: var(--color-border-active);
    color: var(--color-accent);
    border-color: var(--color-btn-primary);
}

.fallback-notice {
    margin-bottom: 1rem;
}

/* ========== Phase 13: Report Diff View ========== */

/* Diff meta bar */
.diff-meta-bar {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-primary);
    border-radius: 6px;
    margin-bottom: 1.5rem;
    font-size: 0.75rem;
}
.diff-meta-bar__col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.diff-meta-bar__label {
    color: var(--color-text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.diff-meta-bar__value {
    color: var(--color-text-secondary);
    font-weight: 700;
}
.diff-meta-bar__divider {
    width: 1px;
    background: var(--color-border-primary);
    align-self: stretch;
}

/* Summary card */
.diff-summary-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-primary);
    border-radius: 6px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}
.diff-summary-card__header {
    color: var(--color-text-subtle);
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.06em;
    margin-bottom: 0.75rem;
}
.diff-summary-card__bullets {
    list-style: none;
    padding: 0;
    margin: 0;
}
.diff-summary-card__bullets li {
    color: var(--color-text-secondary);
    line-height: 1.8;
    padding-left: 1rem;
    position: relative;
}
.diff-summary-card__bullets li::before {
    content: "\2022";
    position: absolute;
    left: 0;
    color: var(--color-accent);
}

/* Diff section */
.diff-section {
    margin-bottom: 2rem;
}
.diff-section__header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 44px;
    cursor: pointer;
    list-style: none;
    padding: 0.5rem 0;
}
.diff-section__header::-webkit-details-marker {
    display: none;
}
.diff-section__header h2 {
    margin: 0;
}

/* Diff lines */
.diff-lines {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-primary);
    border-radius: 6px;
    overflow: hidden;
    margin-top: 0.5rem;
}
.diff-line {
    display: flex;
    padding: 0.25rem 1rem;
    font-size: 0.875rem;
}
.diff-line--add {
    background: rgba(46, 204, 113, 0.12);
    color: var(--color-text-secondary);
}
.diff-line--remove {
    background: rgba(231, 76, 60, 0.12);
    color: var(--color-text-secondary);
}
.diff-line--equal {
    background: transparent;
    color: var(--color-text-subtle);
}
.diff-line__gutter {
    width: 20px;
    flex-shrink: 0;
    color: var(--color-text-subtle);
    font-weight: 700;
    user-select: none;
    padding-left: 0.5rem;
}
.diff-line__gutter--add {
    color: var(--color-success);
}
.diff-line__gutter--remove {
    color: var(--color-danger);
}
.diff-line__text {
    flex: 1;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Investment points diff */
.invest-diff {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.invest-diff__category {
    color: var(--color-text-subtle);
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.06em;
    margin-top: 0.75rem;
    margin-bottom: 0.25rem;
}
.invest-diff__item {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    font-size: 0.875rem;
}
.invest-diff__item--add {
    color: var(--color-text-secondary);
}
.invest-diff__item--remove {
    color: var(--color-text-subtle);
    text-decoration: line-through;
}
.invest-diff__item--unchanged {
    color: var(--color-text-subtle);
}
.invest-diff__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}
.invest-diff__badge--add {
    background: rgba(46, 204, 113, 0.2);
    color: var(--color-success);
}
.invest-diff__badge--remove {
    background: rgba(231, 76, 60, 0.2);
    color: var(--color-danger);
}
.invest-diff__badge--unchanged {
    background: rgba(160, 160, 192, 0.1);
    color: var(--color-text-subtle);
}

/* Change count badge */
.diff-change-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
}
.diff-change-badge--modified {
    background: rgba(122, 162, 247, 0.15);
    color: var(--color-accent);
}
.diff-change-badge--unchanged {
    background: rgba(160, 160, 192, 0.08);
    color: var(--color-text-subtle);
}

/* Version selector in history page */
.diff-version-select {
    margin-bottom: 1.5rem;
}
.diff-version-radio {
    display: block;
    min-height: 44px;
    padding: 0.5rem 0;
    cursor: pointer;
    color: var(--color-text-secondary);
}
.diff-version-radio input[type="radio"] {
    margin-right: 0.5rem;
}

/* ========== Phase 14: Comparison Matrix ========== */

/* Sector recommendation chips */
.sector-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.sector-chip {
    background: var(--color-border-primary);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border-secondary);
    border-radius: 14px;
    padding: 4px 12px;
    font-size: 0.75rem;
    font-weight: 400;
    font-family: inherit;
    height: 28px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.sector-chip:hover {
    background: var(--color-border-secondary);
    color: var(--color-text-primary);
}

.sector-chip:focus {
    border-color: var(--color-btn-primary);
    box-shadow: 0 0 0 2px rgba(59, 91, 219, 0.2);
    outline: none;
}

/* Investment matrix table */
.matrix-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-bg-secondary);
}

.matrix-table th {
    min-height: 44px;
}

.matrix-table td {
    padding: 12px 16px;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    line-height: 1.5;
    vertical-align: top;
}

.matrix-category-label {
    font-weight: 700;
    color: var(--color-text-secondary);
    background: var(--color-bg-tertiary);
    width: 120px;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    vertical-align: top;
}

.matrix-category-border td {
    border-top: 1px solid var(--color-border-primary);
}

.matrix-no-report {
    color: var(--color-text-subtle);
    font-style: italic;
    text-align: center;
    vertical-align: middle;
}

/* Radar chart canvas override */
.chart-container canvas#radarChart {
    min-height: 320px;
}

/* Phase 17: Upload area for file inputs */
.upload-area {
    border: 2px dashed var(--color-border-secondary);
    border-radius: 8px;
    padding: 32px 16px;
    text-align: center;
    color: var(--color-text-subtle);
    background: var(--color-bg-primary);
}

.upload-area:hover {
    border-color: var(--color-btn-primary);
}

/* Phase 17: URL extraction preview box */
.url-preview {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-primary);
    border-radius: 8px;
    padding: 16px;
    margin-top: 16px;
    display: none;
}

.url-preview.visible {
    display: block;
}

/* Phase 17: Processing status indicator (static text, no animation) */
.processing-spinner {
    display: inline;
}

/* ========== Phase 19: Monitoring & Notification ========== */

.monitoring-table {
    width: 100%;
    border-collapse: collapse;
}

.notif-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--color-border-primary);
}

.notif-row:last-child {
    border-bottom: none;
}

.threshold-input {
    width: 64px;
    text-align: center;
}

details.log-accordion {
    margin-top: 0.5rem;
}

details.log-accordion > summary {
    cursor: pointer;
    list-style: none;
    padding: 0.5rem 0;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    font-weight: 700;
}

details.log-accordion > summary::-webkit-details-marker {
    display: none;
}

details.log-accordion[open] > summary::after {
    content: " \25b4";
}

details.log-accordion:not([open]) > summary::after {
    content: " \25be";
}

/* ───── Earnings Calendar (Phase 20) ───── */
.calendar-table td {
    vertical-align: top;
    min-height: 130px;
    height: 130px;
    border: 1px solid var(--color-border-primary);
    padding: 0.35rem;
    font-size: 0.8rem;
}
.calendar-table .cal-day-num {
    font-size: 0.8rem;
    text-align: right;
    margin-bottom: 0.25rem;
}
.calendar-table tbody tr td:nth-child(6),
.calendar-table tbody tr td:nth-child(7) {
    color: var(--color-danger);
}

/* Global search bar (Phase 22 D-03) */
.topnav-search {
    display: flex;
    align-items: center;
    margin-left: auto;
}

.topnav-search-input {
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border-primary);
    border-radius: 6px;
    color: var(--color-text-primary);
    font-size: 0.8rem;
    padding: 0.25rem 0.6rem;
    width: 180px;
    font-family: inherit;
}

.topnav-search-input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.topnav-search-input::placeholder {
    color: var(--color-text-muted);
}

/* Mobile overlay search (Phase 22 D-05) */
.overlay-search {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border-primary);
}

.overlay-search-input {
    width: 100%;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border-primary);
    border-radius: 6px;
    color: var(--color-text-primary);
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    font-family: inherit;
}

.overlay-search-input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.overlay-search-input::placeholder {
    color: var(--color-text-muted);
}

/* === Source / Collector Tabs (Phase 29.4 — D-11) === */
.source-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #1e1e3f;
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.source-tab {
    padding: 0.625rem 1.25rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #5a5a7a;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
    text-decoration: none;
}

.source-tab:hover {
    color: #a0a0c0;
}

.source-tab.active {
    color: #7aa2f7;
    border-bottom-color: #7aa2f7;
}

.source-panel {
    display: none;
}

.source-panel.active {
    display: block;
}
