/* DataHub - Matching Attribution Dashboard Style */
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

* { box-sizing: border-box; }

:root {
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --text-secondary: #475569;
    --muted: #64748b;
    --muted-light: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --accent-green: #22c55e;
    --accent-green-text: #16a34a;
    --accent-red: #ef4444;
    --accent-red-text: #dc2626;
    --accent-amber: #f59e0b;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

body {
    margin: 0;
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}

/* ============================================================================
   LAYOUT
   ============================================================================ */

.container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 8px 16px;
}

/* ============================================================================
   TOP NAVIGATION
   ============================================================================ */

.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding-bottom: 8px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 0;
}

.nav-logo {
    height: 32px;
    width: auto;
    margin-right: 12px;
}

.brand {
    font-family: 'Manrope', 'Inter', sans-serif;
    font-weight: 800;
    color: var(--text);
    text-decoration: none;
    font-size: 1.1rem;
    padding: 8px 16px 8px 0;
    margin-right: 8px;
    border-right: 1px solid var(--border);
}

.nav-link {
    color: var(--muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}

.nav-link:hover {
    color: var(--text);
    background: var(--border-light);
}

.nav-link.active {
    color: var(--primary);
    background: #eff6ff;
    font-weight: 600;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

#authUserEmail {
    font-size: 0.75rem;
    color: var(--muted);
    background: var(--border-light);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#authLogoutBtn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

#authLogoutBtn:hover {
    background: var(--border-light);
    border-color: var(--muted-light);
    color: var(--text-secondary);
}

/* ============================================================================
   PAGE HEADER
   ============================================================================ */

.page-header {
    margin-bottom: 10px;
}

.page-title {
    font-family: 'Manrope', 'Inter', sans-serif;
    margin: 0 0 2px 0;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.subtitle {
    margin: 0 0 8px 0;
    color: var(--muted);
    font-size: 0.9rem;
}

/* ============================================================================
   SUB NAVIGATION (TABS)
   ============================================================================ */

.sub-nav {
    display: flex;
    gap: 2px;
    margin-bottom: 10px;
    padding: 3px;
    background: var(--card);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    width: fit-content;
}

.sub-link {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--muted);
    text-decoration: none;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}

.sub-link:hover {
    color: var(--text);
    background: var(--border-light);
}

.sub-link.active {
    color: var(--card);
    background: var(--muted);
}

.tab-panel {
    display: none;
}

/* ============================================================================
   SECTIONS (CARDS)
   ============================================================================ */

.section {
    background: var(--card);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
    border-top: 2px solid var(--border);
}

.section.accent-primary {
    border-top-color: var(--primary);
}

.section.accent-green {
    border-top-color: var(--accent-green);
}

.section.accent-amber {
    border-top-color: var(--accent-amber);
}

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

.section-title {
    font-family: 'Manrope', 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0;
    color: var(--text);
}

.section-meta {
    color: var(--muted);
    font-size: 0.85rem;
}

/* ============================================================================
   STAT CARDS (Attribution Style)
   ============================================================================ */

.stats-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    min-width: 90px;
    box-shadow: var(--shadow-sm);
    border-top: 2px solid var(--border);
}

.stat-card.positive { border-top-color: var(--accent-green); }
.stat-card.negative { border-top-color: var(--accent-red); }
.stat-card.primary { border-top-color: var(--primary); }

.stat-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.stat-card.positive .stat-value { color: var(--accent-green-text); }
.stat-card.negative .stat-value { color: var(--accent-red-text); }

/* ============================================================================
   CONTROLS
   ============================================================================ */

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
    align-items: flex-end;
}

.control {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 120px;
}

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

.control.span-2 {
    grid-column: span 2;
}

label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 700;
}

/* ============================================================================
   FORM ELEMENTS
   ============================================================================ */

select,
input[type="date"],
input[type="text"],
input[type="number"],
textarea {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

select:focus,
input[type="date"]:focus,
input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

textarea {
    min-height: 60px;
    resize: vertical;
}

select[multiple] {
    min-height: 100px;
}

/* ============================================================================
   BUTTONS
   ============================================================================ */

button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: var(--radius-sm);
    padding: 7px 14px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--muted);
    transition: all 0.15s;
    font-family: inherit;
}

button:hover {
    background: var(--border-light);
    color: var(--text);
}

button.primary {
    background: var(--primary);
    color: var(--card);
    border-color: var(--primary);
}

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

button.danger {
    background: var(--accent-red);
    color: var(--card);
    border-color: var(--accent-red);
}

button.danger:hover {
    background: var(--accent-red-text);
    border-color: var(--accent-red-text);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Toggle Buttons (Attribution Style) */
.btn-group {
    display: flex;
    gap: 4px;
}

.toggle-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--muted);
    transition: all 0.15s;
}

.toggle-btn:hover {
    background: var(--border-light);
    color: var(--text);
}

.toggle-btn.active {
    background: var(--muted);
    color: var(--card);
    border-color: var(--muted);
}

/* ============================================================================
   TABLES
   ============================================================================ */

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

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

.table th {
    position: sticky;
    top: 0;
    background: var(--bg);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text);
    vertical-align: middle;
}

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

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

.table td a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.table td a:hover {
    text-decoration: underline;
}

.table input[type="checkbox"],
.table input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* Value styling */
.value-positive { color: var(--accent-green-text); font-weight: 600; }
.value-negative { color: var(--accent-red-text); font-weight: 600; }

/* ============================================================================
   PAGINATION
   ============================================================================ */

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

.pagination button {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.pagination span {
    color: var(--muted);
    font-size: 0.85rem;
}

/* ============================================================================
   NOTICES & ALERTS
   ============================================================================ */

.notice {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-left: 3px solid var(--primary);
    color: #1e40af;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.notice.warning {
    background: #fefce8;
    border-color: #fde047;
    border-left-color: var(--accent-amber);
    color: #854d0e;
}

.notice.error {
    background: #fef2f2;
    border-color: #fecaca;
    border-left-color: var(--accent-red);
    color: #991b1b;
}

.notice.success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    border-left-color: var(--accent-green);
    color: #166534;
}

/* ============================================================================
   EMPTY STATES
   ============================================================================ */

.empty {
    color: var(--muted);
    font-size: 0.9rem;
    padding: 8px 0;
}

/* ============================================================================
   INLINE OPTIONS (Checkboxes/Radios)
   ============================================================================ */

.inline-options {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.inline-options label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text);
    font-size: 0.8rem;
    cursor: pointer;
}

.inline-options input[type="checkbox"],
.inline-options input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* ============================================================================
   CODE BLOCKS
   ============================================================================ */

.code-block {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px;
    font-size: 0.75rem;
    font-family: 'Monaco', 'Menlo', monospace;
    white-space: pre-wrap;
    overflow: auto;
    max-height: 200px;
}

/* ============================================================================
   LINK BUTTON
   ============================================================================ */

.link-btn {
    border: none;
    background: none;
    color: var(--primary);
    cursor: pointer;
    font-weight: 600;
    padding: 0;
    font-size: 0.8rem;
}

.link-btn:hover {
    text-decoration: underline;
    background: none;
}

/* ============================================================================
   MULTI-SELECT DROPDOWN (Custom Component)
   ============================================================================ */

.multi-select-hidden {
    display: none;
}

.multi-select {
    position: relative;
    width: 100%;
}

.multi-select-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.multi-select-trigger:hover {
    background: var(--bg);
}

.multi-select-label {
    text-align: left;
    color: var(--text);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.multi-select-caret {
    color: var(--muted);
    font-size: 0.7rem;
    flex-shrink: 0;
}

.multi-select-dropdown {
    position: absolute;
    left: 0;
    min-width: 100%;
    width: max-content;
    max-width: 400px;
    margin-top: 2px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: 6px;
    z-index: 100;
    display: none;
}

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

.multi-select-search input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 0.9rem;
}

.multi-select-options {
    margin-top: 6px;
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px;
    background: var(--bg);
}

.multi-select-option {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    line-height: 1.4;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.1s;
}

.multi-select-option:hover {
    background: var(--border);
}

.multi-select-option input {
    margin: 0;
    margin-top: 2px;
    flex-shrink: 0;
}

.multi-select-option label,
.multi-select-option span {
    word-break: break-word;
}

.multi-select-option-locked {
    background: var(--border);
    cursor: not-allowed;
}

.multi-select-option-locked input {
    cursor: not-allowed;
}

.multi-select-empty {
    padding: 8px;
    color: var(--muted);
    font-size: 0.85rem;
    text-align: center;
}

.multi-select-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    margin-top: 8px;
}

.multi-select-actions button {
    padding: 5px 10px;
    font-size: 0.85rem;
}

/* ============================================================================
   INLINE INPUT (for tables)
   ============================================================================ */

.inline-input,
.inline-textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 5px 8px;
    font-size: 0.8rem;
    font-family: inherit;
    background: var(--bg);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.inline-textarea {
    min-height: 80px;
    resize: vertical;
}

.inline-input:focus,
.inline-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
    background: var(--card);
}

/* ============================================================================
   AUTH CARD (Light version for fallback)
   ============================================================================ */

.auth-card {
    max-width: 400px;
    margin: 60px auto 0;
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 32px;
    text-align: center;
    box-shadow: var(--shadow-md);
    border-top: 3px solid var(--primary);
}

.auth-card h1 {
    font-family: 'Manrope', 'Inter', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 8px 0;
}

.auth-card .subtitle {
    margin-bottom: 24px;
}

.auth-card button {
    width: 100%;
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */

.hidden {
    display: none !important;
}

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

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

.text-muted {
    color: var(--muted);
}

.font-mono {
    font-family: 'Monaco', 'Menlo', monospace;
}

.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }

/* ============================================================================
   SCROLLBAR
   ============================================================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--border-light);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--muted-light);
}

/* ============================================================================
   WIZARD / STEP-BY-STEP WORKFLOW
   ============================================================================ */

/* Collapsible search results container */
.search-results-container {
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg);
    padding: 8px;
    margin-top: 12px;
}

.search-results-container.collapsed {
    display: none;
}

/* Compact publisher result item */
.publisher-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--card);
    border: 1px solid var(--border);
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.publisher-item:last-child {
    margin-bottom: 0;
}

.publisher-item:hover {
    border-color: var(--primary);
    background: #f8faff;
}

.publisher-item.selected {
    border-color: var(--primary);
    background: #eff6ff;
}

.publisher-item input[type="radio"] {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.publisher-item-info {
    flex: 1;
    min-width: 0;
}

.publisher-item-name {
    font-weight: 600;
    color: var(--text);
    font-size: 0.85rem;
}

.publisher-item-meta {
    font-size: 0.7rem;
    color: var(--muted);
    margin-top: 2px;
}

.publisher-item-apps {
    flex-shrink: 0;
    background: var(--border-light);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Selected publisher summary (shown when collapsed) */
.selected-summary {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #eff6ff;
    border: 1px solid var(--primary);
    border-radius: var(--radius-md);
    margin-top: 12px;
}

.selected-summary.visible {
    display: flex;
}

.selected-summary .summary-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.selected-summary .summary-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

.selected-summary .summary-text {
    display: flex;
    flex-direction: column;
}

.selected-summary .summary-name {
    font-weight: 600;
    color: var(--text);
    font-size: 0.9rem;
}

.selected-summary .summary-meta {
    font-size: 0.75rem;
    color: var(--muted);
}

.selected-summary .change-btn {
    font-size: 0.75rem;
    padding: 4px 10px;
}

/* Apps Picker Component */
.apps-picker {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--card);
    overflow: hidden;
}

.apps-picker-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.apps-picker-search {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.85rem;
    padding: 4px 0;
    outline: none;
    color: var(--text);
}

.apps-picker-search::placeholder {
    color: var(--muted-light);
}

.apps-picker-actions {
    display: flex;
    gap: 6px;
}

.apps-picker-actions button {
    padding: 4px 8px;
    font-size: 0.7rem;
}

/* Selected tags area */
.apps-picker-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 12px;
    min-height: 44px;
    border-bottom: 1px solid var(--border);
    background: var(--card);
}

.apps-picker-tags:empty {
    display: none;
}

.apps-picker-tags:empty + .apps-picker-header {
    border-top: none;
}

.app-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: var(--primary);
    padding: 4px 8px 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    max-width: 200px;
}

.app-tag-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-tag-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--primary);
    cursor: pointer;
    padding: 0;
    font-size: 14px;
    line-height: 1;
    transition: background 0.1s;
}

.app-tag-remove:hover {
    background: #dbeafe;
}

/* Dropdown list */
.apps-picker-dropdown {
    max-height: 200px;
    overflow-y: auto;
    padding: 6px;
}

.apps-picker-empty {
    padding: 16px;
    text-align: center;
    color: var(--muted);
    font-size: 0.8rem;
}

/* App option in dropdown */
.app-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.1s;
}

.app-option:hover {
    background: var(--bg);
}

.app-option.selected {
    background: #eff6ff;
}

.app-option input[type="checkbox"] {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    pointer-events: none;
}

.app-option-name {
    flex: 1;
    font-size: 0.8rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-option-id {
    flex-shrink: 0;
    font-size: 0.65rem;
    color: var(--muted-light);
    font-family: 'Monaco', 'Menlo', monospace;
}

/* Legacy app item styles (keeping for compatibility) */
.apps-list-container {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg);
    padding: 8px;
}

.app-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    background: var(--card);
    margin-bottom: 4px;
    transition: background 0.1s;
}

.app-item:last-child {
    margin-bottom: 0;
}

.app-item:hover {
    background: var(--border-light);
}

.app-item input[type="checkbox"] {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.app-item-name {
    flex: 1;
    font-size: 0.8rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-item-id {
    flex-shrink: 0;
    font-size: 0.65rem;
    color: var(--muted-light);
    font-family: 'Monaco', 'Menlo', monospace;
    opacity: 0;
    transition: opacity 0.15s;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-item:hover .app-item-id {
    opacity: 1;
}

/* Step sections */
.step-section {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.2s;
}

.step-section.active {
    opacity: 1;
    pointer-events: auto;
}

/* ============================================================================
   CONFIG PANEL (Tracking Settings)
   ============================================================================ */

.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    align-items: start;
}

.config-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.config-group-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 700;
}

/* Toggle button group for granularities */
.toggle-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.toggle-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--card);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.toggle-chip:hover {
    border-color: var(--primary);
    color: var(--text);
}

.toggle-chip.active {
    background: #eff6ff;
    border-color: var(--primary);
    color: var(--primary);
}

.toggle-chip input {
    display: none;
}

/* Metric chips */
.metric-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.metric-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
    font-size: 0.85rem;
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.metric-chip:hover {
    border-color: var(--muted-light);
}

.metric-chip.active {
    background: #f0fdf4;
    border-color: var(--accent-green);
    color: var(--accent-green-text);
}

.metric-chip input {
    display: none;
}

.metric-chip-icon {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: transparent;
    transition: all 0.15s;
}

.metric-chip.active .metric-chip-icon {
    background: var(--accent-green);
    border-color: var(--accent-green);
    color: white;
}

/* Config action area */
.config-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

/* ============================================================================
   USAGE STATS
   ============================================================================ */

.usage-stats {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.usage-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.usage-stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 700;
}

.usage-stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
}

/* ============================================================================
   STATUS & PREVIEW
   ============================================================================ */

.status-message {
    margin-top: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--muted);
}

.status-message:empty {
    display: none;
}

.status-message.success {
    background: #f0fdf4;
    color: var(--accent-green-text);
    border: 1px solid var(--accent-green);
}

.status-message.error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.preview-container {
    margin-top: 10px;
}

.preview-container:empty {
    display: none;
}

/* ============================================================================
   BUTTON GROUP
   ============================================================================ */

.button-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

/* ============================================================================
   CHIPS (for tags/pills)
   ============================================================================ */

.chips-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
}

.chip.removable {
    padding-right: 6px;
}

.chip-label {
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    border: none;
    background: var(--border);
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    color: var(--text);
    transition: background 0.15s;
}

.chip-remove:hover {
    background: var(--danger);
    color: white;
}

/* ============================================================================
   FIELD VALUE (read-only display)
   ============================================================================ */

.field-value {
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    min-height: 38px;
}

/* ============================================================================
   CONFIRM BOX (for delete confirmations)
   ============================================================================ */

.confirm-box {
    padding: 16px;
    background: var(--card);
    border: 1px solid var(--danger);
    border-radius: var(--radius);
}

.confirm-box p {
    margin: 0 0 12px 0;
    font-weight: 500;
}

.confirm-box button {
    margin-right: 8px;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 900px) {
    .top-nav {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .nav-left {
        flex-wrap: wrap;
    }

    .nav-right {
        width: 100%;
        justify-content: flex-start;
    }

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

    .control {
        min-width: 100%;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 12px;
    }

    .section {
        padding: 12px;
    }

    .stats-row {
        flex-direction: column;
    }

    .stat-card {
        min-width: 100%;
    }
}

/* ============================================================================
   SCHEDULE CARDS (Jobs Page)
   ============================================================================ */

.schedule-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.schedule-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.schedule-card:hover {
    border-color: var(--muted-light);
    box-shadow: var(--shadow-sm);
}

.schedule-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg);
}

.schedule-source {
    display: flex;
    align-items: center;
    gap: 10px;
}

.schedule-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    font-family: 'Manrope', sans-serif;
}

.schedule-name {
    font-weight: 600;
    color: var(--text);
    font-size: 0.95rem;
}

.schedule-pattern {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 500;
    background: var(--border-light);
    padding: 4px 10px;
    border-radius: 20px;
}

.schedule-card-body {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
}

.schedule-next {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.schedule-label {
    font-size: 0.75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.schedule-time {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.schedule-countdown {
    display: flex;
    align-items: baseline;
    gap: 3px;
    font-family: 'Manrope', monospace;
}

.countdown-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    min-width: 28px;
    text-align: right;
}

.countdown-unit {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    margin-right: 6px;
}

.schedule-progress {
    height: 4px;
    background: var(--border-light);
}

.schedule-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, #60a5fa 100%);
    border-radius: 0 2px 2px 0;
    transition: width 0.5s ease-out;
}

.schedule-card[data-source="sensortower"] .schedule-progress-bar {
    background: linear-gradient(90deg, #8b5cf6 0%, #a78bfa 100%);
}

.schedule-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.schedule-refresh-btn {
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.schedule-refresh-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.schedule-refresh-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.schedule-status {
    padding: 0 16px;
    font-size: 0.8rem;
    color: var(--muted);
}

.schedule-status:empty {
    display: none;
}

.schedule-status.success {
    color: var(--accent-green-text);
}

.schedule-status.error {
    color: var(--accent-red-text);
}

.schedule-confirm {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg);
    border-top: 1px solid var(--border-light);
}

.schedule-confirm-btn {
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s;
}

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

.schedule-confirm-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.schedule-cancel-btn {
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.schedule-cancel-btn:hover {
    background: var(--border-light);
}

@media (max-width: 600px) {
    .schedule-cards {
        grid-template-columns: 1fr;
    }

    .schedule-card-body {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .schedule-countdown {
        align-self: flex-end;
    }
}
