* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f5f5;
    color: #1a1a1a;
}

.container {
    display: grid;
    grid-template-columns: 1fr 260px;
    grid-template-rows: auto 1fr;
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem;
    gap: 2rem;
    min-height: 100vh;
}

header {
    grid-column: 1 / -1;
}

h1 { font-size: 1.6rem; }
.subtitle { color: #666; margin-top: 0.25rem; }

.input-section { display: flex; flex-direction: column; gap: 0.5rem; }

label { font-weight: 600; font-size: 0.9rem; }

textarea {
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 0.75rem;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
}

textarea:focus { outline: 2px solid #2563eb; border-color: transparent; }

button {
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0.6rem 1.5rem;
    font-size: 0.95rem;
    cursor: pointer;
    align-self: flex-start;
}

button:hover { background: #1d4ed8; }
button:disabled { background: #93c5fd; cursor: not-allowed; }

.hidden { display: none; }

.result-section {
    margin-top: 1.5rem;
    background: #fff;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.score-display {
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    padding: 1rem 0;
}

.action-display {
    text-align: center;
    padding: 0.4rem 1rem;
    border-radius: 20px;
    display: inline-block;
    font-weight: 600;
    font-size: 0.85rem;
    margin: 0 auto 1rem;
}

.action-auto_approve { background: #dcfce7; color: #166534; }
.action-human_review { background: #fef9c3; color: #854d0e; }
.action-auto_flag    { background: #fecaca; color: #991b1b; }

.components-display, .factors-display {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.component-row, .factor-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0.6rem;
    background: #f9fafb;
    border-radius: 4px;
    font-size: 0.85rem;
}

.concern-normal       { color: #166534; }
.concern-low_concern  { color: #854d0e; }
.concern-moderate_concern { color: #c2410c; }
.concern-high_concern { color: #991b1b; font-weight: 600; }

h3 { margin-top: 1rem; font-size: 0.95rem; }

.history-sidebar {
    background: #fff;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    align-self: start;
    position: sticky;
    top: 2rem;
}

.history-sidebar h3 { margin-top: 0; margin-bottom: 0.5rem; }

#history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-height: 60vh;
    overflow-y: auto;
}

#history-list li {
    padding: 0.5rem;
    background: #f9fafb;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    border-left: 3px solid transparent;
}

#history-list li:hover { background: #f0f0f0; }
#history-list li.score-high   { border-left-color: #22c55e; }
#history-list li.score-medium { border-left-color: #eab308; }
#history-list li.score-low    { border-left-color: #ef4444; }

/* Similar claims */
.similar-display {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.similar-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    font-size: 0.83rem;
}

.similar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.3rem;
}

.similar-id {
    font-family: "SF Mono", "Consolas", monospace;
    font-weight: 600;
    font-size: 0.8rem;
    color: #374151;
}

.similar-sim {
    font-weight: 600;
    color: #2563eb;
    font-size: 0.8rem;
}

.similar-tags {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-bottom: 0.25rem;
}

.label-legit {
    background: #dcfce7;
    color: #166534;
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.label-fraud {
    background: #fecaca;
    color: #991b1b;
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.fraud-type {
    background: #fef3c7;
    color: #854d0e;
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
}

.matched-comp {
    background: #e0e7ff;
    color: #3730a3;
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
}

.similar-preview {
    color: #6b7280;
    font-size: 0.78rem;
    line-height: 1.3;
    margin-top: 0.2rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.empty-state {
    color: #9ca3af;
    font-size: 0.83rem;
    font-style: italic;
    padding: 0.5rem 0;
}

/* Structured claim breakdown */
.structured-display {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.5rem;
}

.struct-section {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
}

.struct-title {
    background: #e5e7eb;
    font-weight: 600;
    font-size: 0.82rem;
    padding: 0.35rem 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #374151;
}

.struct-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.3rem 0.7rem;
    font-size: 0.83rem;
    border-bottom: 1px solid #f3f4f6;
}

.struct-row:last-child { border-bottom: none; }

.struct-total {
    font-weight: 600;
    background: #f3f4f6;
}

.struct-key {
    color: #6b7280;
    text-transform: capitalize;
    min-width: 100px;
    flex-shrink: 0;
}

.struct-val {
    color: #111827;
    text-align: right;
    word-break: break-word;
    max-width: 65%;
}

.kw-list { display: flex; gap: 0.3rem; flex-wrap: wrap; justify-content: flex-end; }

.kw-tag {
    background: #e0e7ff;
    color: #3730a3;
    padding: 0.05rem 0.45rem;
    border-radius: 8px;
    font-size: 0.75rem;
}

.dtc-tag {
    background: #fef3c7;
    color: #854d0e;
    padding: 0.05rem 0.45rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-family: "SF Mono", "Consolas", monospace;
    font-weight: 600;
}

.ratio-ok  { color: #166534; }
.ratio-mod { color: #c2410c; }
.ratio-high { color: #991b1b; font-weight: 600; }
