/* Tracivic — Design System v3
   Palette: Slate/Navy/Blue — inspired by Tailwind UI, USWDS, and Linear
   Backgrounds neutral (slate), interactive vivid blue, deep navy for brand.
*/

:root {
    --pico-font-size: 17px;

    /* ── Brand ──────────────────────────────────────────────── */
    --brand-primary:   #0c3055;   /* Deep navy — headings, primary brand */
    --brand-accent:    #1a65b5;   /* Vivid blue — buttons, links, active */
    --brand-hover:     #14509a;   /* Darker blue for hover states */
    --brand-bright:    #3b82f6;   /* Tailwind blue-500 — vivid indicators */
    --brand-teal:      #0891b2;   /* Cyan-600 — secondary accents */
    --brand-amber:     #d97706;   /* Amber-600 */
    --brand-light:     #dbeafe;   /* Blue-100 — badge/pill backgrounds */
    --brand-gradient:  linear-gradient(135deg, #0c3055 0%, #1a65b5 100%);

    /* ── Backgrounds ────────────────────────────────────────── */
    --dash-bg:         #f1f5f9;   /* Slate-100 — page background */
    --card-bg:         #ffffff;   /* Pure white — cards/tables */
    --muted-bg:        #f8fafc;   /* Slate-50 — subtle inset areas */

    /* ── Borders ─────────────────────────────────────────────  */
    --border-color:    #e2e8f0;   /* Slate-200 — standard borders */
    --border-strong:   #cbd5e1;   /* Slate-300 — emphasis borders */

    /* ── Text ───────────────────────────────────────────────── */
    --text-primary:    #0f172a;   /* Slate-900 — body text */
    --text-secondary:  #475569;   /* Slate-600 — secondary text */
    --text-muted:      #94a3b8;   /* Slate-400 — placeholders, timestamps */

    /* ── Semantic ───────────────────────────────────────────── */
    --color-success:   #059669;   /* Emerald-600 */
    --color-success-bg:#d1fae5;   /* Emerald-100 */
    --color-success-bd:#6ee7b7;   /* Emerald-300 */
    --color-warning:   #d97706;   /* Amber-600 */
    --color-warning-bg:#fef3c7;   /* Amber-100 */
    --color-danger:    #dc2626;   /* Red-600 */
    --color-danger-bg: #fee2e2;   /* Red-100 */
    --color-info:      #0284c7;   /* Sky-600 */
    --color-info-bg:   #e0f2fe;   /* Sky-100 */

    --section-gap: 4rem;
}

/* ════════════════════════════════════════════
   NAV
═══════════════════════════════════════════ */
nav.container {
    padding-top: 1rem;
    padding-bottom: 1rem;
}
nav a[role="button"] {
    background: var(--brand-accent);
    border-color: var(--brand-accent);
    font-weight: 600;
    letter-spacing: 0.02em;
}
nav a[role="button"]:hover {
    background: var(--brand-hover);
    border-color: var(--brand-hover);
}

/* ════════════════════════════════════════════
   HERO
═══════════════════════════════════════════ */
.hero {
    text-align: center;
    padding: 4rem 0 3rem;
    background: var(--brand-gradient);
    color: #fff;
    border-radius: 14px;
    margin-bottom: var(--section-gap);
    box-shadow: 0 4px 24px rgba(12, 48, 85, 0.18);
}
.hero h1 {
    font-size: 2.6rem;
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 1rem;
    color: #fff;
}
.hero p {
    font-size: 1.15rem;
    color: rgba(255,255,255,0.88);
    max-width: 640px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ════════════════════════════════════════════
   SECTION HEADINGS
═══════════════════════════════════════════ */
.section-title {
    text-align: center;
    margin-bottom: 2.5rem;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--brand-primary);
}

/* ════════════════════════════════════════════
   CARDS GRID
═══════════════════════════════════════════ */
.cards {
    display: grid;
    gap: 1.5rem;
    margin-bottom: var(--section-gap);
}
.cards-3 { grid-template-columns: repeat(3, 1fr); }
.cards-4 { grid-template-columns: repeat(4, 1fr); }
.cards-2 { grid-template-columns: repeat(2, 1fr); }

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.75rem;
    transition: box-shadow 0.2s, transform 0.2s;
}
.card:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,0.07);
    transform: translateY(-2px);
}
.card .step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--brand-accent);
    color: #fff;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
}
.card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--brand-primary);
}
.card p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.55;
}
.card .icon-label {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    display: block;
}

/* ════════════════════════════════════════════
   PRICING
═══════════════════════════════════════════ */
.pricing-card {
    text-align: center;
    position: relative;
}
.pricing-card .price {
    font-size: 2rem;
    font-weight: 800;
    color: var(--brand-primary);
    margin: 0.5rem 0 1rem;
}
.pricing-card .price span {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text-muted);
}
.pricing-card ul {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
    text-align: left;
}
.pricing-card ul li {
    padding: 0.4rem 0;
    font-size: 0.92rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}
.pricing-card ul li::before {
    content: "\2713\0020";
    color: var(--color-success);
    font-weight: 700;
}
.pricing-card.featured {
    border: 2px solid var(--brand-accent);
    box-shadow: 0 4px 20px rgba(26, 101, 181, 0.15);
}
.pricing-card.featured::before {
    content: "Most Popular";
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--brand-accent);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 14px;
    border-radius: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* ════════════════════════════════════════════
   CTA / SIGNUP
═══════════════════════════════════════════ */
.cta-section {
    background: var(--brand-light);
    border: 1px solid #bfdbfe;
    border-radius: 14px;
    padding: 3rem;
    text-align: center;
    margin-bottom: var(--section-gap);
}
.cta-section h2 {
    color: var(--brand-primary);
    margin-bottom: 0.5rem;
}
.cta-section p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}
.cta-section form {
    max-width: 420px;
    margin: 0 auto;
    text-align: left;
}
.cta-section button {
    width: 100%;
    background: var(--brand-accent);
    border-color: var(--brand-accent);
    font-weight: 600;
    font-size: 1rem;
    padding: 0.75rem;
}
.cta-section button:hover {
    background: var(--brand-hover);
}

/* ════════════════════════════════════════════
   UTILITY
═══════════════════════════════════════════ */
mark {
    background: var(--color-warning-bg);
    padding: 2px 6px;
    border-radius: 3px;
    color: var(--text-primary);
}
details summary { cursor: pointer; }

footer.container {
    margin-top: var(--section-gap);
    padding: 1.5rem 0;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-muted);
}
table { font-size: 0.9rem; }

/* ════════════════════════════════════════════
   DASHBOARD LAYOUT
═══════════════════════════════════════════ */
body, main.container {
    background: var(--dash-bg);
}

.api-key-box {
    background: var(--muted-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    font-family: monospace;
    font-size: 0.85rem;
    word-break: break-all;
    color: var(--text-primary);
}

/* Dashboard header */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}
.dashboard-header h2 {
    margin-bottom: 0.25rem;
    color: var(--brand-primary);
}
.dashboard-header p {
    color: var(--text-secondary);
    margin-bottom: 0;
}

/* Dashboard two-column layout */
.dashboard-layout {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 2rem;
    align-items: start;
}
.dashboard-main {
    min-width: 0; /* prevent overflow */
}

/* Dashboard sections */
.dash-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.dash-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.dash-section-header h3 {
    margin-bottom: 0;
    color: var(--brand-primary);
    font-size: 1.3rem;
}

/* Badge */
.badge {
    display: inline-block;
    background: var(--brand-light);
    color: var(--brand-accent);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.2rem 0.65rem;
    border-radius: 12px;
}

/* ════════════════════════════════════════════
   FORM ROWS
═══════════════════════════════════════════ */
.form-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}
.form-group {
    display: flex;
    flex-direction: column;
    min-width: 140px;
}
.form-group label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}
.form-group input,
.form-group select {
    margin-bottom: 0;
    padding: 0.5rem 0.65rem;
    font-size: 0.95rem;
}
.form-group-grow {
    flex: 1;
}
.form-group-btn {
    display: flex;
    gap: 0.5rem;
    min-width: auto;
}

/* ════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.btn-primary {
    background: var(--brand-accent);
    color: #fff;
    border-color: var(--brand-accent);
}
.btn-primary:hover {
    background: var(--brand-hover);
    color: #fff;
    border-color: var(--brand-hover);
}
.btn-outline {
    background: transparent;
    color: var(--brand-accent);
    border-color: var(--brand-accent);
}
.btn-outline:hover {
    background: var(--brand-light);
    color: var(--brand-accent);
}
.btn-sm {
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
}
.btn-danger {
    background: var(--color-danger);
    color: #fff;
    border-color: var(--color-danger);
}
.btn-danger:hover {
    background: #b91c1c;
}
.btn-success {
    background: var(--color-success);
    color: #fff;
    border-color: var(--color-success);
}
.btn-success:hover {
    background: #047857;
}

/* ════════════════════════════════════════════
   DASHBOARD TABLES
═══════════════════════════════════════════ */
.table-wrap {
    overflow-x: auto;
}
.dash-table {
    width: 100%;
    font-size: 0.95rem;
    border-collapse: collapse;
}
.dash-table th {
    background: var(--muted-bg);
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    padding: 0.65rem 0.75rem;
    border-bottom: 2px solid var(--border-strong);
    text-align: left;
}
.dash-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
    font-size: 0.95rem;
    color: var(--text-primary);
}
.dash-table tbody tr:hover {
    background: var(--dash-bg);
}
.col-action {
    width: 140px;
    text-align: center;
    white-space: nowrap;
}
.col-action form {
    display: inline;
}
.col-action .btn + .btn,
.col-action form + form .btn {
    margin-left: 4px;
}
.col-summary {
    max-width: 250px;
    color: var(--text-secondary);
    font-size: 0.93rem;
}

/* ════════════════════════════════════════════
   PILLS / TAGS
═══════════════════════════════════════════ */
.pill {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    white-space: nowrap;
}
.pill-daily {
    background: var(--brand-light);
    color: var(--brand-accent);
}
.pill-instant {
    background: var(--color-warning-bg);
    color: #92400e;
}
.pill-weekly {
    background: var(--color-success-bg);
    color: #065f46;
}
.pill-category {
    background: var(--brand-light);
    color: var(--brand-primary);
}
.pill-tag {
    background: #cffafe;
    color: #164e63;
    margin: 1px;
}

/* Tag filter interaction */
.pill-tag-link { cursor: pointer; transition: background 0.15s, color 0.15s; }
.pill-tag-link:hover { background: var(--brand-teal); color: #fff; }

/* Active tag filter banner */
.active-tag-filter {
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* +N expand button */
.pill-expand-btn { cursor: pointer; background: var(--brand-amber); color: #fff; }
.pill-expand-btn:hover { background: #b45309; }

/* Status dots */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}
.status-active   { background: var(--color-success); }
.status-inactive { background: #94a3b8; }

/* ════════════════════════════════════════════
   EXPANDABLE ROWS
═══════════════════════════════════════════ */
.expandable-row {
    cursor: pointer;
}
.expandable-row:hover {
    background: #eff6ff !important;
}
.expandable-row.expanded {
    background: #eff6ff;
}
.expand-detail {
    display: none;
}
.expand-detail td {
    padding: 0;
    background: var(--muted-bg);
}
/* Slide-down animation container */
.expand-detail-inner {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.expand-detail.expanded .expand-detail-inner {
    max-height: 1200px;
}
.detail-content {
    padding: 1rem 1.5rem;
    border-left: 3px solid var(--brand-accent);
    margin: 0.25rem 0;
}

/* Source link at the bottom of expanded row */
.detail-source-link {
    margin-top: 0.75rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.82rem;
}
.detail-source-link a {
    color: var(--brand-accent);
    text-decoration: none;
    font-weight: 600;
}
.detail-source-link a:hover {
    text-decoration: underline;
    color: var(--brand-hover);
}
.detail-block {
    margin-bottom: 0.75rem;
}
.detail-block:last-child {
    margin-bottom: 0;
}
.detail-block strong {
    font-size: 0.82rem;
    color: var(--brand-primary);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.detail-block p {
    margin: 0.25rem 0 0;
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ════════════════════════════════════════════
   ATTACHMENTS IN DETAIL VIEW
═══════════════════════════════════════════ */
.attachment-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0;
}
.attachment-list li {
    padding: 0.5rem 0.75rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 0.4rem;
}
.att-filename {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
}
.att-type {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 0.5rem;
}
.att-summary {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin: 0.25rem 0;
    line-height: 1.45;
}
.att-link {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--brand-accent);
}

/* External link icon */
.external-link {
    font-size: 0.85rem;
    text-decoration: none;
    margin-left: 4px;
    color: var(--brand-accent);
}

/* ════════════════════════════════════════════
   SEARCH RESULTS HEADER
═══════════════════════════════════════════ */
.search-results-header {
    margin-bottom: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}
.search-results-header p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ════════════════════════════════════════════
   PAGINATION
═══════════════════════════════════════════ */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0 0.25rem;
}
.page-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
}
.empty-state p {
    margin: 0;
}

/* ════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════ */
.dashboard-sidebar {
    position: sticky;
    top: 1rem;
}
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    text-align: center;
}
.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--brand-primary);
    line-height: 1.2;
}
.stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

/* Sidebar navigation */
.sidebar-nav {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-top: 0.75rem;
}
.sidebar-nav h4 {
    font-size: 0.82rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
}
.sidebar-nav a {
    display: block;
    padding: 0.35rem 0;
    font-size: 0.88rem;
    color: var(--brand-accent);
    text-decoration: none;
    border-bottom: 1px solid var(--border-color);
}
.sidebar-nav a:last-child {
    border-bottom: none;
}
.sidebar-nav a:hover {
    color: var(--brand-primary);
}

/* ════════════════════════════════════════════
   LATEST PULLS
═══════════════════════════════════════════ */
.section-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-top: -1.5rem;
    margin-bottom: 1rem;
    font-size: 1.05rem;
}
.last-updated {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}
.latest-items, .latest-preview {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}
.latest-item-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.5rem;
    transition: box-shadow 0.2s;
}
.latest-item-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}
.latest-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.latest-item-meta {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}
.latest-city {
    background: var(--brand-primary);
    color: #fff;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}
.latest-body {
    color: var(--text-secondary);
    font-size: 0.85rem;
}
.latest-date {
    color: var(--text-muted);
    font-size: 0.8rem;
}
.latest-category {
    background: var(--brand-light);
    color: var(--brand-primary);
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
}
.latest-item-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--brand-primary);
    margin-bottom: 0.5rem;
    line-height: 1.4;
}
.latest-ai-summary {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-bottom: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--muted-bg);
    border-left: 3px solid var(--brand-accent);
    border-radius: 0 4px 4px 0;
}
.latest-ai-tags {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}
.tag {
    background: var(--brand-light);
    color: var(--brand-accent);
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
}
.latest-source-link {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--brand-accent);
}

/* ════════════════════════════════════════════
   PAGINATION (latest page)
═══════════════════════════════════════════ */
.pagination-nav {
    margin-top: 2rem;
    margin-bottom: 2rem;
}
.pagination-nav ul {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    list-style: none;
    padding: 0;
    margin: 0;
}
.pagination-nav .disabled {
    color: var(--text-muted);
}
.pagination-nav .page-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ════════════════════════════════════════════
   ABOUT PAGE
═══════════════════════════════════════════ */
.hero-compact {
    padding: 2.5rem 2rem;
    margin-bottom: 3rem;
}
.hero-compact h1 {
    font-size: 2rem;
}
.about-content {
    max-width: 720px;
    margin: 0 auto;
    margin-bottom: var(--section-gap);
}
.about-content p {
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}
.stat-number {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--brand-accent);
    line-height: 1.2;
}

/* ════════════════════════════════════════════
   CONTACT PAGE
═══════════════════════════════════════════ */
.contact-success {
    background: var(--color-success-bg);
    color: #065f46;
    border: 1px solid var(--color-success-bd);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

/* ════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════ */
@media (max-width: 768px) {
    .cards-3, .cards-4 { grid-template-columns: 1fr; }
    .cards-2 { grid-template-columns: 1fr; }
    .hero h1 { font-size: 1.8rem; }
    .hero { padding: 2.5rem 1.5rem; }
    .cta-section { padding: 2rem 1.5rem; }

    .dashboard-layout {
        grid-template-columns: 1fr;
    }
    .dashboard-sidebar {
        position: static;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
        gap: 0.5rem;
    }
    .sidebar-nav {
        grid-column: 1 / -1;
    }
    .dashboard-header {
        flex-direction: column;
        gap: 1rem;
    }
    .form-row {
        flex-direction: column;
    }
    .form-group {
        min-width: 100%;
    }
}
@media (min-width: 769px) and (max-width: 1024px) {
    .cards-3 { grid-template-columns: repeat(2, 1fr); }
    .cards-4 { grid-template-columns: repeat(2, 1fr); }
    .dashboard-layout {
        grid-template-columns: 1fr 220px;
    }
}

/* ════════════════════════════════════════════
   SMART SEARCH
═══════════════════════════════════════════ */
.smart-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
}
.smart-toggle input[type="checkbox"] {
    width: auto;
    margin: 0;
}
.smart-answer {
    background: var(--brand-gradient);
    border: 1px solid var(--brand-hover);
    border-radius: 8px;
    padding: 1rem 1.2rem;
    margin-bottom: 1rem;
}
.smart-answer-header {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #93c5fd;
    margin-bottom: 0.5rem;
}
.smart-answer p {
    margin: 0;
    line-height: 1.6;
    color: #dbeafe;
}

/* Smart answer card (dashboard search) */
.smart-answer-card {
    background: var(--brand-gradient);
    color: #e0f2fe;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid var(--brand-hover);
}
.smart-answer-label {
    font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em;
    text-transform: uppercase; color: #93c5fd; margin-bottom: 0.5rem;
}
.smart-answer-body { font-size: 0.93rem; line-height: 1.65; color: #dbeafe; }
.smart-answer-note { font-size: 0.75rem; color: #7dd3fc; margin-top: 0.5rem; }

/* Generating spinner */
.smart-answer-generating {
    display: flex; align-items: center; gap: 0.6rem;
    font-size: 0.9rem; color: #93c5fd; padding: 0.25rem 0;
}
.generating-dots {
    display: inline-block; width: 18px; height: 18px;
    border: 2px solid #93c5fd; border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Citation links in smart answer */
a.cite-link {
    display: inline-block;
    background: rgba(147,197,253,0.18);
    color: #bae6fd;
    border: 1px solid rgba(147,197,253,0.35);
    border-radius: 3px;
    padding: 0 4px;
    font-size: 0.82em;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s;
    vertical-align: super;
    line-height: 1;
}
a.cite-link:hover { background: rgba(147,197,253,0.35); color: #fff; }

/* Superscript citation markers inside answer text */
sup.cite-ref {
    font-size: 0.72em;
    font-weight: 700;
    line-height: 1;
    vertical-align: super;
}

/* Citations list below the AI answer */
.smart-citations {
    margin-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.2);
    padding-top: 10px;
}
.smart-citations-heading {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #93c5fd;
    margin-bottom: 6px;
}
.smart-citation {
    font-size: 0.8rem;
    margin-bottom: 6px;
    opacity: 0.85;
    line-height: 1.4;
}
.smart-citation-id { font-weight: 700; margin-right: 4px; }
.smart-citation-id-link { text-decoration: none; }
.smart-citation-meta { color: inherit; }
.smart-citation-title {
    display: block;
    margin-top: 2px;
    padding-left: 1.2em;
    font-weight: 600;
    opacity: 0.9;
}
.smart-citation-snippet {
    display: block;
    font-style: italic;
    opacity: 0.75;
    margin-top: 2px;
    padding-left: 1.2em;
}

/* Highlight row when citation is clicked */
tr.cite-highlight td {
    animation: cite-flash 1.8s ease-out;
}
@keyframes cite-flash {
    0%   { background: rgba(250,204,21,0.28); }
    100% { background: transparent; }
}

/* ════════════════════════════════════════════
   SEARCH UI
═══════════════════════════════════════════ */
.search-row-filters { align-items: flex-end; flex-wrap: wrap; gap: 0.5rem; }

.smart-toggle-label {
    display: flex; align-items: center; gap: 0.4rem;
    font-size: 0.88rem; cursor: pointer; white-space: nowrap;
    padding: 6px 10px; border: 1px solid var(--border-color); border-radius: 6px;
    background: var(--card-bg); user-select: none; color: var(--text-secondary);
}
.smart-toggle-label:hover { background: var(--brand-light); border-color: var(--brand-accent); }
.smart-toggle-label input[type="checkbox"] { margin: 0; cursor: pointer; }
.smart-toggle-group { align-self: flex-end; }

/* ── Sortable column headers ── */
.sortable-col {
    cursor: pointer; white-space: nowrap; user-select: none;
    transition: background 0.15s;
}
.sortable-col:hover { background: var(--dash-bg); }
.sort-active { color: var(--brand-primary); background: var(--brand-light) !important; }
.sort-arrow { color: var(--brand-accent); font-size: 0.8em; }
.sort-hint { color: var(--border-strong); font-size: 0.8em; }

/* ── Column sizing ── */
.col-relevance { text-align: center; width: 56px; min-width: 52px; padding: 4px 6px; }
.relevance-badge {
    display: inline-block;
    min-width: 32px;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 700;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.rel-high  { background: #d1fae5; color: #065f46; }
.rel-mid   { background: #fef9c3; color: #713f12; }
.rel-low   { background: #f1f5f9; color: #64748b; }
.col-date { white-space: nowrap; min-width: 90px; }
.col-city { white-space: nowrap; }
.col-body { white-space: nowrap; font-size: 0.85rem; color: var(--text-secondary); min-width: 90px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.col-body-hdr { min-width: 90px; }
.col-summary { max-width: 340px; font-size: 0.93rem; line-height: 1.45; color: var(--text-primary); }
.col-summary-hdr { min-width: 260px; }
.col-tags { min-width: 80px; }
.col-tags-hdr { min-width: 80px; }
.col-docs { text-align: center; white-space: nowrap; }
.col-docs-hdr { text-align: center; }
.col-category { min-width: 100px; }
@media (max-width: 900px) { .col-body, .col-body-hdr { display: none; } }

/* ── Status pill ── */
.pill-upcoming { background: var(--color-success-bg); color: #065f46; font-size: 0.7rem; }

/* ── Match type badges ── */
.match-type {
    font-size: 0.7rem;
    padding: 1px 5px;
    border-radius: 3px;
    vertical-align: middle;
    margin-left: 4px;
}
.match-type-semantic {
    background: var(--brand-hover);
    color: #bfdbfe;
}
.match-type-fts {
    background: #134e4a;
    color: #99f6e4;
}
.match-type-both {
    background: #4c1d95;
    color: #ddd6fe;
}
.match-badge {
    display: inline-block; font-size: 0.7rem; padding: 1px 5px;
    border-radius: 4px; margin-left: 4px; vertical-align: middle;
    cursor: default;
}
.match-fts      { background: var(--brand-light); color: var(--brand-primary); }
.match-semantic { background: #f3e8ff; color: #6d28d9; }
.match-both     { background: #fef9c3; color: #78350f; }

/* ── Pills ── */
.pill-more { background: var(--brand-light); color: var(--brand-primary); font-size: 0.78rem; }

/* ── Docs badge ── */
.docs-badge {
    display: inline-block; font-size: 0.8rem; padding: 2px 7px;
    border-radius: 10px; font-weight: 600; white-space: nowrap;
}
.docs-local { background: var(--color-success-bg); color: #065f46; }
.docs-ext   { background: var(--brand-light); color: var(--brand-primary); }
.docs-multi { background: var(--bg-tertiary); color: var(--text-secondary); cursor: pointer; user-select: none; }
.docs-multi:hover { background: var(--border-color); }
a.docs-badge { text-decoration: none; }
a.docs-badge:hover { filter: brightness(0.9); }

/* ── Docs multi-dropdown ── */
.docs-multi-wrap { display: inline-block; }
#docs-popup {
    position: fixed;
    background: var(--bg-primary); border: 1px solid var(--border-color);
    border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,0.15);
    z-index: 9999; min-width: 200px; max-width: 340px; padding: 4px 0;
}
.docs-dropdown-item {
    display: flex; align-items: center; gap: 7px;
    padding: 8px 14px; color: var(--text-primary); text-decoration: none;
    font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: background 0.1s;
}
.docs-dropdown-item:hover { background: var(--bg-secondary); }
.docs-dd-local { color: #065f46; }

/* ── Attachment cards ── */
.att-cards { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.5rem; }
.att-card {
    background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 8px;
    padding: 0.75rem 1rem; transition: border-color 0.15s, box-shadow 0.15s;
}
.att-card:hover { border-color: var(--brand-accent); box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.att-card-meta { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.35rem; }
.att-icon { font-size: 1.1rem; }
.att-card-name { font-weight: 600; font-size: 0.88rem; color: var(--brand-primary); flex: 1; }
.att-type-badge {
    font-size: 0.68rem; background: var(--muted-bg); color: var(--text-secondary);
    padding: 1px 6px; border-radius: 3px; font-weight: 600; letter-spacing: 0.05em;
}
.att-card-summary { font-size: 0.83rem; color: var(--text-secondary); margin: 0 0 0.5rem; line-height: 1.45; }
.att-card-btn {
    display: block; width: 100%; text-align: center; padding: 0.45rem 1rem;
    border-radius: 6px; font-size: 0.85rem; font-weight: 600;
    text-decoration: none; transition: all 0.15s; box-sizing: border-box;
}
.att-btn-local {
    background: var(--brand-primary); color: #fff; border: 2px solid var(--brand-primary);
}
.att-btn-local:hover { background: var(--brand-accent); border-color: var(--brand-accent); color: #fff; }
.att-btn-ext {
    background: var(--card-bg); color: var(--brand-primary); border: 2px solid var(--brand-primary);
}
.att-btn-ext:hover { background: var(--brand-light); }

/* ── Attachment match highlighting (document text search matches) ── */
.att-card-matched {
    border-color: #ca8a04;   /* amber-600 */
    background: #fef9c3;     /* yellow-100 — clearly visible match highlight */
}
.att-card-matched:hover { border-color: #a16207; box-shadow: 0 2px 8px rgba(202,138,4,0.2); }
.att-match-badge {
    display: inline-block; font-size: 0.68rem; font-weight: 700;
    background: #16a34a; color: #fff;
    padding: 1px 7px; border-radius: 10px; letter-spacing: 0.04em;
    white-space: nowrap; flex-shrink: 0;
}
.att-snippet {
    background: #fef08a; border-radius: 4px; padding: 4px 8px;
    font-size: 0.82rem; color: #713f12; margin: 0.35rem 0 0.5rem;
    line-height: 1.5; word-break: break-word;
    border-left: 3px solid #ca8a04;
}
.att-snippet mark {
    background: #fde047; color: #1a1a1a; padding: 0 2px; border-radius: 2px;
}

/* ── Detail meta row ── */
.detail-meta { font-size: 0.83rem; color: var(--text-secondary); margin: 0.4rem 0; }
.meta-key { font-weight: 600; color: var(--text-primary); }

/* ════════════════════════════════════════════
   SEARCH RESULTS TABLE SPECIAL RULES
═══════════════════════════════════════════ */
/* Zebra striping */
.search-results-table tbody tr.expandable-row:nth-child(4n+1) { background: var(--muted-bg); }

/* Sticky header */
.search-results-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--muted-bg);
    box-shadow: 0 1px 0 var(--border-strong);
}

/* ════════════════════════════════════════════
   SMART SEARCH / QUESTION GROUP
═══════════════════════════════════════════ */
.question-group-row {
    margin-top: 0.5rem;
}

/* ════════════════════════════════════════════
   SEARCH HINT TOOLTIP
═══════════════════════════════════════════ */
.search-hint {
    display: inline-flex; align-items: center; justify-content: center;
    width: 15px; height: 15px; border-radius: 50%;
    background: var(--brand-light); color: var(--brand-accent);
    font-size: 0.65rem; font-weight: 700; cursor: help;
    vertical-align: middle; margin-left: 3px;
    border: 1px solid var(--brand-accent);
}
.search-hint:hover { background: var(--brand-accent); color: #fff; }

/* ────────────────────────────────────────────
   Search Mode Tabs (Keyword / Natural Language)
──────────────────────────────────────────── */
.search-mode-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0;
}
.mode-tab {
    padding: 6px 14px;
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 6px 6px 0 0;
    background: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}
.mode-tab:hover  { color: var(--brand-accent); }
.mode-tab.active { color: var(--brand-accent); border-bottom-color: var(--brand-accent); background: var(--brand-light); }
.mode-tab-hint   { font-size: 0.76rem; color: var(--text-muted); margin-left: 8px; font-style: italic; }

/* NL input — wider, bigger font */
.nl-input { font-size: 1rem; }
.nl-hint   { font-size: 0.78rem; color: var(--text-muted); margin: 0.3rem 0 0.5rem; }

/* Generated SQL panel */
.sql-panel {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--brand-accent);
    border-radius: 0 6px 6px 0;
    margin: 0.75rem 0;
    padding: 0;
    overflow: hidden;
}
.sql-panel-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: #f0f4f8;
    user-select: none;
}
.sql-panel-summary:hover { background: var(--brand-light); }
.sql-mode-badge {
    background: var(--brand-accent);
    color: #fff;
    font-size: 0.68rem;
    padding: 1px 7px;
    border-radius: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.sql-error-badge {
    background: var(--color-warning-bg);
    color: var(--color-warning);
    font-size: 0.68rem;
    padding: 1px 7px;
    border-radius: 12px;
    font-weight: 600;
    border: 1px solid var(--color-warning);
}
.sql-code {
    margin: 0;
    padding: 10px 14px;
    font-size: 0.78rem;
    line-height: 1.55;
    overflow-x: auto;
    white-space: pre-wrap;
    color: var(--text-primary);
    background: transparent;
    border: none;
    border-top: 1px solid var(--border-color);
}
.sql-error-note {
    padding: 6px 14px 8px;
    font-size: 0.78rem;
    color: var(--color-warning);
    background: var(--color-warning-bg);
    border-top: 1px solid #fde68a;
}

/* Mode indicator in results count */
.mode-indicator { color: var(--text-muted); font-size: 0.83em; }

/* Aggregated SQL results table */
.sql-agg-table th { text-transform: capitalize; }
.sql-agg-table td { font-variant-numeric: tabular-nums; }

/* ── SQL Agent answer panel ── */
.cost-badge {
    display: inline-block;
    background: rgba(147,197,253,0.18);
    color: #93c5fd;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 0.5rem;
    letter-spacing: 0.02em;
    text-transform: none;
    vertical-align: middle;
    border: 1px solid rgba(147,197,253,0.25);
}
.sql-agent-queries {
    margin-top: 0.75rem;
    border-top: 1px solid rgba(147,197,253,0.15);
    padding-top: 0.5rem;
}
.sql-agent-queries summary {
    font-size: 0.78rem;
    font-weight: 600;
    color: #93c5fd;
    cursor: pointer;
    user-select: none;
    padding: 4px 0;
}
.sql-agent-queries summary:hover { color: #bae6fd; }
.sql-agent-query-block {
    background: rgba(0,0,0,0.18);
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    margin: 0.5rem 0;
}
.sql-agent-purpose {
    font-size: 0.8rem;
    font-weight: 600;
    color: #bae6fd;
    margin-bottom: 0.3rem;
}
.sql-agent-query-block .sql-code {
    background: rgba(0,0,0,0.2);
    border: none;
    border-radius: 4px;
    padding: 6px 10px;
    margin: 0.3rem 0;
    font-size: 0.75rem;
    color: #e2e8f0;
}
.sql-agent-row-count {
    font-size: 0.72rem;
    color: #7dd3fc;
    margin-top: 0.25rem;
}

/* ════════════════════════════════════════════
   ADMIN PAGES
═══════════════════════════════════════════ */
.admin-header {
    background: var(--brand-primary);
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.88rem;
}
.admin-header a { color: #93c5fd; }
.admin-stat {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 1.25rem;
    text-align: center;
}
.admin-stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--brand-primary);
}
.admin-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ════════════════════════════════════════════
   GROUPED SEARCH RESULT ROWS
═══════════════════════════════════════════ */

/* The summary-collapsed group header row */
.group-row {
    cursor: pointer;
    background: var(--brand-light);
    border-left: 3px solid var(--brand-accent);
}
.group-row:hover {
    background: #dbeafe !important;
}
.group-row.group-row-open {
    background: #dbeafe;
    border-bottom: none;
}

/* Summary cell inside the group header */
.group-summary {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.group-label {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--brand-primary);
}
.group-hint {
    font-size: 0.78rem;
    color: var(--brand-accent);
    font-style: italic;
}
.group-row-open .group-hint {
    visibility: hidden;
}

/* Docs badge variant for groups (totals across all sub-items) */
.docs-group {
    background: var(--brand-light);
    color: var(--brand-primary);
}

/* The hidden row that contains the expanded inner table */
.group-expand-row > td {
    padding: 0 !important;
    background: var(--muted-bg);
    border-left: 3px solid var(--brand-accent);
    border-bottom: 2px solid var(--border-strong);
}
.group-expand-td {
    padding: 0 !important;
}

/* Inner table that holds the individual sub-item rows */
.group-inner-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.93rem;
    background: var(--muted-bg);
}
.group-inner-table td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}
.group-inner-table .sub-row {
    cursor: pointer;
}
.group-inner-table .sub-row:hover {
    background: #eff6ff !important;
}
.group-inner-table .sub-row.expanded {
    background: #eff6ff;
}

/* Make sub-row expand-detail cells span the full inner table */
.group-inner-table .expand-detail td {
    background: var(--card-bg);
    padding: 0;
    border-bottom: 1px solid var(--border-color);
}
