@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&display=swap');

:root {
    --primary:       #2563EB;
    --primary-hover: #1D4ED8;
    --primary-light: #EFF6FF;
    --bg:            #F3F4F6;
    --card:          #FFFFFF;
    --text:          #111827;
    --text-muted:    #6B7280;
    --border:        #E5E7EB;
    --success:       #10B981;
    --error:         #EF4444;
    --radius:        12px;
    --radius-sm:     8px;
}

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

body {
    font-family: 'Sarabun', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

#app {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

/* ── Header ─────────────────────────────────────────────── */
.app-header {
    background: var(--primary);
    color: white;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}

.app-title {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Mode Tabs ───────────────────────────────────────────── */
.mode-tabs {
    display: flex;
    background: var(--card);
    border-bottom: 1px solid var(--border);
}

.mode-tab {
    flex: 1;
    padding: 12px 6px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border-bottom: 2px solid transparent;
    transition: color .2s, border-color .2s;
    white-space: nowrap;
}

.mode-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ── Mode Panels ─────────────────────────────────────────── */
.mode-panel { display: none; flex-direction: column; }
.mode-panel.active { display: flex; }

/* ── Camera Container ────────────────────────────────────── */
.camera-container {
    position: relative;
    background: #111;
    width: 100%;
    aspect-ratio: 4/3;
    overflow: hidden;
}

.camera-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,.55);
}

.camera-overlay.hidden { display: none; }

.btn-start-camera {
    background: rgba(255,255,255,.12);
    border: 2px solid rgba(255,255,255,.45);
    color: white;
    border-radius: var(--radius);
    padding: 18px 28px;
    font-size: 15px;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    transition: background .2s;
}

.btn-start-camera:hover { background: rgba(255,255,255,.22); }

/* ── Camera Actions ──────────────────────────────────────── */
.camera-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--card);
    gap: 20px;
    border-bottom: 1px solid var(--border);
}

/* Shutter button */
.btn-capture {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 4px solid var(--border);
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .1s, box-shadow .1s;
    padding: 0;
}

.btn-capture:active { transform: scale(.93); }
.btn-capture:disabled { opacity: .4; cursor: not-allowed; }

.capture-ring {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: white;
    border: 2px solid #CCC;
    display: block;
    transition: background .1s;
}

.btn-capture:not(:disabled):active .capture-ring { background: #E5E7EB; }

/* Record button */
.btn-record {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 4px solid var(--border);
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color .2s;
    color: var(--error);
    padding: 0;
}

.btn-record:disabled { opacity: .4; cursor: not-allowed; }
.btn-record.recording { border-color: var(--error); }
.btn-record.recording svg { animation: pulse 1s infinite; }

.record-timer {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 56px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* Recording badge */
.recording-indicator {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(239,68,68,.9);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.rec-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
    animation: blink 1s infinite;
}

/* ── Upload Mode ─────────────────────────────────────────── */
.upload-area {
    margin: 16px;
    background: var(--card);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    min-height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color .2s, background .2s;
    position: relative;
}

.upload-area.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-placeholder {
    text-align: center;
    color: var(--text-muted);
    padding: 32px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.upload-placeholder svg { color: #D1D5DB; }
.upload-hint { font-size: 12px; }

.upload-preview {
    width: 100%;
    min-height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    position: relative;
}

.upload-preview img,
.upload-preview video {
    max-width: 100%;
    max-height: 280px;
    border-radius: var(--radius-sm);
    object-fit: contain;
}

.btn-remove-file {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,.5);
    color: white;
    border-radius: 50%;
    width: 32px;
    height: 32px;
}

.upload-actions { padding: 0 16px 16px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background .2s;
}

.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
    padding: 10px 18px;
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    transition: background .2s;
    white-space: nowrap;
}

.btn-secondary:hover { background: var(--bg); }
.btn-secondary.btn-sm { padding: 6px 12px; font-size: 13px; }

.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    color: inherit;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
    flex-shrink: 0;
}

.btn-icon:hover { background: rgba(0,0,0,.06); }

/* ── Loading Overlay ─────────────────────────────────────── */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.loading-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 32px 40px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

/* ── Results Panel ───────────────────────────────────────── */
.results-panel {
    background: var(--card);
    border-top: 2px solid var(--primary-light);
    padding: 16px;
    animation: slideUp .25s ease;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.results-header h2 { font-size: 16px; font-weight: 600; }

.results-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.results-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.result-field {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.result-field-icon { color: var(--primary); flex-shrink: 0; margin-top: 1px; }

.result-field-body { flex: 1; min-width: 0; }

.result-field-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 3px;
}

.result-field-value { font-size: 15px; word-break: break-word; line-height: 1.5; }

.btn-copy-field {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: color .2s;
    flex-shrink: 0;
}

.btn-copy-field:hover { color: var(--primary); }

/* ── No Results Panel ────────────────────────────────────── */
.no-results-panel {
    background: var(--card);
    border-top: 1px solid var(--border);
    padding: 40px 16px;
    animation: slideUp .25s ease;
}

.no-results-content {
    text-align: center;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

/* ── Toast ───────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: #1F2937;
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    z-index: 200;
    transition: transform .3s ease;
    white-space: nowrap;
    pointer-events: none;
}

.toast.show { transform: translateX(-50%) translateY(0); }

/* ── Animations ──────────────────────────────────────────── */
@keyframes spin     { to { transform: rotate(360deg); } }
@keyframes blink    { 0%,100% { opacity:1; } 50% { opacity:0; } }
@keyframes pulse    { 0%,100% { opacity:1; } 50% { opacity:.4; } }
@keyframes slideUp  { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:none; } }

/* ── DBD Section ─────────────────────────────────────────── */
.dbd-section {
    margin: 0 0 4px;
    border-top: 1px dashed var(--border);
    padding-top: 14px;
}

.dbd-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.dbd-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
}

.dbd-badge {
    background: #059669;
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    letter-spacing: .04em;
}

.dbd-status-label {
    font-size: 12px;
    color: var(--text-muted);
}

.dbd-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 14px;
    padding: 8px 0;
}

.spinner-sm {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    flex-shrink: 0;
}

.dbd-not-found {
    font-size: 13px;
    color: var(--text-muted);
    padding: 4px 0;
}

.dbd-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dbd-row {
    display: flex;
    gap: 8px;
    font-size: 14px;
    align-items: flex-start;
}

.dbd-label {
    color: var(--text-muted);
    font-size: 12px;
    min-width: 110px;
    flex-shrink: 0;
    padding-top: 1px;
}

.dbd-value {
    color: var(--text);
    flex: 1;
    word-break: break-word;
    line-height: 1.5;
}

.dbd-status-active {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #059669;
    font-weight: 500;
}

.dbd-status-active::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #059669;
    display: inline-block;
}

.dbd-status-inactive {
    color: var(--error);
}

.dbd-finance {
    margin-top: 10px;
    background: #F0FDF4;
    border: 1px solid #BBF7D0;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

.dbd-finance-title {
    font-size: 12px;
    font-weight: 600;
    color: #065F46;
    margin-bottom: 8px;
}

.dbd-finance-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 12px;
}

.dbd-finance-item {
    font-size: 13px;
}

.dbd-finance-label {
    color: #6B7280;
    font-size: 11px;
}

.dbd-finance-value {
    font-weight: 600;
    color: var(--text);
}

.dbd-finance-value.negative { color: var(--error); }
.dbd-finance-value.positive { color: #059669; }

/* ── Results Count Badge ─────────────────────────────────── */
.results-count {
    display: inline-flex;
    align-items: center;
    background: var(--primary);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    margin-left: 4px;
    vertical-align: middle;
}

/* ── Company Cards ───────────────────────────────────────── */
.company-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.company-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%);
    border-bottom: 1px solid var(--border);
}

.company-card-idx {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: var(--primary);
    color: white;
    font-size: 11px;
    font-weight: 700;
    border-radius: 50%;
    flex-shrink: 0;
}

.company-card-name {
    font-size: 14px;
    font-weight: 600;
    color: #1a2e5a;
    flex: 1;
    word-break: break-word;
}

.company-card-noname { color: var(--text-muted); font-style: italic; font-weight: 400; }

.company-card-body {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.company-card-empty {
    padding: 14px 16px;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
}

.company-card-footer {
    padding: 8px 10px 10px;
}

/* ── DataForThai Card Lookup Button ──────────────────────── */
.btn-lookup-dft-card {
    width: 100%;
    padding: 9px 12px;
    background: #F0FDF4;
    color: #065F46;
    border: 1.5px solid #A7F3D0;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    transition: background .2s, border-color .2s;
}

.btn-lookup-dft-card:hover { background: #D1FAE5; border-color: #6EE7B7; }
.btn-lookup-dft-card--open { background: #D1FAE5; border-color: #6EE7B7; }
.btn-lookup-dft-card--open .search-lookup-chevron { transform: rotate(180deg); }

/* ── DataForThai Inline Section ──────────────────────────── */
.dbd-section-card {
    border-top: 1px dashed var(--border);
    padding: 14px 12px 12px;
}

/* ── DataForThai Lookup Button (legacy, kept for compat) ─── */
.btn-lookup-dft {
    width: 100%;
    padding: 12px;
    background: #F0FDF4;
    color: #065F46;
    border: 1.5px solid #A7F3D0;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background .2s, border-color .2s;
    margin-bottom: 12px;
}

.btn-lookup-dft:hover:not(:disabled) { background: #D1FAE5; border-color: #6EE7B7; }
.btn-lookup-dft:disabled { opacity: .5; cursor: not-allowed; }

/* ── DFT Accordion ───────────────────────────────────────── */
.dft-accordion {
    margin-top: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.dft-accordion-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    background: var(--bg);
    list-style: none;
    user-select: none;
}

.dft-accordion-summary::-webkit-details-marker { display: none; }
.dft-accordion-summary span { flex: 1; }

.dft-chevron { flex-shrink: 0; transition: transform .2s; }
details[open] .dft-chevron { transform: rotate(180deg); }

.dft-accordion-body { padding: 10px 12px; }

/* ── DFT Investment Pills ─────────────────────────────────── */
.dft-invest-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.dft-invest-item {
    display: flex;
    gap: 6px;
    align-items: center;
    background: var(--primary-light);
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--primary);
}

/* ── DFT Chart Containers ────────────────────────────────── */
.dft-chart-container {
    position: relative;
    height: 220px;
    max-width: 300px;
    margin: 12px auto 8px;
}

.dft-chart-bar {
    max-width: 100%;
    height: 200px;
}

/* ── DFT Shareholder Table ───────────────────────────────── */
.dft-sh-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.dft-sh-table-wrap { overflow-x: auto; margin-top: 8px; }

.dft-sh-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.dft-sh-table th {
    background: var(--bg);
    padding: 6px 8px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.dft-sh-table td {
    padding: 6px 8px;
    font-size: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.dft-pct-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 90px;
    font-size: 11px;
}

.dft-pct-bar {
    height: 6px;
    background: var(--primary);
    border-radius: 3px;
    flex-shrink: 0;
    min-width: 2px;
}

/* ── DFT Company Header ─────────────────────────────────── */
.dft-co-header {
    background: linear-gradient(135deg, #0f2460 0%, #1a4b9e 55%, #1e88e5 100%);
    color: white;
    padding: 16px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.dft-co-name  { font-size: 1.05rem; font-weight: 700; line-height: 1.35; margin-bottom: 4px; word-break: break-word; }
.dft-co-ename { font-size: .82rem; opacity: .75; margin-bottom: 8px; }
.dft-co-badges { display: flex; flex-wrap: wrap; gap: 4px; }

.dft-badge {
    display: inline-flex; align-items: center;
    font-size: .73rem; padding: 2px 9px; border-radius: 20px;
    font-weight: 600; white-space: nowrap; cursor: default;
    border: none; font-family: inherit;
}
.dft-badge-active   { background: #22c55e; color: #fff; }
.dft-badge-inactive { background: #ef4444; color: #fff; }
.dft-badge-type     { background: rgba(255,255,255,.2); color: #fff; }
.dft-badge-grey     { background: rgba(255,255,255,.12); color: rgba(255,255,255,.85); cursor: pointer; }
.dft-badge-grey:hover { background: rgba(255,255,255,.25); }

/* ── DFT Metric Cards ────────────────────────────────────── */
.dft-metrics { display: flex; gap: 8px; padding: 10px 0 6px; flex-wrap: wrap; }

.dft-mc {
    flex: 1; min-width: 68px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 8px;
    text-align: center;
}

.dft-mc-val { font-size: .95rem; font-weight: 700; color: #1a2e5a; line-height: 1.2; margin-bottom: 3px; }
.dft-mc-lbl { font-size: .68rem; color: var(--text-muted); }

/* ── DFT Contact Pills ───────────────────────────────────── */
.dft-contact-row { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 0 4px; }

.contact-pill {
    display: inline-flex; align-items: center; gap: 5px;
    background: #F1F5F9; border-radius: 20px;
    padding: 4px 12px; font-size: .8rem; color: #334155;
    text-decoration: none; transition: background .2s;
}
.contact-pill:hover { background: #E2E8F0; color: #1e40af; }

/* ── DFT Director Cards ──────────────────────────────────── */
.dft-dir-list { display: flex; flex-direction: column; gap: 6px; }
.dir-item  { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; }
.dir-name  { font-weight: 600; color: #1a2e5a; font-size: .85rem; }
.dir-sub   { color: var(--text-muted); font-size: .78rem; margin-top: 2px; }

/* ── DFT Financial Ratios ────────────────────────────────── */
.dft-ratios-title { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; }

.dft-ratio-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

.dft-ratio-card {
    background: #F8FAFC;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    border-left: 3px solid #E2E8F0;
}
.dft-ratio-card.good { border-left-color: #22c55e; background: #F0FDF4; }
.dft-ratio-card.warn { border-left-color: #F59E0B; background: #FFFBEB; }
.dft-ratio-card.bad  { border-left-color: #EF4444; background: #FEF2F2; }

.dft-ratio-label { font-size: 11px; color: var(--text-muted); font-weight: 600; margin-bottom: 4px; }
.dft-ratio-value { font-size: 1.05rem; font-weight: 700; color: #1a2e5a; margin-bottom: 2px; }
.dft-ratio-sub   { font-size: 9px; color: var(--text-muted); }

/* ── DFT Finance Chart Tabs ──────────────────────────────── */
.fin-chart-tabs { display: flex; gap: 4px; margin-bottom: 10px; flex-wrap: wrap; }

.fin-tab-btn {
    padding: 5px 12px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-muted);
    border-radius: 6px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}
.fin-tab-btn:hover  { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.fin-tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── DFT Finance Table ───────────────────────────────────── */
.dft-table-hint {
    font-size: 11px;
    color: var(--text-muted);
    text-align: right;
    margin-bottom: 4px;
}

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

.dft-fin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    min-width: 480px;
}

.dft-fin-table th {
    background: var(--bg);
    padding: 6px 10px;
    text-align: right;
    white-space: nowrap;
    font-weight: 600;
    font-size: 11px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.dft-fin-table th:first-child { text-align: left; }

.dft-fin-table td {
    padding: 6px 10px;
    text-align: right;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.dft-fin-table td:first-child { text-align: left; }
.dft-fin-table .positive { color: #059669; font-weight: 500; }
.dft-fin-table .negative { color: var(--error); font-weight: 500; }

/* ── Job Log Panel ───────────────────────────────────────── */
.joblog-panel {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 100;
    display: flex;
    flex-direction: column;
    max-width: 600px;
    margin: 0 auto;
    animation: slideUp .2s ease;
}

.joblog-header {
    background: var(--primary);
    color: white;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.joblog-title { font-size: 16px; font-weight: 600; }

.joblog-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.joblog-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 0;
    font-size: 14px;
}

/* ── Job Log Entry ───────────────────────────────────────── */
.job-entry {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.job-entry-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    user-select: none;
}

.job-entry-head:hover { background: #F9FAFB; }

.job-badge {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

.job-badge-image  { background: #EFF6FF; color: var(--primary); }
.job-badge-video  { background: #F0FDF4; color: #065F46; }
.job-badge-error  { background: #FEF2F2; color: var(--error); }
.job-badge-found  { background: #F0FDF4; color: #065F46; }
.job-badge-nofind { background: #F9FAFB; color: var(--text-muted); }

.job-entry-name {
    flex: 1;
    font-size: 13px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.job-entry-meta {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.job-entry-detail {
    padding: 0 12px 10px;
    border-top: 1px solid var(--border);
    font-size: 12px;
}

.job-detail-row {
    display: flex;
    gap: 8px;
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}

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

.job-detail-label {
    color: var(--text-muted);
    min-width: 90px;
    flex-shrink: 0;
    font-size: 11px;
    padding-top: 1px;
}

.job-detail-val {
    flex: 1;
    word-break: break-all;
    color: var(--text);
    font-family: monospace;
    font-size: 11px;
    white-space: pre-wrap;
    max-height: 120px;
    overflow-y: auto;
}

.job-thumb {
    width: 64px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

/* ── FPS selector panel ──────────────────────────────────── */
.fps-panel {
    background: #f0f9ff;
    border-top: 1px solid #bae6fd;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.fps-meta {
    font-size: 12px;
    color: #64748b;
    background: #e0f2fe;
    border-radius: 6px;
    padding: 4px 10px;
    width: fit-content;
}
.fps-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.fps-label { font-size: 13px; color: var(--text-secondary); white-space: nowrap; }
.fps-unit  { font-size: 13px; color: var(--text-secondary); }
.fps-input {
    width: 72px;
    padding: 5px 8px;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    color: var(--text-primary);
    background: white;
    outline: none;
    transition: border-color .15s;
}
.fps-input:focus { border-color: var(--primary); }
.fps-quick {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}
.fps-quick button {
    padding: 4px 10px;
    border-radius: 16px;
    border: 1.5px solid #cbd5e1;
    background: white;
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all .15s;
    line-height: 1;
}
.fps-quick button:hover  { border-color: var(--primary); color: var(--primary); }
.fps-quick button.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}
.fps-result {
    font-size: 13px;
    color: #0369a1;
    background: #e0f2fe;
    border-radius: 6px;
    padding: 5px 10px;
    min-height: 28px;
}
.fps-panel-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}
.fps-panel-actions .btn-primary {
    flex: 1;
    justify-content: center;
}

/* ── Frame strip (video debug) ───────────────────────────── */
.job-frames-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 12px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}
.job-frame-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.job-frame-img {
    width: 100px;
    height: 72px;
    object-fit: cover;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: #e5e7eb;
    cursor: pointer;
}
.job-frame-img:active { opacity: .8; }
.job-frame-label {
    font-size: 10px;
    color: var(--text-muted);
}
.job-ffmpeg-pre {
    white-space: pre-wrap;
    word-break: break-all;
    font-size: 11px;
    font-family: monospace;
    max-height: 200px;
    overflow-y: auto;
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 8px;
    border-radius: 5px;
    margin: 0;
}

/* ── Sortable Table Headers ──────────────────────────────── */
.sort-icon {
    font-size: 10px;
    color: var(--text-muted);
    opacity: .6;
    margin-left: 2px;
}
.sort-icon.active { color: var(--primary); opacity: 1; }
th[data-sort]:hover { background: var(--primary-light); color: var(--primary); }

/* ── Search Mode ─────────────────────────────────────────── */
#panel-search { padding: 0; }

.search-bar-wrap {
    display: flex;
    gap: 8px;
    padding: 12px 14px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    align-items: center;
}

.search-input-row {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 10px;
    transition: border-color .2s;
}
.search-input-row:focus-within { border-color: var(--primary); }

.search-bar-icon { color: var(--text-muted); flex-shrink: 0; }

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    padding: 10px 0;
    outline: none;
}
.search-input::placeholder { color: #9CA3AF; }

.btn-search-clear {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 2px;
    flex-shrink: 0;
}
.btn-search-clear:hover { color: var(--text); }

.btn-search-go {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    padding: 10px 16px;
    cursor: pointer;
    white-space: nowrap;
    transition: background .2s;
    flex-shrink: 0;
}
.btn-search-go:hover { background: var(--primary-hover); }

.search-results-wrap {
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-y: auto;
    flex: 1;
}

.search-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 16px;
    color: var(--text-muted);
    font-size: 14px;
}
.search-status strong { color: var(--text); }
.search-error { color: var(--error); }

.search-count {
    padding: 8px 14px;
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.search-result-card {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 12px 14px;
    transition: background .15s;
}
.search-result-card:hover { background: #FAFBFF; }

.search-result-head {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 4px;
    justify-content: space-between;
}

.search-result-name {
    font-size: 14px;
    font-weight: 600;
    color: #1a2e5a;
    flex: 1;
    line-height: 1.35;
    word-break: break-word;
}

.search-result-badges {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    flex-wrap: wrap;
    margin-top: 1px;
}

.search-result-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 3px;
}

.search-result-biz {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-result-actions { margin-bottom: 0; }

.btn-search-lookup {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #F0FDF4;
    color: #065F46;
    border: 1px solid #A7F3D0;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    padding: 5px 12px;
    cursor: pointer;
    transition: background .2s;
}
.btn-search-lookup:hover { background: #D1FAE5; }
.btn-search-lookup--open { background: #D1FAE5; border-color: #6EE7B7; }
.search-lookup-chevron { transition: transform .2s; flex-shrink: 0; }
.btn-search-lookup--open .search-lookup-chevron { transform: rotate(180deg); }

.search-result-detail {
    display: none;
    margin-top: 12px;
    border-top: 1px dashed var(--border);
    padding-top: 12px;
}

/* ── Lifecycle Banner ────────────────────────────────────── */
.dft-lifecycle-banner {
    margin: 8px 0;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    border-left: 4px solid;
}
.dft-lifecycle-warn  { background: #FFFBEB; border-color: #F59E0B; color: #78350F; }
.dft-lifecycle-error { background: #FEF2F2; border-color: #EF4444; color: #7F1D1D; }
.dft-lifecycle-title { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.dft-lifecycle-line  { font-size: 12px; margin-top: 2px; }

/* ── Director Enhancements ───────────────────────────────── */
.dft-auth-block {
    background: #F0FDF4;
    border: 1px solid #BBF7D0;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 8px;
}
.dft-auth-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    color: #065F46;
    margin-bottom: 8px;
}
.dft-auth-count {
    background: #059669;
    color: white;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}
.dir-item-auth {
    border-color: #A7F3D0;
    background: #F0FDF4;
}
.dir-name-row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    justify-content: space-between;
}
.dir-name-row .dir-name { flex: 1; }
.dir-badges { display: flex; gap: 4px; flex-wrap: wrap; flex-shrink: 0; margin-top: 1px; }
.dir-badge-auth {
    display: inline-flex; align-items: center;
    background: #059669; color: white;
    font-size: 10px; font-weight: 700;
    padding: 1px 6px; border-radius: 4px;
    white-space: nowrap;
}
.dir-badge-sh {
    display: inline-flex; align-items: center;
    background: #EFF6FF; color: var(--primary);
    font-size: 10px; font-weight: 600;
    padding: 1px 6px; border-radius: 4px;
    white-space: nowrap;
}
.dir-authority {
    font-size: 11px;
    color: #065F46;
    background: rgba(5,150,105,.08);
    padding: 3px 7px;
    border-radius: 4px;
    margin-top: 4px;
}
.dft-dir-divider {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin: 10px 0 6px;
}

/* ── Shareholder View Tabs ───────────────────────────────── */
.sh-view-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
}
.sh-view-tab {
    padding: 4px 14px;
    border: 1.5px solid var(--border);
    background: var(--bg);
    color: var(--text-muted);
    border-radius: 20px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
}
.sh-view-tab:hover  { border-color: var(--primary); color: var(--primary); }
.sh-view-tab.active { background: var(--primary); border-color: var(--primary); color: white; }

/* ── Shareholder Director Badge ──────────────────────────── */
.sh-badge-dir {
    display: inline-flex; align-items: center;
    background: #FEF3C7; color: #92400E;
    font-size: 10px; font-weight: 600;
    padding: 1px 5px; border-radius: 4px;
    vertical-align: middle; margin-left: 4px;
}
.sh-family-head td { font-size: 12px; padding: 7px 8px; background: #F8FAFC; border-bottom: 1px solid var(--border); }
.sh-family-member td { font-size: 11px; padding: 4px 8px; border-bottom: 1px solid #F3F4F6; }

/* ── History Section ─────────────────────────────────────── */
.dft-hist-group { margin-bottom: 10px; }
.dft-hist-group-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 6px;
}
.dft-hist-list { display: flex; flex-direction: column; gap: 6px; }
.dft-hist-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    font-size: 12px;
}
.dft-hist-date {
    min-width: 95px;
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: 11px;
    padding-top: 2px;
}
.dft-hist-body { flex: 1; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.dft-hist-badge {
    background: var(--primary-light);
    color: var(--primary);
    font-size: 10px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 4px;
}
.dft-hist-old { color: var(--error); text-decoration: line-through; }
.dft-hist-new { color: var(--success); font-weight: 600; }
.dft-hist-reg-name { color: var(--text-muted); font-size: 12px; }
.dft-hist-badge-up   { background: #D1FAE5; color: #065F46; }
.dft-hist-badge-down { background: #FEE2E2; color: #991B1B; }

/* ── Responsive ──────────────────────────────────────────── */
@media (min-width: 600px) {
    #app { box-shadow: 0 0 40px rgba(0,0,0,.1); }
}

@media (max-width: 380px) {
    .mode-tab { font-size: 12px; gap: 3px; }
    .mode-tab svg { display: none; }
}
