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

:root {
    --bg: #f8f9fb;
    --surface: #ffffff;
    --border: #e5e7eb;
    --border-light: #f0f1f3;
    --text: #1a1d26;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --primary-text: #3730a3;
    --success: #059669;
    --success-light: #ecfdf5;
    --warning: #d97706;
    --warning-light: #fffbeb;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
    --sidebar-width: 220px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

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

/* === Layout === */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--text);
    color: white;
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: width 0.2s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 16px;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.01em;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand-switcher { position: relative; }
.brand-current {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
}
.brand-current:hover { opacity: 0.85; }
.brand-current svg { opacity: 0.5; }
.brand-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: -10px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    min-width: 180px;
    z-index: 1000;
    overflow: hidden;
}
.brand-dropdown.open { display: block; }
.brand-option {
    display: block;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    text-decoration: none;
    transition: background 0.1s;
}
.brand-option:hover { background: #f3f4f6; }
.brand-option.active {
    background: #eff6ff;
    color: #1e40af;
    font-weight: 600;
}

.brand-icon {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.02em;
}

.sidebar-nav {
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 6px;
    color: rgba(255,255,255,0.6);
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.15s;
    text-decoration: none;
}

.nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.9);
}

.nav-item.active {
    background: rgba(255,255,255,0.12);
    color: white;
}

.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.2s ease;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 32px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar h1 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.content {
    padding: 24px 32px;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    background: var(--surface);
    color: var(--text);
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover { background: var(--bg); border-color: #d1d5db; }

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

.btn-danger {
    background: var(--surface);
    color: var(--danger);
    border-color: var(--border);
}
.btn-danger:hover {
    background: var(--danger-light);
    border-color: var(--danger);
}

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-xs { padding: 2px 6px; font-size: 11px; border-radius: 4px; }

.btn-ghost {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 6px 10px;
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

/* === Forms === */
input[type="text"],
input[type="date"],
select {
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.15s;
    outline: none;
}

input[type="text"]:focus,
input[type="date"]:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

input[type="text"]::placeholder { color: var(--text-muted); }

.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 13px;
    color: var(--text-secondary);
}
.form-group input, .form-group select { width: 100%; }
.form-actions { display: flex; gap: 8px; padding-top: 4px; }

.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

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

/* Meeting cards — collapsible via <details> */
details.meeting-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
    overflow: clip;
    overflow-x: visible;
}

details.meeting-card > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}
details.meeting-card > summary::-webkit-details-marker { display: none; }

details.meeting-card > summary .meeting-toggle {
    display: inline-block;
    font-size: 18px;
    color: var(--text-muted);
    transition: transform 0.15s;
    width: 16px;
    text-align: center;
}

details.meeting-card[open] > summary .meeting-toggle {
    transform: rotate(90deg);
}

details.meeting-card[open] > summary {
    border-bottom: 1px solid var(--border-light);
}

/* Static meeting cards (cancelled, non-collapsible) */
.meeting-card-static {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
    overflow: hidden;
}
.meeting-card-static.cancelled { opacity: 0.5; }

.meeting-header-static {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: var(--bg);
}

.meeting-header-static h2 {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
}

.meeting-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: var(--bg);
}

.meeting-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.meeting-header h2 {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
}

.meeting-time {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.meeting-title-link {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: var(--text-muted);
    text-underline-offset: 2px;
}
.meeting-title-link:hover {
    color: var(--primary);
    text-decoration-color: var(--primary);
}

.meeting-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.item-count {
    font-weight: 500;
    color: var(--text-secondary);
}

.agenda-link {
    text-decoration: none;
    font-size: 14px;
    opacity: 0.5;
    transition: opacity 0.15s;
}
.agenda-link:hover {
    opacity: 1;
}

/* === Badges === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.01em;
    background: var(--primary-light);
    color: var(--primary-text);
}

.badge-flags {
    background: var(--warning-light);
    color: var(--warning);
}

.badge-cancelled {
    background: var(--danger-light);
    color: var(--danger);
}

.badge-amended {
    background: #fef3c7;
    color: #92400e;
}

.badge-request {
    background: #e0e7ff;
    color: #3730a3;
}

.action-updated {
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.previous-action {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}

/* === Tables === */
.items-table, .tracking-table {
    width: 100%;
    border-collapse: collapse;
}

.items-table th, .tracking-table th {
    text-align: left;
    padding: 8px 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.items-table td, .tracking-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: top;
    font-size: 13px;
}

.items-table tbody tr, .tracking-table tbody tr {
    transition: background 0.1s;
}

.items-table tbody tr:hover, .tracking-table tbody tr:hover {
    background: var(--bg);
}

.items-table tbody tr:last-child td, .tracking-table tbody tr:last-child td {
    border-bottom: none;
}

tr.matched {
    background: var(--success-light) !important;
    border-left: 3px solid var(--success);
}
tr.matched:hover { background: #d1fae5 !important; }

tr.ai-match {
    background: var(--warning-light) !important;
    border-left: 3px solid var(--warning);
}
tr.ai-match:hover { background: #fef3c7 !important; }

/* === Description === */
.description-text {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: pre-line;
    line-height: 1.65;
}

.committee-tag {
    display: inline-block;
    margin-top: 6px;
    padding: 1px 6px;
    background: #dbeafe;
    color: #1d4ed8;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

/* === Flags === */
.flag-tag {
    padding: 3px 0;
    font-size: 12.5px;
    line-height: 1.4;
}

.flag-tag strong {
    color: var(--primary-text);
    font-weight: 600;
}

.flag-source {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    vertical-align: middle;
    margin-left: 4px;
}

.flag-manual {
    background: var(--success-light);
    color: var(--success);
}

.flag-ai {
    background: var(--warning-light);
    color: var(--warning);
}

/* === Council File Links === */
.council-file-link {
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* === Flagged Indicator === */
.flagged-indicator {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    background: var(--success-light);
    color: var(--success);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

/* === Flag Action Buttons === */
.flag-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.flag-action-row {
    display: flex;
    align-items: center;
    gap: 4px;
}
.flag-action-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-right: 2px;
}

.btn-confirm {
    background: var(--success-light);
    color: var(--success);
    border-color: #a7f3d0;
}
.btn-confirm:hover {
    background: #d1fae5;
    border-color: var(--success);
}

.btn-dismiss {
    background: var(--surface);
    color: var(--text-muted);
    border-color: var(--border);
}
.btn-dismiss:hover {
    background: var(--danger-light);
    color: var(--danger);
    border-color: var(--danger);
}

.btn-remove {
    background: var(--surface);
    color: var(--text-muted);
    border-color: var(--border);
}
.btn-remove:hover {
    background: var(--danger-light);
    color: var(--danger);
    border-color: var(--danger);
}

/* === Tracking Page Delete Button === */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 4px;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    transition: all 0.15s;
}

.btn-delete-flag:hover {
    background: var(--danger-light);
    color: var(--danger);
}

.tracking-client-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 2px;
}

.client-tag {
    display: inline-block;
    padding: 2px 8px;
    background: var(--primary-light);
    color: var(--primary-text);
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    margin: 2px 0;
}

/* === Date Headers === */
.date-header {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin: 32px 0 14px;
    padding: 10px 0;
    border-bottom: 2px solid var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.date-header:first-of-type { margin-top: 4px; }

/* === Dashboard Header (legacy) === */
.dashboard-header { margin-bottom: 24px; }
.dashboard-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.date-nav {
    display: flex;
    align-items: center;
    gap: 2px;
}

.date-nav-form { display: contents; }

.date-nav-arrow {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    line-height: 1;
}

.date-nav-arrow:hover {
    background: var(--bg);
    color: var(--text);
    border-color: #d1d5db;
}

.date-nav-label {
    padding: 0 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

.action-buttons { display: flex; gap: 8px; }

/* === Page Header === */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.filter-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* === Search Bar === */
.search-bar {
    position: relative;
    margin-bottom: 20px;
}

.search-bar input {
    width: 100%;
    padding: 10px 14px 10px 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.search-bar input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

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

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* === Tracking Filters === */
.tracking-filters {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
}

.tracking-filters select {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 13px;
    color: var(--text);
    background: var(--surface);
    min-width: 160px;
    outline: none;
    transition: border-color 0.15s;
    cursor: pointer;
}

.tracking-filters select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

.result-count {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* === No Items / Empty === */
.no-items {
    color: var(--text-muted);
    font-style: italic;
    padding: 16px 20px;
    font-size: 13px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state p { font-size: 14px; }

/* === Cancelled Section === */
.cancelled-section { margin-top: 20px; }
.cancelled-section summary {
    cursor: pointer;
    font-size: 13px;
    color: var(--text-muted);
    padding: 8px 0;
    font-weight: 500;
}
.cancelled-section .meeting-card { opacity: 0.5; }

/* === Client Topics === */
.client-card h2 { font-size: 14px; font-weight: 600; }

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

.topic-count {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.topic-input-row {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
}

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

.lead-badge {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 13px;
}

.topics-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.topic-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 3px 8px;
    border-radius: 6px;
}

.topic-keyword { font-size: 12.5px; font-weight: 500; }
.add-topic-form { margin-top: 8px; }

/* === Modal === */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.modal-content h3 {
    margin-bottom: 20px;
    font-size: 16px;
    font-weight: 600;
}

/* === Flash Messages === */
.flash-messages { margin-bottom: 16px; }

.flash {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
}

.flash-success {
    background: var(--success-light);
    color: var(--success);
    border-color: #a7f3d0;
}
.flash-error {
    background: var(--danger-light);
    color: var(--danger);
    border-color: #fecaca;
}
.flash-info {
    background: var(--primary-light);
    color: var(--primary-text);
    border-color: #c7d2fe;
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }


/* === Collapsible Sidebar === */
.sidebar-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: auto 12px 16px 12px;
    padding: 8px;
    background: none;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    transition: all 0.2s;
}
.sidebar-collapse-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}
.sidebar-collapsed .sidebar {
    width: 60px;
}
.sidebar-collapsed .sidebar .brand-switcher {
    display: none;
}
.sidebar-collapsed .sidebar .sidebar-brand {
    justify-content: center;
    padding: 16px 0;
}
.sidebar-collapsed .sidebar .brand-icon {
    margin: 0;
}
.sidebar-collapsed .sidebar .nav-item {
    font-size: 0;
    justify-content: center;
    padding: 12px 0;
}
.sidebar-collapsed .sidebar .nav-item svg {
    margin: 0;
    font-size: initial;
}
.sidebar-collapsed .sidebar-collapse-btn svg {
    transform: rotate(180deg);
}
.sidebar-collapsed .main-wrapper {
    margin-left: 60px;
}

/* === Table Scroll === */
.table-scroll-wrapper {
    position: relative;
}
.table-scroll-top {
    overflow-x: auto;
    overflow-y: hidden;
    position: sticky;
    top: 112px;
    z-index: 11;
    background: var(--surface, #fff);
    border-bottom: 1px solid var(--border, #e5e7eb);
}
.table-scroll-top-inner {
    height: 1px;
}

.table-scroll-top::-webkit-scrollbar {
    height: 8px;
}
.table-scroll-top::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 7px;
}
.table-scroll-top::-webkit-scrollbar-thumb {
    background: #b0b0b0;
    border-radius: 7px;
    border: 1px solid #f1f1f1;
}
.table-scroll-top::-webkit-scrollbar-thumb:hover {
    background: #888;
}
.table-scroll-top {
    scrollbar-width: auto;
}

.table-scroll {
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.table-scroll thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--surface, #fff);
}
.table-scroll thead th {
    background: var(--surface, #fff);
}
