:root {
    /* GWU Brand Colors */
    --gw-blue: #033C5A;
    --gw-blue-dark: #00223E;
    --gw-buff: #D6BF91;
    --gw-buff-light: #E8D9B8;
    --gw-potomac: #0075C8;

    /* Functional palette */
    --bg-page: #F4F6F9;
    --bg-panel: #FFFFFF;
    --bg-input: #F8FAFC;
    --border: #D9DFE8;
    --border-focus: var(--gw-potomac);

    --text-primary: #1A2B3D;
    --text-secondary: #5A6B7E;
    --text-muted: #8896A6;

    --accent: var(--gw-potomac);
    --accent-hover: #005FA3;
    --success: #2E8B57;
    --danger: #C0392B;

    /* Entity highlight colors */
    --ent-person: #C0392B;
    --ent-location: #D4881C;
    --ent-org: #6C3483;
    --ent-respondent: var(--gw-potomac);
    --ent-timestamp: #2E8B57;
    --ent-date: #2874A6;
    --ent-meta: #5A6B7E;
}

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

body {
    background: var(--bg-page);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    line-height: 1.6;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ---- Header ---- */
.site-header {
    background: var(--gw-blue);
    color: #fff;
    padding: 0;
    border-bottom: 4px solid var(--gw-buff);
    flex-shrink: 0;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.brand-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--gw-buff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--gw-blue);
    font-weight: 700;
}

.brand h1 {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.brand-sub {
    font-size: 0.72rem;
    color: var(--gw-buff-light);
    font-weight: 400;
    letter-spacing: 0.03em;
    margin-top: 1px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.78rem;
    color: rgba(255,255,255,0.7);
    background: rgba(255,255,255,0.08);
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.12);
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--danger);
    flex-shrink: 0;
}

.status-dot.healthy {
    background: var(--success);
}

/* ---- Main content ---- */
.main-content {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    gap: 2rem;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* ---- Panels ---- */
.panel {
    flex: 1;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.panel-head {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-head h2 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.panel-head .hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.panel-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1.5rem;
    gap: 1rem;
    overflow: hidden;
    min-height: 0;
}

/* ---- Upload zone ---- */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    text-align: center;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.upload-zone p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.upload-zone.drag-over {
    border-color: var(--accent);
    background: rgba(0, 117, 200, 0.04);
}

/* ---- Textarea ---- */
textarea {
    flex: 1;
    min-height: 200px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.88rem;
    line-height: 1.65;
    resize: none;
    outline: none;
    transition: border-color 0.2s ease;
}

textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(0, 117, 200, 0.08);
}

textarea::placeholder {
    color: var(--text-muted);
}

/* ---- Buttons ---- */
.action-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-primary {
    background: var(--gw-blue);
    color: #fff;
    border: none;
    padding: 0.65rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s ease;
}

.btn-primary:hover {
    background: var(--gw-blue-dark);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.82rem;
    transition: background 0.15s ease;
}

.btn-secondary:hover {
    background: #eef1f5;
}

.btn-ghost {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.82rem;
    padding: 0.4rem 0.6rem;
}

.btn-ghost:hover {
    color: var(--text-primary);
}

.btn-icon {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.45rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.btn-icon:hover {
    background: var(--bg-input);
}

.btn-download {
    background: var(--gw-buff);
    color: var(--gw-blue-dark);
    border: none;
    padding: 0.45rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-download:hover {
    background: var(--gw-buff-light);
}

.btn-download:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ---- Output ---- */
.output-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.result-box {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    font-family: 'JetBrains Mono', 'Menlo', monospace;
    font-size: 0.82rem;
    line-height: 1.7;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-primary);
    min-height: 0;
}

.entity-highlight {
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 600;
    font-size: 0.78rem;
}

/* ---- Entity Legend ---- */
.entity-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0.75rem 0 0;
    border-top: 1px solid var(--border);
}

.legend-item {
    font-size: 0.7rem;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text-secondary);
}

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

/* ---- Footer ---- */
.site-footer {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 0.6rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.site-footer a {
    color: var(--text-secondary);
    text-decoration: none;
}

.site-footer a:hover {
    color: var(--accent);
}

.footer-links {
    display: flex;
    gap: 1.25rem;
}

/* ---- Action bar spacer ---- */
.action-bar-spacer {
    flex: 1;
}

/* ---- Toggle ---- */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.78rem;
    color: var(--text-muted);
    user-select: none;
}

.toggle-label input[type="checkbox"] {
    accent-color: var(--gw-blue);
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.toggle-text {
    white-space: nowrap;
}

/* ---- Custom Rules Section ---- */
.custom-rules-section {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    flex-shrink: 0;
}

.custom-rules-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.custom-rules-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.custom-rules-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rule-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.rule-row select,
.rule-row input {
    font-family: inherit;
    font-size: 0.78rem;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-panel);
    color: var(--text-primary);
    outline: none;
}

.rule-row select {
    width: 90px;
    flex-shrink: 0;
}

.rule-row input.rule-label {
    width: 110px;
    flex-shrink: 0;
}

.rule-row input.rule-value {
    flex: 1;
    min-width: 0;
}

.rule-row input:focus,
.rule-row select:focus {
    border-color: var(--border-focus);
}

.rule-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 0 4px;
    line-height: 1;
}

.rule-remove:hover {
    color: var(--danger);
}

/* ---- Loader ---- */
.loader {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

[hidden] {
    display: none !important;
}

/* ---- Responsive ---- */
@media (max-width: 860px) {
    .main-content {
        flex-direction: column;
        padding: 1rem;
    }
    .header-inner {
        padding: 0.8rem 1rem;
    }
}
