/* =============================================================================
   Verity - Hospital Price Transparency Platform
   ============================================================================= */

/* -----------------------------------------------------------------------------
   Variables
   ----------------------------------------------------------------------------- */
:root {
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-accent: #10b981;
    --color-accent-dark: #059669;
    --color-secondary: #64748b;
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-error: #ef4444;

    --color-text: #1e293b;
    --color-text-light: #64748b;
    --color-bg: #ffffff;
    --color-bg-alt: #f8fafc;
    --color-border: #e2e8f0;

    --color-dark: #0f172a;
    --color-dark-mid: #1e293b;

    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;

    --radius: 6px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
    --shadow-xl: 0 8px 24px rgba(0,0,0,0.12);
}

/* -----------------------------------------------------------------------------
   Reset & Base
   ----------------------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.6;
    color: var(--color-text);
    background: var(--color-bg);
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0 0 1rem;
    font-weight: 600;
    line-height: 1.3;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

p { margin: 0 0 1rem; }

a {
    color: var(--color-primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

ul {
    margin: 0 0 1rem;
    padding-left: 1.5rem;
}

/* -----------------------------------------------------------------------------
   Layout
   ----------------------------------------------------------------------------- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.main {
    flex: 1;
}

/* -----------------------------------------------------------------------------
   Header & Navigation
   ----------------------------------------------------------------------------- */
.header {
    background: var(--color-dark);
    padding: 0 2rem;
}

.nav {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.nav-brand {
    display: flex;
    align-items: center;
}

.nav-brand:hover {
    text-decoration: none;
    opacity: 0.9;
}

.nav-logo {
    height: 44px;
    width: auto;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-link {
    color: #cbd5e1;
    font-weight: 500;
    font-size: 0.9375rem;
}

.nav-link:hover {
    color: #ffffff;
    text-decoration: none;
}

/* -----------------------------------------------------------------------------
   Footer
   ----------------------------------------------------------------------------- */
.footer {
    background: #0c1322;
    border-top: 1px solid #1e293b;
    padding: 2rem;
    text-align: center;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.footer p {
    margin: 0.25rem 0;
    color: #475569;
    font-size: 0.875rem;
}

.footer-logo {
    height: 28px;
    width: auto;
    opacity: 0.45;
    margin-bottom: 0.75rem;
}

.footer-legal {
    font-size: 0.75rem;
}

/* -----------------------------------------------------------------------------
   Buttons
   ----------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn:hover {
    text-decoration: none;
}

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

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

.btn-secondary {
    background: var(--color-bg-alt);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

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

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-accent {
    background: var(--color-accent);
    color: #ffffff;
    font-weight: 600;
}

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

.btn-ghost {
    background: transparent;
    color: #cbd5e1;
    border: 1px solid #475569;
}

.btn-ghost:hover {
    background: rgba(255,255,255,0.05);
    color: #ffffff;
    border-color: #94a3b8;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.375rem;
    font-weight: 500;
    font-size: 0.875rem;
}

.form-control {
    display: block;
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    transition: border-color 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-control-sm {
    padding: 0.375rem 0.625rem;
    font-size: 0.875rem;
}

.form-error {
    color: var(--color-error);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.form-help {
    color: var(--color-text-light);
    font-size: 0.8125rem;
    margin-top: 0.25rem;
}

.required {
    color: var(--color-error);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-label input {
    width: 1rem;
    height: 1rem;
}

/* -----------------------------------------------------------------------------
   Flash Messages
   ----------------------------------------------------------------------------- */
.flash-messages {
    max-width: 1200px;
    margin: 1rem auto;
    padding: 0 2rem;
}

.flash {
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.flash-success {
    background: #d1fae5;
    color: #065f46;
}

.flash-warning {
    background: #fef3c7;
    color: #92400e;
}

.flash-error {
    background: #fee2e2;
    color: #991b1b;
}

.flash-info {
    background: #dbeafe;
    color: #1e40af;
}

.flash-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    opacity: 0.6;
}

.flash-close:hover {
    opacity: 1;
}

/* -----------------------------------------------------------------------------
   Hero Section (Dark)
   ----------------------------------------------------------------------------- */
.hero-dark {
    background: var(--color-dark);
    color: #ffffff;
    text-align: center;
    padding: 3.5rem 2rem 3rem;
}

.hero-inner {
    max-width: 720px;
    margin: 0 auto;
}

.hero-eyebrow {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-accent);
    margin-bottom: 1rem;
}

.hero-dark h1 {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1.15;
    margin-bottom: 1.25rem;
    letter-spacing: -0.02em;
}

.hero-subtitle {
    font-size: 1.125rem;
    line-height: 1.7;
    color: #94a3b8;
    margin-bottom: 2rem;
}

.hero-cta {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1.25rem;
}

.hero-note {
    font-size: 0.8125rem;
    color: #64748b;
    margin: 0;
}

/* -----------------------------------------------------------------------------
   Stats Bar
   ----------------------------------------------------------------------------- */
.stats-bar {
    background: var(--color-dark);
    border-top: 1px solid #1e293b;
    padding: 2rem 2rem 2.5rem;
}

.stats-inner {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
}

.stat {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffffff;
    font-family: var(--font-mono);
}

.stat-label {
    display: block;
    font-size: 0.75rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.125rem;
}

/* Legacy hero (keep for compatibility) */
.hero {
    text-align: center;
    padding: 4rem 2rem;
    background: linear-gradient(135deg, #f0f7ff 0%, #e8f0fe 100%);
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.hero-description {
    max-width: 600px;
    margin: 0 auto 2rem;
    color: var(--color-text-light);
}

/* -----------------------------------------------------------------------------
   Section Layout
   ----------------------------------------------------------------------------- */
.section-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 2rem;
}

.section-title {
    text-align: center;
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.01em;
}

.section-subtitle {
    text-align: center;
    color: var(--color-text-light);
    max-width: 600px;
    margin: 0 auto 2rem;
}

/* -----------------------------------------------------------------------------
   Features Grid
   ----------------------------------------------------------------------------- */
.features-section {
    padding: 3.5rem 0;
    background: var(--color-bg);
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.feature-card {
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.feature-card:hover {
    box-shadow: var(--shadow-xl);
    border-color: #cbd5e1;
}

.feature-card-highlight {
    border-left: 3px solid var(--color-accent);
}

.feature-card h3 {
    font-size: 1.125rem;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.feature-card p {
    color: var(--color-text-light);
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.6;
}

/* -----------------------------------------------------------------------------
   Audience / Use Cases
   ----------------------------------------------------------------------------- */
.audience-section {
    padding: 3.5rem 0;
    background: var(--color-bg-alt);
}

.audience-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.audience-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-primary);
    border-radius: var(--radius-lg);
    padding: 1.75rem 2rem;
    transition: box-shadow 0.2s ease;
}

.audience-card:hover {
    box-shadow: var(--shadow-xl);
}

.audience-card h3 {
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--color-dark);
    margin-bottom: 0.375rem;
}

.audience-card p {
    color: var(--color-text-light);
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.6;
}

/* Legacy feature/use-case grid (other pages) */
.features, .use-cases {
    padding: 4rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.features h2, .use-cases h2 {
    text-align: center;
    margin-bottom: 2rem;
}

.use-case-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.use-case {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.use-case h3 {
    color: var(--color-primary);
    margin-bottom: 0.5rem;
}

.use-case p {
    color: var(--color-text-light);
    margin: 0;
}

/* -----------------------------------------------------------------------------
   CTA Sections
   ----------------------------------------------------------------------------- */
.cta-section {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--color-bg-alt);
}

.cta-section h2 {
    margin-bottom: 0.5rem;
}

.cta-section p {
    color: var(--color-text-light);
    margin-bottom: 1.5rem;
}

.cta-dark {
    text-align: center;
    padding: 3.5rem 2rem;
    background: var(--color-dark);
    color: #ffffff;
}

.cta-dark h2 {
    font-size: 1.75rem;
    margin-bottom: 0.75rem;
    color: #ffffff;
}

.cta-dark p {
    color: #94a3b8;
    margin-bottom: 2rem;
    font-size: 1.0625rem;
}

/* -----------------------------------------------------------------------------
   Auth Pages
   ----------------------------------------------------------------------------- */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 200px);
    padding: 2rem;
}

.auth-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.auth-card h1 {
    text-align: center;
    margin-bottom: 0.5rem;
}

.auth-subtitle {
    text-align: center;
    color: var(--color-text-light);
    margin-bottom: 1.5rem;
}

.auth-form {
    margin-top: 1.5rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
    color: var(--color-text-light);
}

/* -----------------------------------------------------------------------------
   Search Page
   ----------------------------------------------------------------------------- */
.search-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    color: var(--color-text-light);
}

.upgrade-link {
    font-weight: 500;
}

.search-form {
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.search-form-compact {
    padding: 1rem;
    margin-bottom: 1rem;
}

.search-main {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

.search-filters {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.search-filters .form-control-sm {
    min-width: 160px;
    max-width: 320px;
}

.search-main .form-group {
    margin-bottom: 0;
}

.form-group-grow {
    flex: 1;
}

.btn-search {
    white-space: nowrap;
}

.search-filters {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.search-filters summary {
    cursor: pointer;
    font-weight: 500;
    color: var(--color-text-light);
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.search-tips {
    background: var(--color-bg-alt);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.search-tips h3 {
    margin-bottom: 0.75rem;
}

.search-tips ul {
    margin: 0;
}

.search-tips li {
    margin-bottom: 0.25rem;
}

/* -----------------------------------------------------------------------------
   Results Page
   ----------------------------------------------------------------------------- */
.results-header {
    margin-bottom: 1rem;
}

.results-summary {
    color: var(--color-text-light);
    margin: 0;
}

.export-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.export-form {
    display: inline;
}

.table-container {
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.results-table th,
.results-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.results-table th {
    background: var(--color-bg-alt);
    font-weight: 600;
    white-space: nowrap;
}

.results-table tr:last-child td {
    border-bottom: none;
}

.results-table tr:hover td {
    background: var(--color-bg-alt);
}

.text-right {
    text-align: right;
}

.cell-code {
    font-family: var(--font-mono);
}

.cell-code a {
    font-weight: 500;
}

.code-type {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--color-text-light);
    margin-left: 0.25rem;
}

.cell-description {
    white-space: normal;
    word-wrap: break-word;
}

.cell-price {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
}

.no-results {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--color-text-light);
}

.refine-required {
    text-align: center;
    padding: 2rem;
    margin: 1.5rem 0;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 6px;
}

.refine-required h2 {
    margin: 0 0 0.75rem;
    color: #e65100;
    font-size: 1.2rem;
}

.refine-required p {
    margin: 0.5rem 0;
    color: var(--color-text);
}

.refine-hint {
    font-size: 0.85rem;
    color: var(--color-text-light) !important;
    font-style: italic;
}

/* -----------------------------------------------------------------------------
   Code Detail Page
   ----------------------------------------------------------------------------- */
.breadcrumb {
    color: var(--color-text-light);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.breadcrumb a {
    color: var(--color-text-light);
}

.code-description {
    font-size: 1.125rem;
    color: var(--color-text-light);
    margin-bottom: 1.5rem;
}

.price-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.summary-card {
    background: var(--color-bg-alt);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}

.summary-label {
    display: block;
    font-size: 0.75rem;
    color: var(--color-text-light);
    margin-bottom: 0.25rem;
}

.summary-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 600;
}

/* -----------------------------------------------------------------------------
   Account Page
   ----------------------------------------------------------------------------- */
.account-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.account-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.account-card h2 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

.account-info {
    margin-bottom: 1rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
}

.info-label {
    color: var(--color-text-light);
}

.info-value {
    font-weight: 500;
}

.tier-free { color: var(--color-text); }
.tier-basic { color: var(--color-primary); }
.tier-pro { color: var(--color-success); }

.account-cta {
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.account-cta p {
    font-size: 0.875rem;
    color: var(--color-text-light);
    margin-bottom: 0.75rem;
}

.usage-bar-container {
    height: 8px;
    background: var(--color-border);
    border-radius: 4px;
    overflow: hidden;
}

.usage-bar {
    height: 100%;
    background: var(--color-primary);
    transition: width 0.3s ease;
}

.usage-text {
    font-size: 0.875rem;
    color: var(--color-text-light);
    margin-top: 0.5rem;
}

/* -----------------------------------------------------------------------------
   Pricing Page
   ----------------------------------------------------------------------------- */
.pricing-subtitle {
    text-align: center;
    color: var(--color-text-light);
    margin-bottom: 2rem;
}

.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    max-width: 960px;
    margin: 0 auto 3rem;
}

.pricing-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    position: relative;
}

.pricing-card-featured {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary);
}

.pricing-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.pricing-card h2 {
    margin-bottom: 0.5rem;
}

.price {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.price span {
    font-size: 1rem;
    font-weight: 400;
    color: var(--color-text-light);
}

.pricing-features {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem;
    text-align: left;
}

.pricing-features li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
}

.pricing-features li:last-child {
    border-bottom: none;
}

.pricing-faq {
    max-width: 700px;
    margin: 0 auto;
}

.faq-item {
    margin-bottom: 1.5rem;
}

.faq-item h3 {
    margin-bottom: 0.5rem;
}

.faq-item p {
    color: var(--color-text-light);
    margin: 0;
}

/* -----------------------------------------------------------------------------
   Error Pages
   ----------------------------------------------------------------------------- */
.error-page {
    text-align: center;
    padding: 4rem 2rem;
}

.error-page h1 {
    font-size: 6rem;
    color: var(--color-text-light);
    margin-bottom: 0;
}

.error-page h2 {
    margin-bottom: 1rem;
}

.error-page p {
    color: var(--color-text-light);
    margin-bottom: 2rem;
}

/* -----------------------------------------------------------------------------
   Responsive
   ----------------------------------------------------------------------------- */
/* -----------------------------------------------------------------------------
   Expand/Collapse & Detail Cards
   ----------------------------------------------------------------------------- */
.expand-chevron {
    display: inline-block;
    width: 1em;
    text-align: center;
    color: var(--color-text-light);
    transition: color 0.15s ease;
}

.result-row {
    cursor: pointer;
}

.result-row:hover {
    background: #f0f4ff;
}

.result-row-expanded {
    background: #f0f4ff;
}

/* CSP-safe hidden class — replaces inline style="display: none;" */
.hidden { display: none; }

.detail-row td {
    background: var(--color-bg-alt);
    padding: 0 1rem 1rem;
    border-bottom: 2px solid var(--color-border);
}

.detail-card {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    padding: 0.75rem 0;
}

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

.detail-fields {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25rem 0.75rem;
    font-size: 0.8125rem;
}

.detail-label {
    color: var(--color-text-light);
    white-space: nowrap;
}

.detail-value {
    font-weight: 500;
    word-break: break-word;
}

.detail-value-notes {
    font-weight: 400;
    font-style: italic;
    color: var(--color-text);
}

/* -----------------------------------------------------------------------------
   Sort Indicators
   ----------------------------------------------------------------------------- */
.sortable-header {
    cursor: pointer;
    user-select: none;
    position: relative;
}

.sortable-header:hover {
    color: var(--color-primary);
}

.sort-indicator {
    font-size: 0.6875rem;
    color: var(--color-primary);
}

/* -----------------------------------------------------------------------------
   Historical Row Styling
   ----------------------------------------------------------------------------- */
.result-row-historical {
    background: #f5f0e4;
    opacity: 0.8;
    border-left: 3px solid #d4c5a0;
}

.result-row-historical:hover {
    background: #efe8d6;
    opacity: 1;
}

.badge-historical {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 600;
    background: #e8dcc8;
    color: #7a6a4f;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    margin-left: 0.375rem;
    vertical-align: middle;
}

.badge-govt {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 600;
    background: #dbeafe;
    color: #1e40af;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    vertical-align: middle;
}

/* -----------------------------------------------------------------------------
   Data Freshness
   ----------------------------------------------------------------------------- */
.data-freshness {
    font-size: 0.8125rem;
    color: var(--color-text-light);
    margin-top: 0.25rem;
}

/* -----------------------------------------------------------------------------
   Historical Toggle
   ----------------------------------------------------------------------------- */
.historical-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.875rem;
}

.historical-toggle input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

.historical-toggle label {
    cursor: pointer;
    color: var(--color-text-light);
}

/* -----------------------------------------------------------------------------
   Post-Search Result Filters
   ----------------------------------------------------------------------------- */
.result-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.filter-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-light);
}

.filter-select {
    padding: 0.3125rem 0.5rem;
    font-size: 0.8125rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    max-width: 220px;
}

.filter-select:focus {
    outline: none;
    border-color: var(--color-primary);
}

.filter-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    white-space: nowrap;
}

.filter-count {
    font-size: 0.8125rem;
    color: var(--color-text-light);
    font-weight: 500;
}

.filter-clear {
    font-size: 0.75rem;
    color: var(--color-primary);
    background: none;
    border: 1px solid var(--color-primary);
    cursor: pointer;
}

.filter-clear:hover {
    background: var(--color-primary);
    color: white;
}

/* -----------------------------------------------------------------------------
   Plan Cell
   ----------------------------------------------------------------------------- */
.cell-plan {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* -----------------------------------------------------------------------------
   Code Type Badge (compact table)
   ----------------------------------------------------------------------------- */
.code-badge {
    display: inline-block;
    font-size: 0.625rem;
    font-weight: 600;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    color: var(--color-text-light);
    padding: 0.0625rem 0.25rem;
    border-radius: 3px;
    margin-left: 0.25rem;
    vertical-align: middle;
    text-transform: uppercase;
}

/* -----------------------------------------------------------------------------
   Responsive
   ----------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .hero-dark {
        padding: 3rem 1.5rem 2.5rem;
    }

    .hero-dark h1 {
        font-size: 2rem;
    }

    .hero-cta {
        flex-direction: column;
        align-items: center;
    }

    .stats-inner {
        flex-wrap: wrap;
        gap: 1.5rem;
        justify-content: center;
    }

    .stat {
        min-width: 100px;
    }

    .feature-grid,
    .audience-grid {
        grid-template-columns: 1fr;
    }

    .search-main {
        flex-direction: column;
        align-items: stretch;
    }

    .search-filters {
        flex-direction: column;
    }

    .search-filters .form-control-sm {
        max-width: 100%;
    }

    .nav-links {
        gap: 1rem;
    }

    .results-table {
        font-size: 0.8125rem;
    }

    .results-table th,
    .results-table td {
        padding: 0.5rem;
    }
}

/* -----------------------------------------------------------------------------
   Dark Mode
   ----------------------------------------------------------------------------- */
[data-theme="dark"] {
    --color-primary: #60a5fa;
    --color-primary-dark: #3b82f6;
    --color-accent: #34d399;
    --color-accent-dark: #10b981;
    --color-secondary: #94a3b8;
    --color-success: #34d399;
    --color-warning: #fbbf24;
    --color-error: #f87171;

    --color-text: #e2e8f0;
    --color-text-light: #94a3b8;
    --color-bg: #0f172a;
    --color-bg-alt: #1e293b;
    --color-border: #334155;

    --color-dark: #020617;
    --color-dark-mid: #0f172a;

    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.5);
    --shadow-xl: 0 8px 24px rgba(0,0,0,0.5);
}

[data-theme="dark"] .header {
    background: #020617;
}

[data-theme="dark"] .footer {
    background: #020617;
    border-top-color: #1e293b;
}

[data-theme="dark"] .form-control {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #334155;
}

[data-theme="dark"] .form-control:focus {
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

[data-theme="dark"] .results-table th {
    background: #1e293b;
    color: #cbd5e1;
    border-bottom-color: #334155;
}

[data-theme="dark"] .results-table td {
    border-bottom-color: #1e293b;
}

[data-theme="dark"] .detail-card {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .detail-section-title {
    color: #94a3b8;
}

[data-theme="dark"] .detail-label {
    color: #94a3b8;
}

[data-theme="dark"] .result-row:hover {
    background: #1e293b;
}

[data-theme="dark"] .result-row-expanded {
    background: #1e293b;
}

[data-theme="dark"] .result-row-historical {
    background: #1a1a10;
    border-left-color: #665e3a;
}

[data-theme="dark"] .result-row-historical:hover {
    background: #252510;
}

[data-theme="dark"] .badge-historical {
    background: #3d3820;
    color: #d4c090;
}

[data-theme="dark"] .badge-govt {
    background: #1e3a5f;
    color: #93c5fd;
}

[data-theme="dark"] .flash-success {
    background: #064e3b;
    color: #a7f3d0;
}

[data-theme="dark"] .flash-warning {
    background: #78350f;
    color: #fde68a;
}

[data-theme="dark"] .flash-error {
    background: #7f1d1d;
    color: #fecaca;
}

[data-theme="dark"] .flash-info {
    background: #1e3a5f;
    color: #bfdbfe;
}

[data-theme="dark"] .card {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .search-filters {
    border-top-color: #334155;
}

[data-theme="dark"] .export-actions .btn {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #334155;
}

[data-theme="dark"] .export-actions .btn:hover {
    background: #334155;
}

[data-theme="dark"] .hero {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

[data-theme="dark"] .feature-card,
[data-theme="dark"] .audience-card {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .audience-card h3 {
    color: #f1f5f9;
}

[data-theme="dark"] .pricing-card {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .refine-required {
    background: #1a1700;
    border-color: #665e3a;
}

[data-theme="dark"] .filter-select {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #334155;
}

/* Dark mode toggle button */
.theme-toggle {
    background: none;
    border: 1px solid #475569;
    color: #cbd5e1;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
    font-size: 1rem;
    line-height: 1;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover {
    background: rgba(255,255,255,0.05);
    border-color: #94a3b8;
}
