:root {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-card-hover: #222632;
    --bg-input: #12141c;
    --border: #2a2e3a;
    --border-focus: #4f7df9;
    --text: #e4e6ed;
    --text-dim: #8b8fa3;
    --text-muted: #5c6070;
    --primary: #4f7df9;
    --primary-hover: #3d6ae6;
    --primary-bg: rgba(79, 125, 249, 0.1);
    --danger: #f95f5f;
    --danger-bg: rgba(249, 95, 95, 0.1);
    --warning: #f9b84f;
    --warning-bg: rgba(249, 184, 79, 0.1);
    --success: #4fc98f;
    --success-bg: rgba(79, 201, 143, 0.1);
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

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

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

/* Header */
header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 28px;
    height: 28px;
    color: var(--primary);
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

nav {
    display: flex;
    gap: 4px;
}

.nav-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s;
}

.nav-btn:hover {
    color: var(--text);
    background: var(--bg);
}

.nav-btn.active {
    color: var(--primary);
    background: var(--primary-bg);
}

/* Main */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

/* Section Header */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 8px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

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

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

.btn-outline {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    border-color: var(--text-dim);
    background: var(--bg-card);
}

.btn-ghost {
    background: transparent;
    color: var(--text-dim);
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

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

.btn-danger:hover {
    background: #e04e4e;
}

.btn-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.15s;
    line-height: 1;
}

.btn-remove:hover {
    color: var(--danger);
    background: var(--danger-bg);
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.card-subtitle {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 16px;
}

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

.card-header-row h3 {
    margin-bottom: 0;
}

/* Inputs */
.input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.875rem;
    font-family: inherit;
    transition: border-color 0.15s;
}

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

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

.input-sm {
    min-width: 120px;
    width: auto;
}

select.input {
    cursor: pointer;
}

.textarea {
    resize: vertical;
    min-height: 80px;
}

/* Multi-entry rows */
.multi-entries {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.entry-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.entry-row .input {
    flex: 1;
}

/* Form Layout */
.form-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

/* Dropzone */
.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-dim);
}

.dropzone:hover,
.dropzone.drag-over {
    border-color: var(--primary);
    background: var(--primary-bg);
    color: var(--primary);
}

.dropzone p {
    font-weight: 500;
    font-size: 0.95rem;
}

.dropzone span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Photo Grid */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    margin-top: 16px;
}

.photo-grid:empty {
    display: none;
}

.photo-thumb {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}

.photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-thumb .photo-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
}

.photo-thumb:hover .photo-remove {
    opacity: 1;
}

/* Subject Cards (List View) */
.subjects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.subject-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    gap: 16px;
}

.subject-card:hover {
    border-color: var(--primary);
    background: var(--bg-card-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.subject-card-photo {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.subject-card-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.subject-card-info {
    flex: 1;
    min-width: 0;
}

.subject-card-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.subject-card-meta {
    font-size: 0.8rem;
    color: var(--text-dim);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.subject-card-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

.subject-card-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-pending {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-clear {
    background: var(--success-bg);
    color: var(--success);
}

.badge-flagged {
    background: var(--danger-bg);
    color: var(--danger);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-dim);
}

.empty-state svg {
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 1.25rem;
    color: var(--text);
    margin-bottom: 8px;
}

.empty-state p {
    margin-bottom: 24px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

/* Report */
.report-header {
    display: flex;
    gap: 24px;
    margin-bottom: 32px;
}

.report-subject-photos {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.report-subject-photos img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.report-subject-info {
    flex: 1;
}

.report-subject-info h2 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.report-contact-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-dim);
}

.chip-label {
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Score Ring */
.score-ring-container {
    text-align: center;
    flex-shrink: 0;
}

.score-ring {
    width: 120px;
    height: 120px;
    position: relative;
}

.score-ring svg {
    transform: rotate(-90deg);
}

.score-ring-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 8;
}

.score-ring-fill {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s ease-out;
}

.score-ring-text {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.score-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1;
}

.score-label {
    font-size: 0.7rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

/* Report Modules */
.report-modules {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.report-module {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.report-module.full-width {
    grid-column: 1 / -1;
}

.module-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.module-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.module-icon svg {
    width: 20px;
    height: 20px;
}

.module-icon.icon-images { background: var(--primary-bg); color: var(--primary); }
.module-icon.icon-phone { background: var(--warning-bg); color: var(--warning); }
.module-icon.icon-social { background: var(--success-bg); color: var(--success); }
.module-icon.icon-email { background: rgba(168,85,247,0.1); color: #a855f7; }
.module-icon.icon-geo { background: var(--danger-bg); color: var(--danger); }
.module-icon.icon-summary { background: var(--primary-bg); color: var(--primary); }

.module-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.module-status {
    margin-left: auto;
    font-size: 0.8rem;
    font-weight: 500;
}

.finding {
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    font-size: 0.875rem;
}

.finding:last-child {
    margin-bottom: 0;
}

.finding-icon {
    flex-shrink: 0;
    font-size: 1rem;
    line-height: 1.4;
}

.finding-clear {
    background: var(--success-bg);
    color: var(--success);
}

.finding-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.finding-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.finding-info {
    background: var(--primary-bg);
    color: var(--primary);
}

.finding-pending {
    background: var(--bg-input);
    color: var(--text-dim);
}

/* Not yet run state */
.report-not-run {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-dim);
}

.report-not-run svg {
    margin-bottom: 16px;
    opacity: 0.3;
}

.report-not-run h3 {
    color: var(--text);
    margin-bottom: 8px;
}

.report-not-run p {
    max-width: 400px;
    margin: 0 auto 24px;
}

/* Delete confirmation */
.subject-card-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.15s;
}

.subject-card-delete:hover {
    color: var(--danger);
    background: var(--danger-bg);
}

/* Loading spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
}

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

/* Responsive */
@media (max-width: 768px) {
    .form-layout {
        grid-template-columns: 1fr;
    }

    .report-modules {
        grid-template-columns: 1fr;
    }

    .report-header {
        flex-direction: column;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .subjects-grid {
        grid-template-columns: 1fr;
    }

    .header-inner {
        flex-direction: column;
        height: auto;
        padding: 12px 16px;
        gap: 8px;
    }
}
