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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f5f6f8;
    min-height: 100vh;
    padding: 0;
}

/* ============================================
   APP LAYOUT: SIDEBAR + MAIN CONTENT
   ============================================ */
#main-container {
    display: flex;
    min-height: 100vh;
}

/* Platform Sidebar */
.platform-sidebar {
    width: 72px;
    min-height: 100vh;
    background: #1e293b;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 0;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    align-self: flex-start;
}

.platform-sidebar-header {
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    display: flex;
    justify-content: center;
}

.platform-sidebar-logo {
    width: 36px;
    height: 36px;
}

.platform-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    width: 100%;
}

.platform-btn {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: 2px solid transparent;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
}

.platform-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.9);
}

.platform-btn.active {
    background: rgba(59, 130, 246, 0.25);
    border-color: #3b82f6;
    color: #fff;
}

.platform-btn img {
    width: 28px;
    height: 28px;
    border-radius: 4px;
}

.platform-btn .platform-btn-label {
    line-height: 1.1;
    text-align: center;
}

.platform-btn .platform-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.platform-btn[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: #1f2937;
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    transition-delay: 0s;
    z-index: 100;
}

.platform-btn[data-tooltip]:hover::after {
    opacity: 1;
    transition-delay: 0.5s;
}

.platform-btn .platform-btn-icon svg {
    width: 26px;
    height: 26px;
}

/* Main content area next to sidebar */
#main-container > .container {
    flex: 1;
    min-width: 0;
    padding: 20px 25px;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.login-container {
    background: white;
    padding: 40px 50px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.login-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
}

.login-container h1 {
    font-size: 1.5rem;
    color: #333;
    margin-bottom: 10px;
    text-align: center;
}

.login-subtitle {
    color: #666;
    font-size: 0.95rem;
    margin-bottom: 30px;
}

#google-signin-btn {
    display: flex;
    justify-content: center;
    margin-bottom: 15px;
}

.login-error {
    color: #dc3545;
    font-size: 0.9rem;
    margin-top: 15px;
    min-height: 20px;
}

/* User info in header */
.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

#user-name {
    font-size: 0.9rem;
    color: #333;
    font-weight: 500;
}

.btn-logout {
    background: #f8f9fa;
    color: #666;
    border: 1px solid #ddd;
    padding: 5px 12px;
    font-size: 0.8rem;
}

.btn-logout:hover {
    background: #e9ecef;
    color: #333;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 20px 25px;
}

/* Header with logo */
.header-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.header-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

h1 {
    color: #333;
    text-align: left;
    margin-bottom: 0;
    font-size: 1.5rem;
    font-weight: 500;
}

/* Loading and status messages */
.loading {
    text-align: center;
    color: #666;
    font-size: 1rem;
    padding: 40px;
}

.error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 15px;
    color: #dc2626;
    text-align: center;
    margin: 20px 0;
}

.no-data {
    text-align: center;
    color: #999;
    padding: 40px;
    font-size: 1rem;
    background: #f9f9f9;
    border-radius: 6px;
}

/* Navigation */
.main-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e5e7eb;
}

.nav-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    min-width: 0;
}

.nav-btn {
    padding: 10px 24px;
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-btn:hover {
    background: #e5e7eb;
}

.nav-btn.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

/* Safe Mode Toggle */
.safe-mode-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    position: relative;
    flex-shrink: 0;
}

.safe-mode-text {
    font-size: 0.82rem;
    font-weight: 500;
    color: #374151;
}

.safe-mode-label input[type="checkbox"] {
    display: none;
}

.safe-mode-slider {
    width: 36px;
    height: 20px;
    background: #d1d5db;
    border-radius: 10px;
    position: relative;
    transition: background 0.2s;
}

.safe-mode-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.safe-mode-label input:checked + .safe-mode-slider {
    background: #059669;
}

.safe-mode-label input:checked + .safe-mode-slider::after {
    transform: translateX(16px);
}

.safe-mode-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Page containers */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* ============================================
   LOOKER-STYLE FILTER PANEL
   ============================================ */
.filter-panel {
    background: #fafbfc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 20px;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-end;
    margin-bottom: 16px;
}

.filter-row:last-child {
    margin-bottom: 0;
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-item label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Filter buttons (like Looker's date range pills) */
.filter-buttons {
    display: flex;
    gap: 0;
}

.filter-btn {
    padding: 8px 16px;
    background: white;
    color: #374151;
    border: 1px solid #d1d5db;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
}

.filter-btn:first-child {
    border-radius: 6px 0 0 6px;
}

.filter-btn:last-child {
    border-radius: 0 6px 6px 0;
}

.filter-btn:not(:first-child) {
    border-left: none;
}

.filter-btn:hover {
    background: #f3f4f6;
}

.filter-btn.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.filter-btn.active + .filter-btn {
    border-left: 1px solid #d1d5db;
}

/* Toggle buttons (Yes/No) */
.toggle-group {
    display: flex;
    gap: 0;
}

.toggle-btn {
    padding: 8px 16px;
    background: white;
    color: #374151;
    border: 1px solid #d1d5db;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
    min-width: 50px;
}

.toggle-btn:first-child {
    border-radius: 6px 0 0 6px;
}

.toggle-btn:last-child {
    border-radius: 0 6px 6px 0;
    border-left: none;
}

.toggle-btn:hover {
    background: #f3f4f6;
}

.toggle-btn.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

/* Date range inputs */
.date-range {
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-range span {
    color: #6b7280;
    font-size: 0.85rem;
}

.filter-input-date {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.85rem;
    background: white;
    color: #374151;
}

.filter-input-date:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Select dropdown */
.filter-select {
    padding: 8px 32px 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.85rem;
    background: white url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e") right 8px center no-repeat;
    background-size: 16px;
    appearance: none;
    cursor: pointer;
    min-width: 150px;
    color: #374151;
}

.filter-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Text input */
.filter-input {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.85rem;
    background: white;
    min-width: 150px;
    color: #374151;
}

.filter-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.filter-input::placeholder {
    color: #9ca3af;
}

.filter-input-small {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.85rem;
    background: white;
    width: 100px;
    color: #374151;
}

.filter-input-small:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Filter action buttons */
.filter-actions {
    display: flex;
    gap: 10px;
    margin-left: auto;
}

.btn-apply {
    background: #3b82f6;
    color: white;
    padding: 8px 20px;
}

.btn-apply:hover {
    background: #2563eb;
}

.btn-clear {
    background: white;
    color: #374151;
    border: 1px solid #d1d5db;
    padding: 8px 20px;
}

.btn-clear:hover {
    background: #f3f4f6;
}

.btn-refresh {
    background: #f59e0b;
    color: white;
    padding: 8px 20px;
}

.btn-refresh:hover {
    background: #d97706;
}

/* Table header */
.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 0 5px;
}

.table-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #111827;
}

/* Collapse/Expand button */
.collapse-btn {
    width: 24px;
    height: 24px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: #f9fafb;
    color: #6b7280;
    font-size: 16px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.collapse-btn:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
    color: #374151;
}

/* Collapsible content */
.collapsible-content {
    transition: all 0.2s ease-out;
}

.table-section.collapsed .collapsible-content {
    display: none;
}

.table-section.collapsed .table-header {
    margin-bottom: 0;
}

.table-info {
    font-size: 0.85rem;
    color: #6b7280;
}

/* ============================================
   DATA TABLE
   ============================================ */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1400px;
}

thead {
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

th {
    padding: 12px 10px;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    position: relative;
    border-right: 1px solid #e5e7eb;
}

th:last-child {
    border-right: none;
}

th:hover {
    background: #f3f4f6;
}

th .sort-asc::after {
    content: ' \25B2';
    font-size: 0.65rem;
}

th .sort-desc::after {
    content: ' \25BC';
    font-size: 0.65rem;
}

td {
    padding: 10px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.85rem;
    color: #374151;
    border-right: 1px solid #f3f4f6;
}

td:last-child {
    border-right: none;
}

/* Cell ellipsis - truncates with CSS so column resize reveals text */
.cell-ellipsis {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Cell tooltip - positioned via JS to stay in viewport */
.cell-tooltip {
    position: fixed;
    z-index: 9999;
    background: #1f2937;
    color: #fff;
    font-size: 0.8rem;
    padding: 8px 12px;
    border-radius: 6px;
    white-space: pre-wrap;
    max-width: 450px;
    max-height: 300px;
    overflow-y: auto;
    word-break: break-all;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    line-height: 1.4;
}

tbody tr {
    transition: background-color 0.1s;
}

tbody tr:hover {
    background-color: #f9fafb;
}


/* Highlighted column (like ROAS 0 in the screenshot) */
td.highlight {
    background: #dbeafe;
}

/* Column filters in table */
.filter-row-table {
    background: #f9fafb !important;
}

.filter-row-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #e5e7eb;
}

.table-filter-input {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.8rem;
    background: white;
}

.table-filter-input:focus {
    outline: none;
    border-color: #3b82f6;
}

.filter-note {
    font-size: 0.7rem;
    color: #9ca3af;
    font-style: italic;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    padding: 8px 16px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
    font-weight: 500;
}

.btn:hover {
    background: #2563eb;
}

.btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

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

.btn-danger {
    background: #ef4444;
}

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

.btn-success {
    background: #10b981;
}

.btn-success:hover {
    background: #059669;
}

.btn-warning {
    background: #f59e0b;
    color: #fff;
}

.btn-warning:hover {
    background: #d97706;
}

/* Confirm-modal — used when a destructive/auto-apply action needs explicit acknowledgement.
   Replaces window.confirm() so the warning can't be suppressed by the browser. */
.confirm-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.confirm-modal {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    max-width: 480px;
    width: calc(100% - 32px);
    padding: 24px 28px;
    border-top: 6px solid #f59e0b;
}

.confirm-modal h3 {
    margin: 0 0 12px;
    font-size: 1.15rem;
    color: #92400e;
}

.confirm-modal p {
    margin: 0 0 16px;
    color: #1f2937;
    line-height: 1.45;
    white-space: pre-wrap;
}

.confirm-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding: 12px;
    background: #f9fafb;
    border-radius: 6px;
    flex-wrap: wrap;
}

.pagination-btn {
    padding: 6px 14px;
    background: white;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
}

.pagination-btn:hover:not(:disabled) {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.pagination-btn:disabled {
    background: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
}

.pagination-info {
    color: #6b7280;
    font-size: 0.85rem;
}

.page-size-selector {
    display: flex;
    align-items: center;
    gap: 6px;
}

.page-size-selector label {
    color: #6b7280;
    font-size: 0.85rem;
}

.page-size-selector select {
    padding: 5px 10px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    background: white;
}

/* ============================================
   RULES PAGE
   ============================================ */
.rules-section {
    margin-top: 10px;
}

.rule-builder {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 25px;
}

.rule-builder h3 {
    margin-bottom: 16px;
    color: #111827;
    font-size: 1rem;
    font-weight: 600;
}

.rule-form {
    display: grid;
    gap: 12px;
}

.rule-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.rule-row label {
    font-weight: 500;
    color: #374151;
    min-width: 100px;
    flex-shrink: 0;
    font-size: 0.9rem;
}

.rule-row span {
    flex-shrink: 0;
    white-space: nowrap;
}

.rule-row select,
.rule-row input {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
}

.rule-row select:focus,
.rule-row input:focus {
    outline: none;
    border-color: #3b82f6;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 400 !important;
    min-width: auto !important;
    cursor: pointer;
    font-size: 0.85rem;
    color: #4b5563;
}

/* Max change "up / same for decrease / down" controls sit on one line. */
#rule-max-change-pct-custom,
#rule-max-change-pct-down-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.rule-input-wide {
    flex: 1;
    min-width: 200px;
}

.rule-input-small {
    width: 100px;
}

.rule-select {
    flex: 1;
    min-width: 250px;
    max-width: 400px;
}

.rule-condition-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 8px 0;
}

.rule-condition-row label {
    font-weight: 500;
    color: #374151;
    font-size: 0.9rem;
    min-width: 30px;
}

.rule-condition-row select,
.rule-condition-row input {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
}

.rule-condition-row select:focus,
.rule-condition-row input:focus {
    outline: none;
    border-color: #3b82f6;
}

.remove-condition-btn {
    padding: 4px 8px !important;
    font-size: 0.8rem !important;
    line-height: 1 !important;
}

/* Multi-select dropdown */
.multi-select-wrapper {
    position: relative;
    flex: 1;
    min-width: 250px;
    max-width: 400px;
}

.multi-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
    min-height: 38px;
    user-select: none;
}

.multi-select-trigger:hover {
    border-color: #9ca3af;
}

.multi-select-trigger.open {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.multi-select-trigger .ms-display {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #374151;
}

.multi-select-trigger .ms-display.placeholder {
    color: #9ca3af;
}

.multi-select-trigger .ms-arrow {
    margin-left: 8px;
    font-size: 0.7rem;
    color: #6b7280;
    transition: transform 0.15s;
}

.multi-select-trigger.open .ms-arrow {
    transform: rotate(180deg);
}

.multi-select-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    z-index: 200;
    max-height: 260px;
    overflow-y: auto;
}

.multi-select-dropdown.open {
    display: block;
}

.multi-select-dropdown .ms-search {
    position: sticky;
    top: 0;
    background: white;
    padding: 8px;
    border-bottom: 1px solid #e5e7eb;
}

.multi-select-dropdown .ms-search input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.85rem;
    outline: none;
}

.multi-select-dropdown .ms-search input:focus {
    border-color: #3b82f6;
}

.multi-select-dropdown .ms-options {
    padding: 4px 0;
}

.multi-select-dropdown .ms-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #374151;
    transition: background 0.1s;
}

.multi-select-dropdown .ms-option:hover {
    background: #f3f4f6;
}

.multi-select-dropdown .ms-option input[type="checkbox"] {
    width: 15px;
    height: 15px;
    cursor: pointer;
    flex-shrink: 0;
}

.multi-select-dropdown .ms-option.hidden {
    display: none;
}

.multi-select-dropdown .ms-actions {
    display: flex;
    justify-content: space-between;
    padding: 6px 10px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    position: sticky;
    bottom: 0;
}

.multi-select-dropdown .ms-actions button {
    padding: 4px 10px;
    font-size: 0.78rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: #3b82f6;
    background: transparent;
    font-weight: 500;
}

.multi-select-dropdown .ms-actions button:hover {
    background: #eff6ff;
}

/* Weekday multi-select (compact) */
.weekday-multi-select {
    display: flex;
    gap: 0;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    overflow: hidden;
}

.weekday-multi-select .wd-option {
    padding: 7px 10px;
    background: white;
    color: #374151;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.15s;
    font-weight: 500;
    user-select: none;
    border-right: 1px solid #d1d5db;
    text-align: center;
    min-width: 40px;
}

.weekday-multi-select .wd-option:last-child {
    border-right: none;
}

.weekday-multi-select .wd-option:hover {
    background: #f3f4f6;
}

.weekday-multi-select .wd-option.selected {
    background: #3b82f6;
    color: white;
}

#rule-conditions-container {
    border-left: 3px solid #3b82f6;
    padding-left: 12px;
    margin: 4px 0;
}

.logic-hint {
    font-size: 0.8rem;
    color: #6b7280;
}

.condition-preview {
    background: #3b82f6;
    color: white;
    padding: 12px 16px;
    border-radius: 6px;
    margin-top: 8px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.rule-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

/* Rules List */
.rules-list {
    margin-top: 20px;
}

.rules-list h3 {
    margin-bottom: 16px;
    color: #111827;
    font-size: 1rem;
    font-weight: 600;
}

.rule-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.15s;
}

.rule-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

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

.rule-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #111827;
}

.rule-card-status {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.rule-card-status.enabled {
    background: #d1fae5;
    color: #065f46;
}

.rule-card-status.disabled {
    background: #fee2e2;
    color: #991b1b;
}

.auto-apply-badge {
    display: inline-block;
    padding: 2px 8px;
    margin-left: 6px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    background: #fef3c7;
    color: #92400e;
    vertical-align: middle;
}

.rule-card-description {
    color: #6b7280;
    font-size: 0.85rem;
    margin-bottom: 12px;
    padding: 10px;
    background: #f9fafb;
    border-radius: 4px;
    line-height: 1.4;
}

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

.no-rules {
    text-align: center;
    color: #9ca3af;
    padding: 30px;
    font-size: 0.95rem;
    background: #f9fafb;
    border-radius: 6px;
}

/* Rules Table */
.rules-table-wrapper {
    overflow-x: auto;
}

.rules-table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
}

.rules-table th {
    white-space: nowrap;
    cursor: default;
}

.rules-table-name {
    font-weight: 600;
    white-space: nowrap;
}

.rules-table-scope {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rules-table-conditions {
    font-size: 0.8rem;
    line-height: 1.5;
    white-space: nowrap;
}

.rules-table-action {
    white-space: nowrap;
    font-weight: 600;
}

.rules-table-date {
    white-space: nowrap;
    font-size: 0.8rem;
    color: #6b7280;
}

.rules-table-actions {
    white-space: nowrap;
    display: flex;
    gap: 6px;
}

/* Rules table row hover & selected */
.rules-table tbody tr:hover {
    background: #f3f4f6;
}

.rules-table tbody tr.selected-rule {
    background: #dbeafe;
}

.rules-table tbody tr.selected-rule:hover {
    background: #bfdbfe;
}

/* Read-only rule form */
.rule-form.read-only input,
.rule-form.read-only select {
    background: #f3f4f6;
    color: #6b7280;
    cursor: default;
}

/* Multi-select: show full names with wrapping */
.multi-select-trigger .ms-display {
    white-space: normal;
    line-height: 1.4;
}

.rule-form.read-only .rule-condition-row .remove-condition-btn {
    display: none !important;
}

.rule-form.read-only .wd-option {
    opacity: 0.6;
}

/* ============================================
   RUN RULES SECTION
   ============================================ */
.run-rules-section {
    margin-top: 30px;
    padding-top: 25px;
    border-top: 1px solid #e5e7eb;
}

.run-rules-section h3 {
    margin-bottom: 16px;
    color: #111827;
    font-size: 1rem;
    font-weight: 600;
}

.run-rules-form {
    background: #f9fafb;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.run-rules-form .rule-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.evaluation-results {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
}

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

.evaluation-header h4 {
    margin: 0;
    font-size: 1rem;
    color: #111827;
}

#evaluation-summary {
    color: #6b7280;
    font-size: 0.9rem;
}

.evaluation-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.evaluation-filter select {
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #374151;
    background: white;
    cursor: pointer;
}

.evaluation-table-info {
    font-size: 0.8rem;
    color: #6b7280;
    margin-bottom: 6px;
}

.evaluation-table .sortable-th {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

/* Filter row */
.evaluation-table .eval-filter-row td {
    padding: 4px 6px;
    background: #f9fafb;
    border-bottom: 2px solid #e5e7eb;
}

.evaluation-table .filter-cell input {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.78rem;
    color: #374151;
    background: white;
    outline: none;
    box-sizing: border-box;
}

.evaluation-table .filter-cell input:focus {
    border-color: #3b82f6;
}

.filter-range-wrap {
    display: flex;
    gap: 2px;
}

.filter-range-wrap input {
    width: 50%;
    min-width: 0;
}

.col-filter-text {
    min-width: 60px;
}

.col-filter-num {
    min-width: 40px;
    /* Hide number input spinners */
    -moz-appearance: textfield;
}

.col-filter-num::-webkit-outer-spin-button,
.col-filter-num::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.column-toggle-wrapper {
    position: relative;
}

.column-toggle-btn {
    font-size: 0.85rem;
}

.column-toggle-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 8px 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 100;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.col-toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: #374151;
    cursor: pointer;
    white-space: nowrap;
}

.col-toggle-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-yes {
    background: #d1fae5;
    color: #065f46;
}

.badge-no {
    background: #f3f4f6;
    color: #6b7280;
}

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

.row-cooldown-warning {
    background-color: #fffbeb;
}

.row-warning {
    background-color: #fff3f3;
}

.row-warning .warning-text {
    color: #b91c1c;
    font-style: italic;
    font-size: 0.9em;
}

.row-data-warning {
    background-color: #fffbeb;
}

.row-no-bq-data {
    background-color: #fffbeb;
    color: #9ca3af;
}

.warning-icon {
    cursor: help;
    font-size: 0.85em;
    margin-left: 4px;
}

.run-rules-separator {
    color: #6b7280;
    font-style: italic;
    margin: 0 8px;
}

.run-rules-controls {
    margin-bottom: 16px;
}

.progress-section {
    padding: 30px 20px;
    text-align: center;
}

.progress-container {
    width: 100%;
    max-width: 500px;
    height: 12px;
    background: #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
    margin: 0 auto 10px auto;
}

.progress-bar {
    height: 100%;
    background: #3b82f6;
    border-radius: 6px;
    transition: width 0.4s ease;
}

.progress-label {
    color: #6b7280;
    font-size: 0.875rem;
}

.evaluation-table {
    width: 100%;
    margin-bottom: 16px;
}

.evaluation-table th,
.evaluation-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.evaluation-table th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
    font-size: 0.85rem;
}

.evaluation-table td {
    font-size: 0.9rem;
    color: #374151;
}

.evaluation-table tr:hover {
    background: #f9fafb;
}

.evaluation-table input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.bid-increase {
    color: #059669;
    font-weight: 600;
}

.bid-decrease {
    color: #dc2626;
    font-weight: 600;
}

.evaluation-actions {
    display: flex;
    gap: 10px;
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
}

.no-results {
    text-align: center;
    color: #9ca3af;
    padding: 30px;
    font-size: 0.95rem;
}

/* ============================================
   KEYWORDS TABLE SECTION
   ============================================ */
.table-section {
    margin-top: 30px;
}

.keywords-section {
    border-top: 1px solid #e5e7eb;
    padding-top: 25px;
}

.keywords-section .table-header h2 {
    color: #374151;
}

/* Empty value indicator (null/empty strings) */
.empty-value {
    color: #9ca3af;
    font-style: italic;
}

/* Status badges for bid log */
.status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

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

.status-badge.failed {
    background: #fee2e2;
    color: #991b1b;
}

.success-cell {
    background: #f0fdf4;
}

.error-cell {
    background: #fef2f2;
}

/* Bid Log Section */
.bidlog-section {
    margin-top: 20px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1200px) {
    .filter-row {
        gap: 15px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .filter-panel {
        padding: 12px 15px;
    }

    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-item {
        width: 100%;
    }

    .filter-actions {
        margin-left: 0;
        width: 100%;
        justify-content: flex-end;
    }

    .filter-buttons {
        flex-wrap: wrap;
    }

    .rule-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .rule-row label {
        min-width: auto;
    }

    .rule-row select,
    .rule-row input {
        width: 100%;
    }

    .rule-input-wide,
    .rule-input-small {
        width: 100% !important;
    }
}

/* ROAS color coding */
.positive-roas {
    color: #16a34a;
    font-weight: 600;
}

.neutral-roas {
    color: #ca8a04;
    font-weight: 500;
}

.negative-roas {
    color: #dc2626;
    font-weight: 500;
}

/* ============================================
   BID ACTIONS PAGE
   ============================================ */
.bid-actions-section {
    display: grid;
    gap: 24px;
    margin-top: 10px;
}

.action-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
}

.action-card h3 {
    margin-bottom: 8px;
    color: #111827;
    font-size: 1rem;
    font-weight: 600;
}

.action-card > p {
    color: #6b7280;
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.action-card .btn-primary {
    background: #3b82f6;
    color: white;
}

.action-card .btn-primary:hover {
    background: #2563eb;
}

.action-result {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
}

.action-result:empty {
    display: none;
}

.action-result.success {
    background: #d1fae5;
    border: 1px solid #a7f3d0;
}

.action-result.error {
    background: #fee2e2;
    border: 1px solid #fecaca;
}

.action-result .success-message {
    color: #065f46;
}

.action-result .error-message {
    color: #991b1b;
}

.action-result .loading {
    color: #6b7280;
    padding: 0;
}

.action-result pre {
    margin-top: 10px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    overflow-x: auto;
    font-size: 0.8rem;
}

/* Bid Form */
.bid-form {
    display: grid;
    gap: 14px;
}

.bid-form .form-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bid-form .form-row label {
    min-width: 160px;
    font-weight: 500;
    color: #374151;
    font-size: 0.9rem;
}

.bid-form .form-input {
    flex: 1;
    max-width: 300px;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
}

.bid-form .form-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.bid-form .form-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.bid-form input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin-right: 8px;
    cursor: pointer;
}

/* Field with toggle (ID/Name) */
.field-with-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.field-with-toggle > label {
    min-width: 100px;
    font-weight: 500;
    color: #374151;
    font-size: 0.9rem;
}

.input-toggle-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.toggle-switch {
    display: flex;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
}

.toggle-option {
    padding: 6px 12px;
    background: white;
    color: #6b7280;
    border: none;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
    font-weight: 500;
}

.toggle-option:first-child {
    border-right: 1px solid #d1d5db;
}

.toggle-option:hover {
    background: #f3f4f6;
}

.toggle-option.active {
    background: #3b82f6;
    color: white;
}

.resolved-id {
    font-size: 0.85rem;
    white-space: nowrap;
}

.lookup-loading {
    color: #6b7280;
    font-style: italic;
}

.lookup-success {
    color: #059669;
    font-weight: 500;
}

.lookup-error {
    color: #dc2626;
    font-size: 0.8rem;
}

/* Bid form header with refresh button */
.bid-form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.bid-form-header p {
    margin: 0;
    color: #6b7280;
}

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

.btn-secondary {
    background: #e5e7eb;
    color: #374151;
}

.btn-secondary:hover {
    background: #d1d5db;
}

/* Dropdown select styling */
.bid-form select.form-input {
    cursor: pointer;
    appearance: auto;
}

/* Performance Graph Page */
.perf-chart-section {
    position: relative;
    margin-top: 20px;
}

.perf-chart-container {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    height: 500px;
}

.perf-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #6b7280;
    font-size: 0.9rem;
}

.perf-empty {
    text-align: center;
    color: #9ca3af;
    padding: 80px 0;
    font-size: 0.95rem;
}

.perf-metric-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.perf-metric-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    color: #374151;
    cursor: pointer;
}

.perf-metric-toggle input[type="checkbox"] {
    cursor: pointer;
}

#perf-campaign,
#perf-keyword {
    min-width: 220px;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #374151;
    background: white;
}


