/* ============================================
   Direct Line Dashboard - Design System
   Light theme, deep red accent (#c0392b)
   ============================================ */

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

:root {
    --primary: #c0392b;
    --primary-dark: #a93226;
    --primary-light: #e74c3c;
    --primary-bg: rgba(192, 57, 43, 0.06);
    --primary-border: rgba(192, 57, 43, 0.2);

    --bg: #f5f5f5;
    --bg-white: #ffffff;
    --bg-stripe: #f9f9f9;
    --bg-hover: #f0f0f0;

    --text: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --text-white: #ffffff;

    --border: #e0e0e0;
    --border-light: #eeeeee;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
    --shadow-xl: 0 8px 32px rgba(0,0,0,0.15);

    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

    --transition: 0.2s ease;
    --header-h: 100px;

    --green: #2e7d32;
    --green-light: #388e3c;
    --green-dark: #1b5e20;
    --green-bg: #e8f5e9;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

a:hover {
    color: var(--primary-dark);
}

/* === Header === */
.header {
    background: var(--bg-white);
    box-shadow: var(--shadow-sm);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    border-bottom: 2px solid var(--primary);
}
.main-content { padding-top: var(--header-h); }

.header-inner {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 28px;
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-weight: 800;
    font-size: 20px;
    color: var(--text);
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: color var(--transition);
}

.logo:has(img)::before { display: none; }
.logo::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 28px;
    background: var(--primary);
    border-radius: 2px;
}

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

.brand {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    writing-mode: sideways-lr;
    height: 100%;
}
.brand .logo-img { writing-mode: horizontal-tb; }
.header-inner { position: relative; }
.brand-tagline {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.2px;
    padding-left: 10px;
    border-left: 2px solid var(--primary);
    line-height: 1.2;
    white-space: nowrap;
}
@media (max-width: 640px) {
    .brand-tagline { display: none; }
}

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

.nav-links { display: flex; gap: 4px; align-items: center; }

.nav-link {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.nav-link:hover { color: var(--primary); background: var(--primary-bg); }
.nav-link.active { color: var(--primary); background: var(--primary-bg); font-weight: 600; }
.nav-link--logout { color: var(--text-muted); margin-left: 8px; }
.nav-link--logout:hover { color: var(--primary); background: var(--primary-bg); }

/* === Main Content === */
.main-content { min-height: calc(100vh - var(--header-h)); }

.container { max-width: 1440px; margin: 0 auto; padding: 28px; }

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

.page-header h1 { font-size: 26px; font-weight: 700; color: var(--text); letter-spacing: -0.3px; }
.subtitle { color: var(--text-muted); font-size: 13px; margin-top: 2px; display: block; }

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

/* === Buttons === */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 18px; font-size: 13px; font-weight: 600;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg-white); color: var(--text-secondary);
    cursor: pointer; transition: all var(--transition);
    white-space: nowrap; font-family: var(--font); line-height: 1.4; text-decoration: none;
}
.btn:hover { background: var(--bg-hover); border-color: #ccc; color: var(--text); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: var(--text-white); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: var(--text-white); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text-secondary); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }
.btn-secondary { background: var(--bg-white); border: 1.5px dashed var(--border); color: var(--text-secondary); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); border-style: solid; }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-full { width: 100%; }
.btn-icon { padding: 6px 10px; font-size: 14px; min-width: 32px; }

.btn-sync { position: relative; overflow: hidden; }
.btn-sync.loading { pointer-events: none; opacity: 0.7; }
.btn-sync.loading::after {
    content: ''; position: absolute; top: 0; left: -100%; width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 1.5s infinite;
}
@keyframes shimmer { 100% { left: 100%; } }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-sync .spinner {
    display: none; width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,0.3); border-top-color: white;
    border-radius: 50%; animation: spin 0.6s linear infinite;
}
.btn-sync.loading .spinner { display: inline-block; }
.btn-sync.loading .btn-text { opacity: 0.7; }

.drr-btn { position: relative; }
.drr-status { display: inline-block; margin-left: 4px; font-size: 10px; padding: 2px 6px; border-radius: 3px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.drr-on { background: #d4edda; color: #155724; }
.drr-off { background: var(--bg-stripe); color: var(--text-muted); }

/* === Login === */
.login-wrapper { display: flex; align-items: center; justify-content: center; min-height: calc(100vh - var(--header-h)); padding: 24px; background: url('/static/img/login-bg.jpg') center 70%/cover no-repeat; position: relative; }
.login-wrapper::before { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255,255,255,0.35) 0%, rgba(255,255,255,0.55) 100%); backdrop-filter: blur(2px); }
.login-wrapper > .login-card { position: relative; z-index: 1; }
.login-card { background: var(--bg-white); border-radius: var(--radius-lg); box-shadow: 0 24px 60px rgba(0,0,0,0.25); padding: 36px 32px; width: 100%; max-width: 360px; }
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo-icon { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; background: var(--primary); border-radius: var(--radius); margin-bottom: 16px; }
.login-logo-icon svg { width: 28px; height: 28px; fill: white; }
.login-logo h1 { font-size: 24px; font-weight: 700; color: var(--text); letter-spacing: -0.3px; }
.login-logo p { color: var(--text-muted); font-size: 14px; margin-top: 12px; }
.login-logo-img { max-width: 180px; width: 100%; height: auto; display: block; margin: 0 auto; }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; color: var(--text-secondary); font-size: 13px; }
.form-group input { width: 100%; padding: 11px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; font-family: var(--font); transition: all var(--transition); background: var(--bg-white); color: var(--text); }
.form-group input::placeholder { color: var(--text-muted); }
.form-group input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.1); }

/* === Alerts === */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* === Badges === */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.badge-on { background: #d4edda; color: #155724; }
.badge-off { background: var(--bg-stripe); color: var(--text-muted); }

/* === Search === */
.search-bar { margin-bottom: 20px; }
.search-input-wrapper { position: relative; max-width: 400px; }
.search-input-wrapper svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); pointer-events: none; }
.search-input { width: 100%; padding: 10px 14px 10px 38px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; font-family: var(--font); transition: all var(--transition); background: var(--bg-white); color: var(--text); }
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.1); }

/* === Cards === */
.card { background: var(--bg-white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.table-wrapper { background: var(--bg-white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.table-scroll { overflow-x: auto; background: var(--bg-white); border-radius: var(--radius); box-shadow: var(--shadow); -webkit-overflow-scrolling: touch; }

/* === Tables === */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { background: var(--primary); color: var(--text-white); font-weight: 600; text-align: left; padding: 12px 14px; white-space: nowrap; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; border-bottom: none; }
.data-table td { padding: 10px 14px; border-bottom: 1px solid var(--border-light); vertical-align: middle; transition: background var(--transition); }
.data-table tbody tr:nth-child(even) { background: var(--bg-stripe); }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-family: var(--font-mono); font-size: 12px; }

.client-link { font-weight: 600; color: var(--primary); }
.client-link:hover { color: var(--primary-dark); text-decoration: underline; }

.actions-cell { display: flex; gap: 8px; align-items: center; }
.copy-btn { padding: 5px 8px; font-size: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-white); color: var(--text-muted); cursor: pointer; transition: all var(--transition); display: inline-flex; align-items: center; gap: 4px; }
.copy-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }
.copy-btn svg { width: 14px; height: 14px; }

/* === Monthly Table === */
.monthly-table .metric-col { min-width: 180px; position: sticky; left: 0; z-index: 2; background: var(--primary); }
.monthly-table .metric-name { font-weight: 500; white-space: nowrap; position: sticky; left: 0; z-index: 1; background: var(--bg-white); border-right: 2px solid var(--border-light); }
.monthly-table tbody tr:nth-child(even) .metric-name { background: var(--bg-stripe); }
.monthly-table tbody tr:hover .metric-name { background: var(--bg-hover); }
.monthly-table .month-col { min-width: 95px; text-align: right; }

.drr-row { background: rgba(192, 57, 43, 0.03) !important; }
.drr-row .metric-name { background: #fef8f7; color: var(--primary); font-weight: 600; }
.drr-row:hover .metric-name { background: var(--bg-hover) !important; }

/* === Campaign Table === */
.campaign-table .campaign-col { min-width: 260px; }
.campaign-table .campaign-name { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.campaign-table .group-header { text-align: center; background: var(--primary-dark); color: var(--text-white); font-size: 11px; letter-spacing: 0.5px; }
.campaign-table .sub-header { text-align: right; font-size: 11px; background: var(--primary); color: rgba(255,255,255,0.85); }

.group-row td { background: var(--bg) !important; font-weight: 700; color: var(--primary); font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; padding: 8px 14px; border-top: 2px solid var(--border); }
.totals-row td { background: var(--bg) !important; border-top: 2px solid var(--primary); font-weight: 700; }
.total-col { background: var(--primary-bg) !important; font-weight: 700; color: var(--primary); }

/* === Filters === */
.filters-bar { margin-bottom: 20px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.year-selector { display: flex; gap: 6px; align-items: center; }
.year-selector label { font-weight: 600; color: var(--text-secondary); margin-right: 4px; font-size: 13px; }

/* === Tabs === */
.tabs { display: flex; gap: 0; margin-bottom: 28px; border-bottom: 2px solid var(--border); }
.tab { padding: 12px 24px; font-weight: 600; font-size: 14px; color: var(--text-muted); border-bottom: 3px solid transparent; margin-bottom: -2px; transition: all var(--transition); }
.tab:hover { color: var(--text); background: var(--bg-stripe); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); background: transparent; }

/* === Report Section === */
.report-section { margin-bottom: 36px; }
.section-title { font-size: 16px; font-weight: 700; margin-bottom: 14px; padding: 10px 16px; background: var(--primary); color: var(--text-white); border-radius: var(--radius-sm); display: flex; align-items: center; gap: 8px; }

/* === Empty State === */
.empty-state { text-align: center; padding: 64px 24px; color: var(--text-muted); background: var(--bg-white); border-radius: var(--radius); box-shadow: var(--shadow); }
.empty-state p { font-size: 15px; max-width: 440px; margin: 0 auto; line-height: 1.7; }

/* === Toast === */
.toast { position: fixed; bottom: 28px; right: 28px; background: var(--text); color: var(--text-white); padding: 14px 24px; border-radius: var(--radius); font-size: 13px; font-weight: 500; box-shadow: var(--shadow-xl); opacity: 0; transform: translateY(16px); transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1); z-index: 9999; display: flex; align-items: center; gap: 8px; max-width: 360px; }
.toast.toast-success { background: #166534; }
.toast.toast-error { background: #b91c1c; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-icon { font-size: 16px; flex-shrink: 0; }
.notification { position: fixed; bottom: 28px; right: 28px; background: var(--text); color: var(--text-white); padding: 14px 24px; border-radius: var(--radius); font-size: 13px; font-weight: 500; box-shadow: var(--shadow-xl); opacity: 0; transform: translateY(16px); transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1); z-index: 9999; }
.notification.show { opacity: 1; transform: translateY(0); }

.client-count { font-size: 13px; color: var(--text-muted); font-weight: 400; margin-left: 8px; }

/* ============================================================
   SUMMARY BLOCK
   ============================================================ */

.summary-block {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.summary-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px 16px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}

.summary-logo {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--primary);
  font-family: var(--font-sans);
  text-transform: lowercase;
  flex-shrink: 0;
}

.summary-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  flex: 1;
}

.summary-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}

.summary-section-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.summary-period-selector {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.summary-period-selector::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #fff;
  pointer-events: none;
}

.summary-period-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 7px 34px 7px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  outline: none;
  transition: background 0.2s;
}

.summary-period-select:hover {
  background: var(--green-dark);
}

.summary-period-select option {
  background: #fff;
  color: var(--text);
  font-weight: 500;
}

.summary-metrics-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-top: none;
}

.summary-metric-card {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.summary-metric-card:last-child {
  border-right: none;
}

.summary-metric-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 8px 14px;
  color: #fff;
}

.summary-stat-label {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.summary-leads-label {

  background: linear-gradient(135deg, #8b1a1a 0%, #6b1515 100%);
}

.summary-metric-value {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text);
  padding: 14px 14px 16px;
  line-height: 1.2;
}

/* ============================================================
   SETTINGS DROPDOWN
   ============================================================ */

.settings-dropdown {
  position: relative;
  display: inline-block;
}

.settings-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xl);
  min-width: 200px;
  z-index: 1000;
  overflow: hidden;
  display: none;
}

.settings-dropdown-menu.open {
  display: block;
}

.settings-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
}

.settings-dropdown-item:hover {
  background: var(--bg-hover);
}

.settings-dropdown-item.danger {
  color: var(--danger);
}

.settings-dropdown-item.danger:hover {
  background: #fff5f5;
}

.settings-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ============================================================
   LOGO IMAGE SUPPORT
   ============================================================ */

.nav-logo img {
  height: 32px;
  width: auto;
  display: block;
}

.summary-logo img {
  height: 28px;
  width: auto;
  display: block;
}


/* === Favorite Star === */
.favorite-star {
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    transition: color var(--transition), transform 0.15s ease;
    flex-shrink: 0;
    user-select: none;
}
.favorite-star.active {
    color: #f39c12;
}
.favorite-star:not(.active) {
    color: #ddd;
}
.favorite-star:hover {
    transform: scale(1.2);
}

/* === Settings Panel (report page) === */
.settings-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
    min-width: 260px;
    z-index: 1000;
    overflow: hidden;
    display: none;
    padding: 8px 0;
}
.settings-dropdown.open .settings-panel {
    display: block;
}
.settings-section {
    padding: 10px 16px;
}
.settings-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 6px;
}
.settings-select {
    width: 100%;
    padding: 7px 10px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font);
    background: var(--bg-white);
    color: var(--text);
    cursor: pointer;
    outline: none;
}
.settings-select:focus {
    border-color: var(--primary);
}
.settings-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 0;
}
.settings-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s;
}
.settings-checkbox:hover {
    background: var(--bg-hover);
}
.settings-checkbox input[type=checkbox] {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: var(--primary);
}
.settings-checkbox .checkmark {
    display: none;
}
.chevron-icon {
    transition: transform var(--transition);
}
.settings-dropdown.open .chevron-icon {
    transform: rotate(180deg);
}

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

@media (max-width: 1200px) {
  .summary-metrics-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .summary-metric-card:nth-child(4) {
    border-right: none;
  }
}

@media (max-width: 900px) {
  .summary-header-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .summary-title {
    text-align: left;
  }

  .summary-metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .summary-metric-card:nth-child(2n) {
    border-right: none;
  }

  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .main-nav {
    padding: 0 16px;
  }

  .content {
    padding: 20px 16px;
  }

  .filters-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

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

  .summary-metric-card {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .tabs-bar {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .tab-link {
    flex-shrink: 0;
  }

  .page-title {
    font-size: 20px;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   PRINT
   ============================================================ */

@media print {
  .main-nav,
  .filters-row,
  .tabs-bar,
  .summary-controls-row,
  .btn,
  .toast,
  .notification {
    display: none !important;
  }

  .content {
    padding: 0;
  }

  .summary-block,
  .card,
  .report-section {
    box-shadow: none;
    border: 1px solid #ddd;
  }

  body {
    background: #fff;
    color: #000;
  }

  table {
    page-break-inside: avoid;
  }

  .summary-metrics-grid {
    grid-template-columns: repeat(7, 1fr);
  }
}

/* Logo image in header */
.logo-img {
    height: 80px;
    width: auto;
    display: block;
}

/* Goals dropdown */
.goals-dropdown { position: relative; display: inline-block; }
.goals-toggle { display: flex; align-items: center; gap: 6px; }
.goals-panel {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    min-width: 360px;
    max-width: 450px;
    z-index: 1000;
    padding: 12px;
    margin-top: 4px;
}
.goals-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.btn-refresh {
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    color: #666;
    display: flex;
    align-items: center;
}
.btn-refresh:hover { border-color: #c0392b; color: #c0392b; }
.goals-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 6px;
    padding: 4px;
    margin-bottom: 8px;
}
.goals-loading {
    padding: 16px;
    text-align: center;
    color: #999;
    font-size: 13px;
}
.goal-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}
.goal-item:hover { background: #f5f5f5; }
.goal-item input[type=checkbox] {
    accent-color: #c0392b;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
.goal-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal-count { color: #999; font-size: 12px; flex-shrink: 0; }
.goals-actions { display: flex; gap: 6px; }
.btn-sm { padding: 4px 12px; font-size: 12px; }
.btn-primary { background: #c0392b; color: #fff; border: 1px solid #c0392b; border-radius: 4px; cursor: pointer; }
.btn-primary:hover { background: #a93226; }

/* Per-goal columns in campaign report */
.data-table .goal-header {
    background: #fef5f4;
    color: #c0392b;
    border-left: 2px solid #c0392b;
    max-width: 200px;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.25;
    font-size: 12px;
    padding: 6px 8px;
}
.data-table .goal-col {
    background: #fdfafa;
    border-left: 1px solid #f0d9d5;
}
.data-table .goal-col + .goal-col {
    border-left: 1px dashed #f0d9d5;
}

/* Goal totals column (sum across all selected goals) */
.data-table .goal-total-header {
    background: #c0392b;
    color: #fff;
    border-left: 2px solid #c0392b;
}
.data-table .goal-total-col {
    background: #fdeceb;
    font-weight: 500;
    border-left: 1px solid #c0392b;
}

.goal-id { display:inline-block; min-width:72px; font-family:monospace; font-size:12px; color:#666; flex-shrink:0; }
.goal-name-input { flex:1; min-width:0; padding:4px 6px; border:1px solid #ddd; border-radius:3px; font-size:12px; background:#fff; }
.goal-name-input:focus { outline:none; border-color:#c0392b; }
.goal-id-input { width:110px; padding:4px 6px; border:1px solid #ddd; border-radius:3px; font-size:12px; font-family:monospace; }
.goal-del-btn { background:transparent; border:none; color:#999; font-size:18px; line-height:1; cursor:pointer; padding:0 6px; flex-shrink:0; }
.goal-del-btn:hover { color:#c0392b; }
.goal-add-btn { background:#c0392b; color:#fff; border:none; border-radius:3px; width:28px; height:26px; font-size:18px; line-height:1; cursor:pointer; flex-shrink:0; }
.goal-add-btn:hover { background:#a93226; }
.goal-add-row { display:flex; align-items:center; gap:8px; padding:8px 8px; margin-top:6px; border-top:1px dashed #ddd; }
.goals-hint { padding:8px; color:#999; font-size:12px; text-align:center; }

.login-footer-note { margin-top: 20px; text-align: center; font-size: 12px; color: var(--text-muted); letter-spacing: 0.3px; }

/* Transparent header on login page */
.login-page .header { display: none; }
.login-page .main-content { padding-top: 0; }
.login-page .login-wrapper { min-height: 100vh; }


.login-page .brand-tagline {
    color: #1a1a1a;
    font-weight: 700;
    font-size: 14px;
    text-shadow: 0 1px 2px rgba(255,255,255,0.7);
    border-left-color: var(--primary);
}

.login-subtitle {
    margin-top: 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.3px;
    text-align: center;
}

/* Header layout: logo | main | nav */
.header-main { flex: 1; display: flex; align-items: center; gap: 16px; padding: 0 24px; min-width: 0; }
.header-title { flex-shrink: 0; }
.header-title h1 { font-size: 22px; font-weight: 700; color: var(--text); letter-spacing: -0.3px; margin: 0; }
.header-title .client-count { margin-left: 8px; font-size: 14px; font-weight: 500; color: var(--text-muted); }
.header-search { flex: 1; max-width: 360px; }
.header-search .search-input-wrapper { position: relative; }
.header-search .search-input-wrapper svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); pointer-events: none; }
.header-search .search-input { width: 100%; height: 40px; padding: 0 12px 0 36px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); font-size: 14px; color: var(--text); outline: none; transition: border-color var(--transition); }
.header-search .search-input:focus { border-color: var(--primary); background: var(--bg-white); }
.header-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }
.header-actions .btn { height: 40px; padding: 0 14px; white-space: nowrap; }
@media (max-width: 1100px) { .header-search { display: none; } }
@media (max-width: 760px) { .header-title h1 { font-size: 18px; } .header-actions .btn-text { display: none; } .header-actions .btn { padding: 0 10px; } }

/* Specialist column */
.specialist-cell { min-width: 200px; }
.specialist-wrap { display: flex; gap: 6px; align-items: center; }
.specialist-input { flex: 1; min-width: 0; height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-white); font-size: 13px; color: var(--text); outline: none; transition: border-color var(--transition); }
.specialist-input:focus { border-color: var(--primary); }
.specialist-save { flex-shrink: 0; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; background: var(--primary); color: #fff; border: none; border-radius: var(--radius); cursor: pointer; transition: background var(--transition); }
.specialist-save:hover { background: var(--primary-dark); }
.specialist-save svg { width: 16px; height: 16px; }
.specialist-save.saved { background: #2e7d32; }
.specialist-save.error { background: #c62828; }
.specialist-save:disabled { opacity: 0.6; cursor: not-allowed; }

/* Specialist filter dropdown */
.specialist-filter { position: relative; }
.specialist-filter-panel { display: none; position: absolute; right: 0; top: calc(100% + 6px); background: var(--bg-white); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 28px rgba(0,0,0,0.12); min-width: 260px; max-width: 340px; z-index: 200; padding: 10px; }
.specialist-filter-panel.open { display: block; }
.specialist-filter-list { max-height: 300px; overflow-y: auto; margin-bottom: 10px; }
.specialist-filter-item { display: flex; align-items: center; gap: 8px; padding: 6px 4px; font-size: 13px; color: var(--text); cursor: pointer; border-radius: 4px; }
.specialist-filter-item:hover { background: var(--bg); }
.specialist-filter-item input { margin: 0; }
.specialist-filter-buttons { display: flex; gap: 6px; justify-content: flex-end; border-top: 1px solid var(--border); padding-top: 8px; }
.specialist-filter-buttons .btn-sm { height: 30px; padding: 0 12px; font-size: 12px; }
.specialist-filter-empty { padding: 12px 6px; font-size: 13px; color: var(--text-muted); text-align: center; }

/* === Campaign report: weeks collapsible === */
.campaign-month-block .section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.campaign-month-block .section-actions .btn-sm { height: 30px; padding: 0 12px; font-size: 12px; }

/* Unified palette — red primary */
.campaign-table { border-collapse: separate; border-spacing: 0; }
.campaign-table th, .campaign-table td { border-bottom: 1px solid #f0e0df; border-right: 1px solid #f5ebea; padding: 8px 10px; }
.campaign-table thead tr:last-child th { border-bottom: 2px solid var(--primary); }

/* Block headers (top row) */
.campaign-table .block-hdr { background: #fdeceb; color: var(--primary); font-weight: 700; text-align: center; padding: 7px 12px; border-bottom: 2px solid #f5c6c2; border-right: 2px solid #fff; font-size: 13px; letter-spacing: 0.2px; }
.campaign-table .block-hdr--month { background: #fbdedc; }
.campaign-table .block-hdr--week { background: #fdf2f1; color: var(--primary); cursor: pointer; user-select: none; white-space: nowrap; transition: background 0.15s ease; border-left: 2px solid var(--primary); border-right: 2px solid var(--primary); border-top: 2px solid var(--primary); }
.campaign-table .block-hdr--week:hover { background: #fde0de; }
.campaign-table .block-hdr--week.collapsed { background: #f7f7f7; color: #888; border-bottom: 2px solid #e0e0e0; writing-mode: horizontal-tb; }
.campaign-table .block-hdr--week.collapsed:hover { background: #eeeeee; color: var(--primary); }
.campaign-table .block-hdr--week .week-arrow { display: inline-block; font-size: 10px; margin-right: 4px; }

/* Sub headers */
.campaign-table .sub-row th { font-size: 10.5px; font-weight: 600; color: #8a4e48; text-transform: uppercase; letter-spacing: 0.3px; padding: 6px 10px; background: #fff8f8; border-bottom: 2px solid var(--primary); }

/* Week boundaries: add strong divider at left of each week block */
.campaign-table .block-hdr--week { border-left: 2px solid #f5c6c2; }
.campaign-table td[data-week]:nth-child(8n+1),
.campaign-table th[data-week]:nth-child(8n+1) { /* noop placeholder */ }
.campaign-table .week-cell[data-week] { background: #fdfaf9; }
.campaign-table tbody tr:nth-child(even) .week-cell { background: #faf5f4; }

/* Month totals block: subtle tinted bg */
.campaign-table .goal-total-col { background: #fff7f6; }
.campaign-table tbody tr:nth-child(even) .goal-total-col { background: #fdeeec; }

/* Zebra stripes + hover */
.campaign-table tbody tr:nth-child(even) td { background: #fbfbfb; }
.campaign-table tbody tr:nth-child(even) .goal-total-col { background: #fdeeec; }
.campaign-table tbody tr:nth-child(even) .week-cell { background: #faf5f4; }
.campaign-table tbody tr:hover td { background: #fff2f0 !important; transition: background 0.1s ease; }
.campaign-table tbody tr:hover .goal-total-col { background: #ffe4e0 !important; }
.campaign-table tbody tr:hover .week-cell { background: #ffe9e6 !important; }

/* Group-row (campaign type) — vibrant red */
.campaign-table tbody tr.group-row.group-totals-row td { background: var(--primary) !important; color: #fff !important; font-weight: 800 !important; text-transform: uppercase; font-size: 12px; letter-spacing: 0.4px; padding: 6px 10px; border-top: 1px solid var(--primary); border-bottom: 1px solid var(--primary); text-shadow: 0 1px 1px rgba(0,0,0,0.2); }
.campaign-table tbody tr.group-row.group-totals-row td.group-name-cell { cursor: pointer; user-select: none; padding-left: 14px; text-align: left; }
.campaign-table tbody tr.group-row.group-totals-row:hover td { background: var(--primary) !important; color: #fff !important; }
.campaign-table .group-toggle { display: inline-block; width: 16px; height: 16px; line-height: 14px; text-align: center; border: 1px solid #fff; border-radius: 3px; font-size: 12px; margin-right: 6px; color: #fff; background: rgba(255,255,255,0.12); }
.campaign-table tbody tr.group-row.group-totals-row.collapsed td { background: var(--primary) !important; }
.campaign-table tbody tr.group-row:hover td { background: var(--primary) !important; }

/* Totals row */
.campaign-table tbody tr.totals-row td { background: #fbdedc !important; color: var(--primary); font-weight: 700; border-top: 2px solid var(--primary); border-bottom: 2px solid var(--primary); }
.campaign-table tbody tr.totals-row:hover td { background: #fbdedc !important; }

/* Campaign name col sticky feel */
.campaign-table .campaign-name { font-weight: 500; color: var(--text); white-space: nowrap; max-width: 300px; overflow: hidden; text-overflow: ellipsis; border-right: 2px solid #f5ebea; }
.campaign-table .campaign-col { background: #fff !important; color: var(--primary) !important; font-weight: 800 !important; border-right: 2px solid var(--primary) !important; border-bottom: 2px solid var(--primary) !important; font-size: 12px; letter-spacing: 0.5px; }

/* Numbers — right-aligned, tabular nums */
.campaign-table .num { text-align: right; font-variant-numeric: tabular-nums; font-feature-settings: tnum; }

.campaign-table .week-cell.hidden { display: none; }

/* Week block frame */
.campaign-table .week-cell { border-left: 1px solid #f5c6c2; border-right: 1px solid #f5c6c2; }
.campaign-table .block-hdr--week { border-bottom: 2px solid var(--primary); }
.campaign-table .block-hdr--week.collapsed { border-top: 2px solid #ccc; border-left: 2px solid #ccc; border-right: 2px solid #ccc; border-bottom: 2px solid #ccc; }
/* Strong side borders at week boundaries: first week-cell (left edge of first week) and subsequent ones after every 8 */
.campaign-table .sub-row th.week-cell:first-of-type,
.campaign-table tbody tr td.week-cell:first-of-type {
  /* this matches the first week-cell of the row — adds strong left edge */
}


/* Week block frame using week-first/week-last markers */
.campaign-table .week-cell.week-first { border-left: 2px solid var(--primary); }
.campaign-table .week-cell.week-last { border-right: 2px solid var(--primary); }
.campaign-table .block-hdr--week { border-left: 2px solid var(--primary); border-right: 2px solid var(--primary); border-top: 2px solid var(--primary); }
.campaign-table .block-hdr--week.collapsed { border: 2px solid #ccc; }


/* === Uniform row & column sizes === */
.campaign-table { table-layout: auto; }
.campaign-table th, .campaign-table td { height: 36px; box-sizing: border-box; padding: 6px 10px; white-space: nowrap; font-size: 12.5px; }
.campaign-table thead th { height: 34px; padding: 5px 10px; }
.campaign-table .block-hdr { height: 32px; }
.campaign-table .sub-row th { height: 28px; padding: 4px 8px; font-size: 10.5px; }
.campaign-table tbody tr.group-row td { height: 26px; padding: 3px 14px; }
.campaign-table tbody tr.totals-row td { height: 36px; }
.campaign-table .campaign-col { width: 260px; min-width: 260px; max-width: 260px; }
.campaign-table .campaign-name { width: 260px; min-width: 260px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.campaign-table td.num, .campaign-table th.sub-header { min-width: 80px; width: 80px; }
.campaign-table th.sub-header.goal-col { min-width: 90px; width: 90px; }


/* Collapse table body — show only thead + totals row */
.campaign-table.body-collapsed tbody tr:not(.totals-row) { display: none; }


/* Duplicate horizontal scroll on top of campaign tables — match bottom native */
.table-scroll-top { overflow-x: scroll; overflow-y: hidden; margin-bottom: 6px; }
.table-scroll-top-inner { height: 1px; }


/* === Sticky first column for campaign tables === */
.campaign-table thead th.campaign-col { position: sticky; left: 0; z-index: 4; background: #fff !important; border-right: 2px solid var(--primary) !important; }
.campaign-table tbody td.campaign-name { position: sticky; left: 0; z-index: 2; background: #fff; border-right: 2px solid #f5ebea; }
.campaign-table tbody tr:nth-child(even) td.campaign-name { background: #fbfbfb; }
.campaign-table tbody tr:hover td.campaign-name { background: #fff2f0 !important; }
.campaign-table tbody tr.totals-row td:first-child { position: sticky; left: 0; z-index: 3; background: #fbdedc !important; }
.campaign-table tbody tr.group-row td:first-child { position: sticky; left: 0; z-index: 3; background: var(--primary) !important; color: #fff; }


/* === Internal scroll table with sticky thead === */
.campaign-month-block .table-scroll { max-height: 70vh; overflow-y: auto; overflow-x: auto; }
.campaign-table thead th.block-hdr { position: sticky; top: 0; z-index: 3; }
.campaign-table thead tr.sub-row th { position: sticky; top: 32px; z-index: 3; background: #fff8f8; }
/* Top-left corner: KAMPANIA header — stick both */
.campaign-table thead th.campaign-col { position: sticky; left: 0; top: 0; z-index: 6; }


/* Report actions bar (top of report page) */
.report-actions-bar { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; }
.report-actions-bar .btn { height: 38px; padding: 0 18px; font-size: 13px; font-weight: 600; }
.report-actions-bar .btn-export-xls { background: var(--primary); color: #fff; border: 1px solid var(--primary); }
.report-actions-bar .btn-export-xls:hover { background: #a52e21; border-color: #a52e21; }
.report-actions-bar .btn-force-sync { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.report-actions-bar .btn-force-sync:hover { background: #fff2f0; }
.report-actions-bar .btn-force-sync:disabled { opacity: 0.6; cursor: not-allowed; }

/* Paused campaign visual marking */
.campaign-table tr.campaign-row.is-stopped td {
    background: #f2f2f2 !important;
    color: #8a8a8a !important;
}
.campaign-table tr.campaign-row.is-stopped td.campaign-name-cell {
    font-style: italic;
}
.state-icon {
    display: inline-block;
    color: #b0b0b0;
    margin-right: 6px;
    vertical-align: -1px;
}
.campaign-table tr.campaign-row.is-stopped:hover td {
    background: #eaeaea !important;
}
