:root {
    --primary: #305697;
    --primary-light: #3763ae;
    --primary-dark: #1f3c6e;
    --bg: #F8F8F8;
    --bg-alt: #EBEFF5;
    --white: #FFFFFF;
    --border: #E8E9EC;
    --text: #333;
    --text-light: #4D4F5C;
    --green: #4caf50;
    --green-hover: #3e9241;
    --red: #FF6384;
    --yellow: #FEC920;
    --blue-accent: #37A1EA;
    --shadow: rgba(0, 0, 0, 0.1) 0px 4px 12px;
    --shadow-lg: rgba(149, 157, 165, 0.2) 0px 8px 24px;
    --radius: 0.5rem;
}

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

body {
    font-family: 'Inter', 'Helvetica Neue', Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 1.1rem;
    line-height: 1.5;
}

/* Navbar */
.navbar {
    background: var(--primary);
    color: var(--white);
    padding: 0 2rem;
    height: 4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.navbar nav { display: flex; gap: 1.5rem; }

.navbar a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 0.94rem;
    font-weight: 500;
    padding: 0.4rem 0;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.navbar a:hover,
.navbar a.active {
    color: var(--white);
    border-bottom-color: var(--white);
}

.nav-sep {
    opacity: 0.3;
    margin: 0 -0.25rem;
}

.nav-user {
    font-size: 0.94rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
}

/* Layout */
.container {
    width: 90%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h2 {
    font-size: 1.4rem;
    font-weight: 300;
    color: var(--text);
}

.page-header p {
    color: var(--text-light);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Upload area */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg);
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: var(--bg-alt);
}

.upload-zone .icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    color: var(--primary);
}

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

.upload-zone .filename {
    margin-top: 0.75rem;
    color: var(--primary);
    font-weight: 500;
}

/* File list (multi-upload) */
.file-list {
    margin-top: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    background: var(--white);
}

.file-item:last-child { border-bottom: none; }

.file-item-name {
    flex: 1;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-item-size {
    color: var(--text-light);
    font-size: 0.75rem;
    white-space: nowrap;
}

.file-item-remove {
    background: none;
    border: none;
    color: var(--red);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
    font-weight: 600;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.file-item-remove:hover { opacity: 1; }

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-light);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(48, 86, 151, 0.1);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: 5px;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

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

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

.btn-secondary {
    background: var(--white);
    color: var(--primary);
    border: 1px solid var(--border);
}

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

/* Table */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-light);
    border-bottom: 2px solid var(--border);
}

tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

tbody tr:hover { background: var(--bg); }

tbody tr:last-child td { border-bottom: none; }

/* Status badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 10rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-received { background: #e3f2fd; color: #1565c0; }
.badge-pending { background: #f3e5f5; color: #7b1fa2; }
.badge-processing { background: #fff3e0; color: #e65100; }
.badge-completed { background: #e8f5e9; color: #2e7d32; }
.badge-failed { background: #fce4ec; color: #c62828; }
.badge-approved { background: #e8f5e9; color: #2e7d32; }
.badge-denied { background: #fce4ec; color: #c62828; }
.badge-partially_approved { background: #fff3e0; color: #e65100; }
.badge-needs_review { background: #e3f2fd; color: #1565c0; }
.badge-active { background: #e8f5e9; color: #2e7d32; }
.badge-expired { background: #ffebee; color: #c62828; }
.badge-cancelled, .badge-lapsed { background: #f5f5f5; color: #616161; }

/* Detail page */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.detail-item label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-light);
    margin-bottom: 0.15rem;
}

.detail-item span {
    font-size: 0.9rem;
}

.json-block {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 1rem;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.8rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 24rem;
    overflow-y: auto;
    line-height: 1.6;
}

.section-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-light);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light);
}

.empty-state .icon { font-size: 2rem; margin-bottom: 0.5rem; }

/* Toast / alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 5px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.alert-success { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.alert-error { background: #fce4ec; color: #c62828; border: 1px solid #f8bbd0; }

/* Decision banner */
.decision-banner {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.decision-banner .decision-status {
    font-size: 1.1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.decision-banner .decision-amount {
    font-size: 1.5rem;
    font-weight: 600;
}

.decision-banner .decision-amount small {
    font-size: 0.8rem;
    font-weight: 400;
    opacity: 0.8;
}

.decision-approved { background: #e8f5e9; border: 1px solid #a5d6a7; color: #1b5e20; }
.decision-partially_approved { background: #fff3e0; border: 1px solid #ffcc80; color: #e65100; }
.decision-denied { background: #fce4ec; border: 1px solid #f8bbd0; color: #b71c1c; }
.decision-needs_review { background: #e3f2fd; border: 1px solid #90caf9; color: #0d47a1; }

/* Patient info visual grid */
.info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.info-card {
    padding: 0.75rem;
    background: var(--bg);
    border-radius: 5px;
    border-left: 3px solid var(--primary);
}

.info-card.hospital { border-left-color: var(--green); }
.info-card.dates { border-left-color: var(--blue-accent); }
.info-card.diagnosis { border-left-color: var(--red); }
.info-card.financial { border-left-color: var(--yellow); }

.info-card label {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-light);
    margin-bottom: 0.15rem;
}

.info-card .value {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    word-break: break-word;
}

.info-card .value.large {
    font-size: 1.1rem;
}

/* Lab findings */
.lab-table th { font-size: 0.7rem; }
.lab-table td { font-size: 0.8rem; padding: 0.5rem 0.75rem; }
.lab-abnormal { color: #c62828; font-weight: 500; }
.lab-normal { color: #2e7d32; }

/* Bill items table */
.bill-table th { font-size: 0.7rem; }
.bill-table td { font-size: 0.8rem; padding: 0.6rem 0.75rem; }
.bill-table .amount { text-align: right; font-variant-numeric: tabular-nums; }
.bill-table tfoot td {
    font-weight: 600;
    border-top: 2px solid var(--border);
    padding-top: 0.75rem;
}

.payable-yes {
    background: #e8f5e9;
}

.payable-no {
    background: #fce4ec;
}

.payable-tag {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 10rem;
    font-size: 0.7rem;
    font-weight: 600;
}

.payable-tag.yes { background: #c8e6c9; color: #1b5e20; }
.payable-tag.no { background: #f8bbd0; color: #b71c1c; }

.bill-remark {
    font-size: 0.7rem;
    color: var(--text-light);
    margin-top: 0.15rem;
}

.bill-code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.7rem;
    color: var(--primary);
    background: var(--bg-alt);
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
}

/* Confidence meter */
.confidence-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.confidence-track {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

.confidence-low { background: #ef5350; }
.confidence-mid { background: #ffa726; }
.confidence-high { background: #66bb6a; }

/* Flags list */
.flag-list { list-style: none; padding: 0; }

.flag-list li {
    padding: 0.4rem 0.6rem;
    margin-bottom: 0.35rem;
    background: #fff8e1;
    border-left: 3px solid var(--yellow);
    border-radius: 0 4px 4px 0;
    font-size: 0.8rem;
}

.denial-list li {
    background: #fce4ec;
    border-left-color: var(--red);
}

.payable-partial td { background: #fff8e1; }

/* Tabs */
.claim-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 0;
    background: var(--white);
    padding: 0 1rem 0 0;
    overflow-x: auto;
}
.claim-tabs button {
    padding: 0.75rem 1.25rem;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-light);
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
}
.claim-tabs button:hover { color: var(--primary); }
.claim-tabs button.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.claim-tab-panel {
    display: none;
    padding: 1.25rem 0;
}
.claim-tab-panel.active { display: block; }

/* Algorithms tab */
.algo-panel {
    padding: 0 0 1rem 0;
    margin-bottom: 0;
}
.algo-glance-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem 1.5rem;
}
.algo-glance-item label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-light);
    margin-bottom: 0.2rem;
}
.algo-glance-item .value { font-size: 0.9rem; }
.algo-show-more {
    margin-top: 0.75rem;
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
}
.algo-show-more:hover { text-decoration: underline; }

.algo-trigger-panel { padding: 0; }
.trigger-flags-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
}
.trigger-flag-item {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    text-align: center;
}
/* Semi-circle dial: circumference only (arc stroke), label + Low/High inside */
.trigger-dial {
    position: relative;
    width: 100%;
    max-width: 140px;
    aspect-ratio: 2 / 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 0.5rem;
    box-sizing: border-box;
}
.trigger-dial::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 4px solid transparent;
    border-bottom: none;
    border-left-color: transparent;
    border-right-color: transparent;
    border-radius: 50% 50% 0 0;
    background: transparent;
    pointer-events: none;
}
.trigger-dial--low::before { border-top-color: #2e7d32; }
.trigger-dial--medium::before { border-top-color: #f9a825; }
.trigger-dial--high::before { border-top-color: #e65100; }
.trigger-dial--n\/a::before { border-top-color: var(--text-light); }
.trigger-dial .trigger-flag-label,
.trigger-dial .trigger-flag-badge {
    position: relative;
    z-index: 1;
}
.trigger-dial .trigger-flag-label {
    margin-bottom: 0.15rem;
}
.trigger-flag-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-light);
}
.trigger-flag-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}
.trigger-flag--low {
    background: #e8f5e9;
    color: #2e7d32;
}
.trigger-flag--medium {
    background: #fff8e1;
    color: #f9a825;
}
.trigger-flag--high {
    background: #fff3e0;
    color: #e65100;
}
.trigger-flag--n/a {
    background: var(--border);
    color: var(--text-light);
}

.insights-list {
    margin: 0;
    padding-left: 1.25rem;
    font-size: 0.9rem;
    line-height: 1.6;
}
.insights-list li { margin-bottom: 0.5rem; }

/* Utility */
.text-mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.8rem; }
.text-muted { color: var(--text-light); }
.text-small { font-size: 0.8rem; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 1.5rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
