:root {
    --bg: #0f1117;
    --bg2: #161822;
    --bg3: #1c1f2e;
    --bg-hover: #232738;
    --border: #2a2e3f;
    --border-light: #363b50;
    --text: #e8eaed;
    --text-muted: #8b8fa3;
    --primary: #6366f1;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --transition: 0.2s ease;
}

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

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

.app { max-width: 1100px; margin: 0 auto; padding: 20px; }

/* Header */
.header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; padding: 16px 20px;
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 20px;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 1.6rem; }
.logo h1 { font-size: 1.35rem; font-weight: 800; }
.header-status { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: .9rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--success); box-shadow: 0 0 6px var(--success); }
.btn-icon {
    color: var(--text-muted); background: none; border: none; cursor: pointer;
    padding: 6px; border-radius: var(--radius-sm); display: flex;
    transition: var(--transition);
}
.btn-icon:hover { color: var(--text); background: var(--bg-hover); }

/* Badges */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 999px;
    font-size: .75rem; font-weight: 600; letter-spacing: .02em;
}
.badge-primary { background: rgba(99,102,241,.15); color: #a5b4fc; }
.badge-success { background: rgba(34,197,94,.15); color: #86efac; }
.badge-warning { background: rgba(245,158,11,.15); color: #fcd34d; }
.badge-danger { background: rgba(239,68,68,.15); color: #fca5a5; }

/* Search */
.search-panel {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}
.search-row { display: flex; gap: 10px; }
.search-input {
    flex: 1; padding: 12px 14px; font-size: 1rem; color: var(--text);
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: var(--radius-sm); outline: none; transition: var(--transition);
    font-family: inherit;
}
.search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.2); }
.search-options { margin-top: 12px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--text-muted); cursor: pointer; }
.ticket-text {
    width: 100%; margin-top: 12px; padding: 12px 14px; font-size: .9rem;
    color: var(--text); background: var(--bg3); border: 1px solid var(--border);
    border-radius: var(--radius-sm); resize: vertical; outline: none; font-family: inherit;
}
.ticket-text:focus { border-color: var(--primary); }

/* Buttons */
.btn {
    padding: 12px 20px; font-size: .95rem; font-weight: 600; cursor: pointer;
    border: none; border-radius: var(--radius-sm); transition: var(--transition);
    font-family: inherit; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #4f52d9; }
.btn-sm { padding: 8px 14px; font-size: .85rem; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); }
.btn-block { width: 100%; margin-top: 16px; }

/* Empty / loading */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state h2 { color: var(--text); font-size: 1.3rem; margin-bottom: 6px; }
.hidden { display: none; }
.loading-state { text-align: center; padding: 40px; color: var(--text-muted); }
.spinner {
    width: 36px; height: 36px; border: 3px solid var(--border);
    border-top-color: var(--primary); border-radius: 50%;
    margin: 0 auto 12px; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.step-indicator { font-size: .95rem; }

/* Summary bar */
.summary-bar {
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px;
}
.summary-item { font-size: .9rem; color: var(--text-muted); }
.summary-item b { color: var(--text); font-size: 1.1rem; }
.summary-actions { margin-left: auto; display: flex; gap: 8px; }

/* Panels */
.panel {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 16px; overflow: hidden;
}
.panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; cursor: pointer; user-select: none;
    background: var(--bg3); border-bottom: 1px solid var(--border);
}
.panel-header:hover { background: var(--bg-hover); }
.panel-header h3 { font-size: .95rem; font-weight: 700; }
.panel-header .badge { margin-left: 8px; }
.panel-body { padding: 16px; }
.panel-body.collapsed { display: none; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: var(--bg-hover); }
.ok-text { color: var(--success); }
.warn-text { color: var(--warning); }

/* Alerts */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 12px; font-size: .9rem; }
.alert-error { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.3); color: #fca5a5; }
.alert-info { background: rgba(99,102,241,.12); border: 1px solid rgba(99,102,241,.3); color: #a5b4fc; }

/* Analysis text */
.analysis-text { white-space: pre-wrap; line-height: 1.65; font-size: .92rem; }

/* OFAC subtitle */
.ofac-subtitle { font-size: .8rem; font-weight: 700; color: var(--primary2); margin-bottom: 8px; letter-spacing: .02em; }

/* Ticket analysis fields */
.tc-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tc-field { background: var(--bg3); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; }
.tc-field .tc-label { display: block; font-size: .7rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.tc-field .tc-value { font-size: .9rem; color: var(--text); word-break: break-word; }
.tc-copy-row { display: flex; gap: 10px; flex-wrap: wrap; }
.tc-copy-row .btn { background: var(--bg3); border: 1px solid var(--border); color: var(--text); }
.tc-copy-row .btn:hover { border-color: var(--primary); background: rgba(99,102,241,.15); }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
    width: 100%; max-width: 400px; background: var(--bg2);
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 32px; text-align: center;
}
.login-logo { margin-bottom: 8px; }
.login-logo .logo-icon { font-size: 2.2rem; }
.login-logo h1 { font-size: 1.5rem; margin-top: 4px; }
.login-card form { text-align: left; margin-top: 20px; }
.field-label { display: block; font-size: .85rem; color: var(--text-muted); margin: 12px 0 6px; font-weight: 600; }

@media (max-width: 640px) {
    .search-row { flex-direction: column; }
    .summary-actions { margin-left: 0; width: 100%; }
    .stat-grid { grid-template-columns: 1fr; }
}
