:root {
  --navy: #1b3556;
  --navy-dark: #0f1e38;
  --red: #d00837;
  --red-dark: #a80630;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --yellow-bg: #fef9c3;
  --blue-bg: #dbeafe;
  --shadow: 0 1px 3px rgba(15,23,42,0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  display: flex;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 28px 28px 32px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.sidebar .brand .dot {
  width: 12px; height: 12px; background: var(--red); border-radius: 50%;
}
.sidebar nav {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 0 16px;
  gap: 4px;
}
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar nav a.active { background: rgba(208,8,55,0.18); color: #fff; font-weight: 600; }
.sidebar nav a span:first-child { font-size: 20px; }
.sidebar .footer {
  padding: 16px 22px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 14px;
  color: rgba(255,255,255,0.6);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar .user-info { flex: 1; min-width: 0; }
.sidebar .user-name { color: #fff; font-weight: 600; font-size: 14px; }
.sidebar .user-role { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: rgba(255,255,255,0.5); }
.sidebar .btn-logout {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.7);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 14px;
  cursor: pointer;
}
.sidebar .btn-logout:hover { background: rgba(208,8,55,0.18); color: #fff; }

.demo-banner {
  background: linear-gradient(90deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #f59e0b;
  color: #78350f;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 20px;
}
.demo-banner strong { color: #92400e; letter-spacing: 0.5px; }

/* Main */
.main {
  flex: 1;
  padding: 40px 48px;
  max-width: 1750px;
  overflow-x: auto;
}

/* Headers */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 32px;
  gap: 20px;
}
h1 { font-size: 32px; font-weight: 700; color: var(--navy); letter-spacing: -0.5px; }
h2 { font-size: 20px; font-weight: 700; color: var(--navy); margin: 28px 0 14px; }
h3 { font-size: 17px; font-weight: 700; color: var(--navy); margin-bottom: 14px; }
.back { color: var(--muted); font-size: 14px; text-decoration: none; display: inline-block; margin-bottom: 6px; }
.back:hover { color: var(--navy); }

/* KPI row */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}
.kpi {
  background: var(--surface);
  padding: 20px 24px;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.kpi-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 600;
}
.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--navy);
  margin-top: 6px;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.card.hidden { display: none; }
.card header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 18px;
}
.form-grid label.span-2 { grid-column: span 2; }
.form-grid label.span-3 { grid-column: span 3; }
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}
input, select, textarea {
  font: inherit;
  font-size: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(27,53,86,0.1);
}
textarea { resize: vertical; min-height: 90px; font-family: inherit; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 11px 20px;
  font-size: 15px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}
.btn:hover { background: var(--bg); border-color: var(--navy); }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }

/* Account block — sectioned campaigns view */
.account-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.account-head {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 18px 24px;
  background: linear-gradient(0deg, var(--bg) 0%, #fff 100%);
  border-bottom: 1px solid var(--border);
}
.account-title {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}
.account-title h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
}
.account-stats {
  display: flex;
  gap: 28px;
}
.account-stats > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 14px;
}
.account-stats strong {
  color: var(--navy);
  font-weight: 700;
  font-size: 15px;
}
.account-actions {
  display: flex;
  gap: 6px;
}

.campaign-list {
  display: flex;
  flex-direction: column;
}
.campaign-row {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.campaign-row:last-child { border-bottom: none; }
.campaign-row:hover { background: var(--bg); }

.campaign-main { flex: 1; min-width: 0; }
.campaign-num {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 4px;
}
.campaign-name {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.campaign-name strong {
  font-size: 16px;
  color: var(--navy);
  font-weight: 700;
}
.campaign-meta {
  display: flex;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.campaign-meta strong { color: var(--text); font-weight: 600; }
.campaign-effect {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
}

.campaign-numbers {
  display: grid;
  grid-template-columns: repeat(4, minmax(80px, 1fr));
  gap: 16px;
  flex-shrink: 0;
}
.campaign-numbers > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.campaign-numbers strong {
  color: var(--navy);
  font-weight: 700;
  font-size: 14px;
}

@media (max-width: 1100px) {
  .campaign-row { flex-direction: column; align-items: stretch; gap: 12px; }
  .campaign-numbers { grid-template-columns: repeat(4, 1fr); }
  .account-head { flex-wrap: wrap; }
  .account-stats { gap: 18px; }
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  font-size: 14px;
  table-layout: auto;
}
.data-table th, .data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.data-table td.contact { max-width: 220px; word-break: break-word; }
.data-table td.col-source { max-width: 180px; word-break: break-word; }
.data-table td.col-product { max-width: 180px; word-break: break-word; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 12px; margin-bottom: 24px; }
.table-wrap > .data-table { margin-bottom: 0; }
.data-table th {
  background: #f8fafc;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 600;
}
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .empty { text-align: center; padding: 50px; color: var(--muted); font-style: italic; }
.data-table a { color: var(--navy); text-decoration: none; }
.data-table a:hover { color: var(--red); }

/* Badges & status */
.badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
}
.badge-google { background: #fef3c7; color: #92400e; }
.badge-fb { background: #dbeafe; color: #1e40af; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.status {
  display: inline-block;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
}
.status-enabled, .status-aktywna { background: var(--green-bg); color: var(--green); }
.status-paused, .status-wstrzymana { background: var(--yellow-bg); color: #854d0e; }
.status-removed { background: #fee2e2; color: var(--red); }
.status-open { background: var(--blue-bg); color: #1e40af; }
.status-in_progress { background: var(--yellow-bg); color: #854d0e; }
.status-blocked { background: #fee2e2; color: var(--red); }
.status-done { background: var(--green-bg); color: var(--green); }

.status-lead-new       { background: var(--blue-bg); color: #1e40af; }
.status-lead-contacted { background: var(--yellow-bg); color: #854d0e; }
.status-lead-quoted    { background: #fed7aa; color: #9a3412; }
.status-lead-won       { background: var(--green-bg); color: var(--green); }
.status-lead-lost      { background: #fee2e2; color: var(--red); }

.prio { font-size: 13px; font-weight: 600; }
.prio-high { color: var(--red); }
.prio-medium { color: var(--muted); }
.prio-low { color: var(--muted); opacity: 0.7; }

/* Filter tabs */
.filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
}
.filter-tabs a {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  border-radius: 6px;
}
.filter-tabs a.active { background: var(--navy); color: #fff; }

/* Task detail grid */
.task-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
}
.task-grid aside { display: flex; flex-direction: column; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack hr, .card hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* Comments */
.comments { display: flex; flex-direction: column; gap: 14px; margin-bottom: 22px; }
.comment {
  border-left: 3px solid var(--navy);
  padding: 12px 16px;
  background: var(--bg);
  border-radius: 0 8px 8px 0;
}
.comment-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 6px; font-size: 13px; }
.comment-body { white-space: pre-wrap; font-size: 15px; line-height: 1.55; }
.mention {
  background: rgba(208,8,55,0.1);
  color: var(--red);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.comment-form { display: flex; flex-direction: column; gap: 12px; }

/* Notes */
.notes-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.notes-list .card h3 { margin: 0; }
.tag {
  display: inline-block;
  background: var(--blue-bg);
  color: #1e40af;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 6px;
  font-weight: 600;
}

/* Flash */
.flash-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}
.flash {
  padding: 14px 18px;
  border-radius: 8px;
  font-size: 15px;
  transition: opacity 0.4s;
  border: 1px solid;
}
.flash-ok { background: var(--green-bg); color: var(--green); border-color: var(--green); }
.flash-err { background: #fee2e2; color: var(--red); border-color: var(--red); }
.flash.fade { opacity: 0; }

/* Responsive */
@media (max-width: 1100px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .task-grid { grid-template-columns: 1fr; }
  .notes-list { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  body { flex-direction: column; }
  .sidebar { width: 100%; height: auto; flex-direction: row; padding: 8px; position: relative; }
  .sidebar .brand { padding: 10px 14px; font-size: 18px; }
  .sidebar nav { flex-direction: row; gap: 4px; padding: 0 8px; }
  .sidebar .footer { display: none; }
  .main { padding: 24px 20px; }
  .form-grid { grid-template-columns: 1fr; }
  h1 { font-size: 26px; }
}
