:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;

  --brand: #4f46e5;
  --brand-ink: #ffffff;
  --brand-dark: #4338ca;
  --brand-soft: #eef2ff;
  --accent: #4f46e5;
  --grad: linear-gradient(135deg, #38bdf8 0%, #6366f1 50%, #a855f7 100%);

  --green: #16a34a;
  --green-500: #22c55e;
  --amber: #d97706;
  --red: #dc2626;

  --sidebar-bg: #ffffff;

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

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05), 0 0 0 1px rgba(15, 23, 42, 0.04);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.1), 0 1px 2px rgba(15, 23, 42, 0.06), 0 0 0 1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px rgba(15, 23, 42, 0.07), 0 2px 4px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 20px rgba(15, 23, 42, 0.12), 0 4px 8px rgba(15, 23, 42, 0.06);

  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--font);
  font-feature-settings: "tnum" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

svg { flex: none; }

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

.app {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

/* ============================= SIDEBAR ============================= */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  color: var(--ink-soft);
  padding: 18px 14px;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 22px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: var(--grad);
  color: var(--brand-ink);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
}

.brand-mark svg { width: 20px; height: 20px; }

.brand-text { display: grid; line-height: 1.25; }
.brand-text strong { color: var(--ink); font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.brand-text span { font-size: 11.5px; color: var(--muted); }

.nav { display: grid; gap: 3px; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #475569;
  font-weight: 600;
  font-size: 13.5px;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav-item svg { width: 18px; height: 18px; color: var(--muted); }

.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item:hover svg { color: var(--ink-soft); }

.nav-item.active {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.nav-item.active svg { color: var(--brand); }

.nav-item.disabled { opacity: 0.45; cursor: default; }
.nav-item.disabled:hover { background: transparent; color: #475569; }

.nav-count {
  margin-left: auto;
  min-width: 22px;
  text-align: center;
  padding: 1px 7px;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
}

.nav-item.active .nav-count { background: var(--brand); color: #fff; }

/* ---- sidebar: project / threads / automations ---- */
.nav-label {
  padding: 14px 12px 5px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.nav .nav-label:first-child { padding-top: 2px; }

.proj { display: grid; gap: 2px; }
.proj-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
}
.proj-av {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--grad);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  flex: none;
}
.proj-name { font-size: 13.5px; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; }
.proj-body { display: grid; gap: 2px; padding-left: 11px; margin-left: 12px; border-left: 1px solid var(--line); }

.thread-list { display: grid; gap: 1px; }
.thread-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.12s, color 0.12s;
}
.thread-item::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--line-strong);
  flex: none;
}
.thread-item { cursor: pointer; }
.thread-item:hover { background: var(--surface-2); color: var(--ink); }
.thread-item.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.thread-item.active::before { background: var(--brand); }
.thread-item .thread-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-item.is-archived { color: var(--muted); }
.thread-item.is-archived::before { background: var(--line); }

.thread-menu {
  flex: none;
  width: 22px;
  height: 22px;
  margin: -3px -4px -3px 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s, color 0.12s;
}
.thread-item:hover .thread-menu,
.thread-item.active .thread-menu { opacity: 1; }
.thread-menu:hover { background: var(--surface); color: var(--ink); }

.thread-arch-toggle {
  width: 100%;
  margin-top: 4px;
  padding: 6px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.thread-arch-toggle:hover { background: var(--surface-2); color: var(--ink-soft); }

.thread-pop {
  position: fixed;
  z-index: 80;
  min-width: 176px;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.14);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.thread-pop button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.thread-pop button svg { width: 15px; height: 15px; flex: none; }
.thread-pop button:hover { background: var(--surface-2); color: var(--ink); }
.thread-pop button.danger { color: #bd5b5b; }
.thread-pop button.danger:hover { background: #fdf0f0; color: #a63d3d; }

.thread-new {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}
.thread-new svg { width: 15px; height: 15px; }
.thread-new:hover { background: var(--surface-2); color: var(--brand); }

.nav-auto svg { color: var(--accent); }

.sidebar-foot { margin-top: auto; display: grid; gap: 12px; }

.safe-badge {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.safe-badge svg { width: 16px; height: 16px; color: var(--green-500); margin-top: 1px; }
.safe-badge strong { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink); }
.safe-badge span { font-size: 11.5px; color: var(--muted); line-height: 1.35; display: block; }

.reset-link {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px;
  border-radius: 6px;
}

.reset-link:hover { color: var(--red); background: #fef2f2; }

/* ============================= CONTENT ============================= */

.content { min-width: 0; min-height: 0; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 28px 0;
}

.topbar h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.view-sub { margin: 3px 0 0; color: var(--muted); font-size: 13px; }

.topbar-actions { display: flex; gap: 10px; }

.views { padding: 22px 28px 36px; display: grid; flex: 1; min-height: 0; overflow-y: auto; }
.views:has(#view-agent.active) { overflow: hidden; padding-bottom: 22px; }

.view { display: none; gap: 18px; }
.view.active { display: grid; align-content: start; }
#view-agent.active { height: 100%; min-height: 0; }

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 13.5px;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.button svg { width: 16px; height: 16px; }

.button:hover { background: #f8fafc; border-color: #cbd5e1; }

.button.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(27, 27, 26, 0.14);
}

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

.button.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.button.ghost:hover { background: #f1f5f9; border-color: transparent; }

.button.small { min-height: 32px; padding: 0 11px; font-size: 12.5px; }

.button:disabled { opacity: 0.5; cursor: default; }

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}

.icon-button svg { width: 16px; height: 16px; }
.icon-button:hover { background: #f1f5f9; color: var(--ink); }

/* ============================= KPI ============================= */

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  display: grid;
  gap: 10px;
  transition: box-shadow 0.15s;
}

.kpi:hover { box-shadow: var(--shadow-md); }

.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.kpi-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.kpi-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
}

.kpi-icon svg { width: 17px; height: 17px; }

.kpi-value {
  font-family: var(--display);
  font-size: 29px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.05;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-sub { color: var(--muted); font-size: 12px; }

.tint-brand { background: var(--brand-soft); color: var(--accent); }
.tint-green { background: #ecfdf3; color: var(--green); }
.tint-amber { background: #fffaeb; color: var(--amber); }
.tint-red { background: #fef3f2; color: var(--red); }
.tint-violet { background: #f4f3ff; color: #6941c6; }
.tint-teal { background: #effefb; color: #107569; }
.tint-blue { background: #eff8ff; color: #1849a9; }
.tint-gray { background: #f1f5f9; color: var(--ink-soft); }

/* ============================= OVERVIEW (welcome) ============================= */

#view-overview { gap: 20px; max-width: 940px; }

.ov-hero { display: flex; align-items: center; gap: 16px; padding: 4px 2px; }
.ov-hero-av {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--grad);
  color: #fff;
  font-size: 19px;
  font-weight: 700;
  flex: none;
  box-shadow: var(--shadow-sm);
}
.ov-hero-text h2 { margin: 0; font-family: var(--display); font-size: 28px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
.ov-hero-text p { margin: 3px 0 0; color: var(--muted); font-size: 14px; }

.ov-card { padding: 0; overflow: hidden; }
.ov-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.ov-card-title { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 700; color: var(--ink); }
.ov-card-title svg { width: 17px; height: 17px; color: var(--muted); }

.ov-period { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 999px; }
.ov-period button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 13px;
  border-radius: 999px;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.ov-period button.active { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }

.ov-tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}
.ov-tile { background: var(--surface); padding: 16px 18px; display: grid; gap: 7px; align-content: start; }
.ov-tile-label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.ov-tile-value { font-size: 25px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); line-height: 1.05; }
.ov-tile.t-brand .ov-tile-value { color: var(--brand); }
.ov-tile.t-green .ov-tile-value { color: var(--green); }
.ov-tile.t-amber .ov-tile-value { color: var(--amber); }
.ov-tile.t-violet .ov-tile-value { color: #6941c6; }
.ov-tile.t-blue .ov-tile-value { color: #1849a9; }

.ov-activity { padding: 18px; border-top: 1px solid var(--line); }
.ov-activity-h { display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.ov-activity-h svg { width: 15px; height: 15px; }
.ov-heat { display: grid; grid-template-columns: repeat(18, 20px); gap: 4px; justify-content: start; }
.ov-heat .heat-c { width: 20px; height: 20px; border-radius: 4px; }
.ov-legend { display: flex; align-items: center; gap: 4px; margin-top: 12px; font-size: 11px; color: var(--muted); }
.ov-legend .heat-c { width: 12px; height: 12px; border-radius: 3px; }

.ov-insight {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 18px 18px;
  padding: 12px 14px;
  background: var(--brand-soft);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--brand-dark);
}
.ov-insight::before { content: "⚡"; font-size: 15px; }

.ov-cta { display: flex; gap: 10px; flex-wrap: wrap; }
.ov-cta .button { min-height: 44px; padding: 0 18px; }

/* ---- goal ---- */
.ov-goal:empty { display: none; }
.ov-goal-card, .ov-goal-empty, .ov-goal-form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
}
.ov-goal-empty { display: flex; align-items: center; gap: 13px; }
.ov-goal-empty .ov-goal-ic { font-size: 22px; flex: none; }
.ov-goal-empty strong { display: block; font-size: 14px; color: var(--ink); }
.ov-goal-empty span { font-size: 12.5px; color: var(--muted); }
.ov-goal-empty .button { margin-left: auto; flex: none; }

.ov-goal-top { display: flex; align-items: center; gap: 11px; margin-bottom: 11px; }
.ov-goal-ic { font-size: 18px; flex: none; }
.ov-goal-h { display: grid; line-height: 1.25; min-width: 0; }
.ov-goal-h strong { font-size: 14px; font-weight: 700; color: var(--ink); }
.ov-goal-dl { font-size: 11.5px; color: var(--muted); }
.ov-goal-pct { margin-left: auto; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; color: var(--brand); }
.ov-goal-edit { border: 0; background: transparent; color: var(--muted); padding: 4px; border-radius: 6px; display: grid; place-items: center; }
.ov-goal-edit svg { width: 15px; height: 15px; }
.ov-goal-edit:hover { background: var(--surface-2); color: var(--brand); }
.ov-goal-bar { height: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.ov-goal-bar span { display: block; height: 100%; background: var(--grad); border-radius: 999px; min-width: 8px; transition: width 0.4s cubic-bezier(0.2, 0.7, 0.2, 1); }
.ov-goal-nums { margin-top: 9px; font-size: 13px; font-weight: 700; color: var(--ink); }
.ov-goal-nums em { font-style: normal; color: var(--muted); font-weight: 600; }

.ov-goal-form { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.ov-goal-types { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 999px; }
.ov-gt { border: 0; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 600; padding: 6px 13px; border-radius: 999px; }
.ov-gt.active { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.ov-goal-input { border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px; font-size: 13px; background: var(--surface); min-width: 0; }
.ov-goal-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
#goalTarget { flex: 1; min-width: 120px; }
.ov-goal-date { width: 160px; color: var(--ink-soft); }
.ov-goal-form .button { flex: none; }
.ov-goal-clear { border: 0; background: transparent; color: var(--muted); font-size: 12px; font-weight: 600; padding: 6px; }
.ov-goal-clear:hover { color: var(--red); }

/* ============================= KALENDARZ ============================= */
#view-kalendarz { max-width: 1120px; }
.cal-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 344px; gap: 18px; align-items: start; }
.cal-card { padding: 16px 18px 18px; }
.cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.cal-title { font-size: 17px; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; text-transform: capitalize; }
.cal-nav { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft); font-size: 18px; line-height: 1; display: grid; place-items: center; }
.cal-nav:hover { background: var(--surface-2); }
.cal-head .button.small { margin-left: auto; }
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; }
.cal-dow span { text-align: center; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-cell {
  aspect-ratio: 1 / 0.9;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  padding: 6px 7px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.cal-cell.empty { border: 0; background: transparent; cursor: default; }
.cal-cell:not(.empty):hover { background: var(--surface-2); }
.cal-cell.today { border-color: var(--brand); }
.cal-cell.selected { box-shadow: 0 0 0 2px var(--brand); border-color: var(--brand); }
.cal-cell-d { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.cal-cell.today .cal-cell-d { color: var(--brand); font-weight: 700; }
.cal-cell-dots { display: flex; flex-wrap: wrap; gap: 3px; margin-top: auto; }
.cal-dot { width: 7px; height: 7px; border-radius: 999px; display: inline-block; flex: none; }
.d-automat { background: var(--brand); }
.d-activity { background: var(--green-500); }
.d-task { background: var(--amber); }
.cal-legend { display: flex; gap: 16px; margin-top: 14px; font-size: 11.5px; color: var(--muted); }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }

.cal-day { padding: 15px 16px; position: sticky; top: 0; display: grid; gap: 10px; align-content: start; }
.cal-day-h { font-size: 14px; font-weight: 700; color: var(--ink); text-transform: capitalize; }
.cal-day-empty { color: var(--muted); font-size: 12.5px; padding: 6px 0 2px; }
.cal-item { display: grid; gap: 8px; padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.cal-item-top { display: flex; align-items: flex-start; gap: 9px; }
.cal-item-ic { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; flex: none; }
.cal-item-ic svg { width: 14px; height: 14px; }
.cal-item-t { min-width: 0; flex: 1; display: grid; line-height: 1.3; }
.cal-item-t strong { font-size: 12.5px; font-weight: 600; }
.cal-item-t small { font-size: 11px; color: var(--muted); font-weight: 400; }
.cal-item.done .cal-item-t strong { text-decoration: line-through; color: var(--muted); }
.cal-badge { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 3px 7px; border-radius: 999px; align-self: flex-start; white-space: nowrap; }
.cal-badge.b-automat { background: var(--brand-soft); color: var(--brand-dark); }
.cal-badge.b-activity { background: #ecfdf3; color: var(--green); }
.cal-badge.b-task { background: #fffaeb; color: var(--amber); }
.cal-item-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cal-mini { border: 1px solid var(--line); background: var(--surface); border-radius: 7px; padding: 4px 9px; font-size: 11.5px; font-weight: 600; color: var(--ink-soft); }
.cal-mini:hover { background: var(--surface); border-color: var(--line-strong); }
.cal-mini.danger:hover { color: var(--red); border-color: var(--red); }
.cal-mini.go:hover { color: var(--brand); border-color: var(--brand); }
.cal-date-input { border: 1px solid var(--line); border-radius: 7px; padding: 4px 7px; font-size: 11px; color: var(--ink-soft); background: var(--surface); font-family: inherit; }
.cal-task-check { width: 16px; height: 16px; accent-color: var(--brand); flex: none; margin-top: 4px; cursor: pointer; }
.cal-addtask { display: flex; gap: 7px; margin-top: 4px; }
.cal-addtask input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; background: var(--surface); }
.cal-addtask input:focus { outline: none; border-color: var(--brand); }

.ctx-settle {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 7px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  color: var(--muted);
  flex: none;
}
.ctx-settle:hover { background: #ecfdf3; border-color: var(--green-500); color: var(--green); }
.ctx-settle svg { width: 14px; height: 14px; }

.drawer-meta { margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.rodo-row { display: flex; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.rodo-del:hover { color: var(--red); border-color: var(--red); }

.smtp-form { display: grid; gap: 9px; }
.smtp-form input { border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; font-size: 13px; background: var(--surface); }
.smtp-form input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.smtp-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 2px; }
.smtp-hint { font-size: 11.5px; color: var(--muted); }
#smtpStatus.on { background: #ecfdf3; color: var(--green); }
#smtpStatus.off { background: var(--surface-2); color: var(--muted); }

/* ============================= CARD ============================= */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.card-head h2 { margin: 0; font-family: var(--display); font-size: 16px; font-weight: 600; letter-spacing: -0.015em; }
.card-sub { margin: 1px 0 0; color: var(--muted); font-size: 12.5px; }

/* ============================= PIPELINE ============================= */

.pipeline {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0;
  padding: 16px 14px;
}

.pipe-stage {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 14px 6px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: center;
  transition: background 0.15s;
}

.pipe-stage:hover { background: #f8fafc; }
.pipe-stage.empty { opacity: 0.45; }
.pipe-stage.empty:hover { opacity: 0.85; }

.pipe-stage::after {
  content: "";
  position: absolute;
  right: -7px;
  top: 32px;
  width: 13px;
  height: 13px;
  border-top: 1.5px solid var(--line-strong);
  border-right: 1.5px solid var(--line-strong);
  transform: rotate(45deg) scale(0.7);
}

.pipe-stage:last-child::after { display: none; }

.pipe-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 11px;
}

.pipe-icon svg { width: 19px; height: 19px; }

.pipe-count { font-size: 19px; font-weight: 600; letter-spacing: -0.015em; line-height: 1; }

.pipe-label { font-size: 11.5px; font-weight: 600; color: var(--muted); line-height: 1.25; }

/* ============================= PULPIT GRID ============================= */

.pulpit-grid {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 18px;
  align-items: start;
}

.todo-list { display: grid; }

.todo-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 20px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background 0.12s;
}

.todo-item:last-child { border-bottom: 0; }
.todo-item:hover { background: #f8fafc; }

.todo-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  flex: none;
}

.todo-icon svg { width: 17px; height: 17px; }

.todo-text { min-width: 0; display: grid; line-height: 1.35; }
.todo-text strong { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.todo-text span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.todo-meta { margin-left: auto; text-align: right; display: grid; line-height: 1.35; }
.todo-meta strong { font-size: 14px; font-weight: 700; white-space: nowrap; }
.todo-meta span { color: var(--muted); font-size: 11.5px; white-space: nowrap; }

/* ============================= EMPTY STATE ============================= */

.empty-state {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 44px 20px;
  text-align: center;
}

.empty-state svg { width: 34px; height: 34px; color: var(--line-strong); margin-bottom: 4px; }
.empty-state strong { font-size: 14px; font-weight: 600; color: var(--ink); }
.empty-state span { color: var(--muted); font-size: 12.5px; max-width: 360px; }

/* ============================= TABLE ============================= */

.table-card { display: grid; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 12.5px;
  padding: 6px 13px;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.chip:hover { background: #f8fafc; border-color: #cbd5e1; }

.chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
  font-weight: 700;
}

.toolbar-right { display: flex; gap: 10px; align-items: center; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0 11px;
  min-height: 38px;
  width: 230px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.search-box svg { width: 15px; height: 15px; color: var(--muted); }

.search-box input {
  border: 0;
  outline: 0;
  background: transparent;
  width: 100%;
  font-size: 13px;
}

.select {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
}

.stage-filter-note {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  background: var(--brand-soft);
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}

.stage-filter-note button {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  font-size: 12.5px;
  text-decoration: underline;
  padding: 0;
}

.table-wrap { overflow: auto; }

table { width: 100%; border-collapse: collapse; }

th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

th:first-child, td:first-child { padding-left: 20px; }
th:last-child, td:last-child { padding-right: 20px; }

th.num, td.num { text-align: right; }

tbody tr { transition: background 0.12s; }
tbody tr:hover { background: #f8fafc; cursor: pointer; }
tbody tr:last-child td { border-bottom: 0; }

.check-cell { width: 44px; }
.check-cell input, #selectAll { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }

.arrow-cell { width: 40px; }
.arrow-cell svg { width: 16px; height: 16px; color: var(--line-strong); }

tbody tr:hover .arrow-cell svg { color: var(--muted); }

.debtor-cell { display: flex; align-items: center; gap: 11px; min-width: 0; }

.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
  flex: none;
}

.debtor-text { min-width: 0; display: grid; line-height: 1.3; }
.debtor-text strong { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.debtor-text span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.amount-cell { font-weight: 700; font-size: 14px; white-space: nowrap; }

.days-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 12.5px;
  white-space: nowrap;
}

.days-dot { width: 8px; height: 8px; border-radius: 999px; }

.days-ok .days-dot { background: #98a2b3; }
.days-warn .days-dot { background: #f79009; }
.days-late .days-dot { background: #f04438; }
.days-ok { color: var(--muted); }
.days-warn { color: var(--amber); }
.days-late { color: var(--red); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 25px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.tag svg { width: 13px; height: 13px; }

.empty-row { color: var(--muted); text-align: center; padding: 44px 16px; }

/* progress */

.progress { display: flex; align-items: center; gap: 8px; min-width: 110px; }

.progress-track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: #e9e7e1;
  overflow: hidden;
  display: block;
}

.progress-fill {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.progress em {
  font-style: normal;
  font-weight: 600;
  font-size: 12px;
  min-width: 34px;
  text-align: right;
  color: var(--ink-soft);
}

/* schedule (harmonogram) */

.sched-progress { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.sched-progress .progress { max-width: 200px; flex: 1; }

.schedule { display: grid; }

.sched-item {
  position: relative;
  display: flex;
  gap: 13px;
  padding: 0 0 16px 0;
}

.sched-item::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 22px;
  bottom: -2px;
  width: 0;
  border-left: 1.5px solid var(--line);
}

.sched-item:last-child::before { display: none; }
.sched-item:last-child { padding-bottom: 0; }

.sched-dot {
  width: 17px;
  height: 17px;
  border-radius: 999px;
  border: 2px solid var(--line-strong);
  background: var(--surface);
  flex: none;
  margin-top: 3px;
  z-index: 1;
}

.sched-item.wykonane .sched-dot, .sched-item.zakonczone .sched-dot { background: var(--green-500); border-color: var(--green-500); }
.sched-item.nastepny .sched-dot { background: var(--brand); border-color: var(--brand); }
.sched-item.wstrzymane .sched-dot { background: #f79009; border-color: #f79009; }

.sched-item.zaplanowane { opacity: 0.75; }

.sched-main { min-width: 0; flex: 1; display: grid; gap: 5px; }

.sched-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sched-head strong { font-size: 13.5px; font-weight: 600; }

.sched-meta { color: var(--muted); font-size: 12px; }

.sched-previews { display: flex; gap: 7px; flex-wrap: wrap; }

.mini-toggle {
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  padding: 4px 9px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-soft);
  transition: background 0.12s, border-color 0.12s;
}

.mini-toggle:hover { background: #f8fafc; border-color: #cbd5e1; }
.mini-toggle.open { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

.msg-preview {
  margin: 0;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #f8fafc;
  font: 12px/1.55 ui-monospace, "SF Mono", Menlo, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--ink-soft);
}

.selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--brand-soft);
  border-radius: 0 0 var(--radius) var(--radius);
}

.selection-bar > span { font-weight: 600; font-size: 13px; color: var(--ink); }

.selection-actions { display: flex; gap: 10px; }

/* ============================= BATCHES ============================= */

.batch-list { display: grid; }

.batch-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

.batch-list .batch-item:last-child { border-bottom: 0; }

.batch-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: #fffaeb;
  color: var(--amber);
}

.batch-icon svg { width: 18px; height: 18px; }

.batch-text { min-width: 0; display: grid; line-height: 1.35; }
.batch-text strong { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-text span { color: var(--muted); font-size: 12px; }

.batch-links { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.batch-links a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 5px 11px;
  color: var(--ink-soft);
  background: var(--surface);
  font-weight: 600;
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}

.batch-links a:hover { background: #f8fafc; border-color: #cbd5e1; }
.batch-links a svg { width: 13px; height: 13px; }

/* ============================= OVERLAY / DRAWER / MODAL ============================= */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.45);
  backdrop-filter: blur(2px);
  z-index: 50;
  display: flex;
  justify-content: flex-end;
}

.overlay.center { align-items: center; justify-content: center; padding: 20px; }

.drawer {
  width: min(470px, 100%);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  animation: slideIn 0.22s ease;
}

@keyframes slideIn {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.drawer-body { padding: 24px; display: grid; gap: 18px; align-content: start; }

.drawer-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }

.drawer-title { display: grid; gap: 3px; }
.drawer-title h2 { margin: 0; font-family: var(--display); font-size: 20px; font-weight: 600; letter-spacing: -0.015em; letter-spacing: -0.01em; }
.drawer-title span { color: var(--muted); font-size: 12.5px; }

.drawer-amount { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.drawer-amount strong { font-family: var(--display); font-size: 32px; font-weight: 500; letter-spacing: -0.01em; }

.next-action {
  display: flex;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

.next-action.ok { background: var(--brand-soft); border-color: #cdddfd; }
.next-action.blocked { background: #fef3f2; border-color: #fecdca; }
.next-action.idle { background: #f8fafc; }

.next-action .todo-icon { background: var(--surface); }

.next-action-text { display: grid; gap: 1px; line-height: 1.4; }
.next-action-text small { color: var(--muted); font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.next-action-text strong { font-size: 14px; font-weight: 600; }
.next-action-text span { font-size: 12.5px; color: var(--muted); }
.next-action-text .warn { color: var(--red); font-weight: 600; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

.field {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: #f8fafc;
  min-width: 0;
}

.field.full { grid-column: 1 / -1; }

.field span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field strong { display: block; margin-top: 2px; font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.field a { color: var(--accent); }

.status-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }

.pay-form { display: flex; gap: 10px; }

.pay-input {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0 12px;
  font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.pay-input:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.pay-input::placeholder { color: #98a2b3; }

.pay-cell { color: var(--muted); font-weight: 500; white-space: nowrap; }

.drawer h3 { margin: 4px 0 0; font-size: 13.5px; font-weight: 700; color: var(--ink); }

/* timeline */

.timeline { display: grid; }

.tl-item {
  position: relative;
  display: flex;
  gap: 12px;
  padding: 0 0 18px 0;
}

.tl-item::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 32px;
  bottom: 0;
  width: 0;
  border-left: 1.5px solid var(--line);
}

.tl-item:last-child::before { display: none; }
.tl-item:last-child { padding-bottom: 0; }

.tl-icon {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border-radius: 8px;
  background: #f1f5f9;
  color: var(--ink-soft);
  flex: none;
  z-index: 1;
}

.tl-icon svg { width: 14px; height: 14px; }

.tl-text { display: grid; gap: 1px; line-height: 1.4; padding-top: 5px; }
.tl-text strong { font-size: 13px; font-weight: 600; }
.tl-text span { color: var(--muted); font-size: 12.5px; }
.tl-text time { color: #98a2b3; font-size: 11.5px; }

/* modal */

.modal {
  width: min(480px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 22px;
  display: grid;
  gap: 16px;
  animation: pop 0.18s ease;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.modal.wide { width: min(660px, 100%); }

@keyframes pop {
  from { transform: scale(0.98); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal-head h2 { margin: 0; font-family: var(--display); font-size: 18px; font-weight: 600; letter-spacing: -0.015em; }

.dropzone {
  display: grid;
  justify-items: center;
  gap: 7px;
  padding: 30px 18px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: #f8fafc;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.dropzone:hover, .dropzone.drag { background: var(--brand-soft); border-color: var(--brand); }

.dropzone input { position: absolute; width: 0; height: 0; opacity: 0; }
.dropzone svg { width: 28px; height: 28px; color: var(--accent); }
.dropzone strong { font-size: 14px; font-weight: 600; }
.dropzone span { color: var(--muted); font-size: 12px; max-width: 340px; }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

.message { min-height: 18px; color: var(--muted); font-size: 12.5px; }
.message.error { color: var(--red); font-weight: 600; }

/* preview modal */

.preview-summary { display: flex; gap: 8px; flex-wrap: wrap; }

.preview-list { display: grid; gap: 8px; max-height: 50vh; overflow-y: auto; padding: 2px; }

.preview-item {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  background: #f8fafc;
}

.preview-item.blocked { background: #fef3f2; border-color: #fecdca; }

.preview-text { min-width: 0; display: grid; line-height: 1.35; }
.preview-text strong { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-text span { color: var(--muted); font-size: 12px; }
.preview-text .warn { color: var(--red); font-weight: 600; }

.preview-meta { margin-left: auto; text-align: right; display: grid; line-height: 1.35; }
.preview-meta strong { font-size: 13.5px; font-weight: 700; white-space: nowrap; }
.preview-meta span { color: var(--muted); font-size: 11.5px; white-space: nowrap; }

/* ============================= USTAWIENIA ============================= */

.ustawienia-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 18px;
  align-items: start;
}

.plan-body { padding: 18px 20px; display: grid; gap: 12px; }

.plan-price { font-family: var(--display); font-size: 34px; font-weight: 500; letter-spacing: -0.01em; }
.plan-price span { font-family: var(--font); font-size: 14px; color: var(--muted); font-weight: 500; }

.plan-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 7px; }

.plan-list li {
  position: relative;
  padding-left: 24px;
  font-size: 13px;
  color: var(--ink-soft);
}

.plan-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: -1px;
  font-weight: 700;
  color: var(--green-500);
}

.credits-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 16px 20px;
}

.credit-card {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 16px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
  text-align: center;
}

.credit-saldo { font-family: var(--display); font-size: 29px; font-weight: 500; letter-spacing: -0.01em; line-height: 1; }
.credit-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.credit-card .button { width: 100%; }

.integration-list { display: grid; }

.integration-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.integration-list .integration-row:last-child { border-bottom: 0; }

.integration-info { display: grid; line-height: 1.35; min-width: 220px; flex: 1; }
.integration-info strong { font-size: 13.5px; font-weight: 600; }
.integration-info span { color: var(--muted); font-size: 12px; }

.integration-row .int-key { flex: 1; min-width: 180px; max-width: 300px; }

.credit-warn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--red);
  font-size: 12.5px;
  font-weight: 600;
}

.credit-warn svg { width: 14px; height: 14px; }

.link-button {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--accent);
  font-weight: 600;
  font-size: 12.5px;
  text-decoration: underline;
}

/* ============================= AUTH ============================= */

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--bg);
  overflow-y: auto;
}

.auth-card {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 28px;
  display: grid;
  gap: 18px;
}

.auth-brand { padding: 0 0 4px; }
.auth-brand .brand-text strong { color: var(--ink); }
.auth-brand .brand-text span { color: var(--muted); }

.auth-form { display: grid; gap: 13px; }
.auth-form h2 { margin: 0; font-family: var(--display); font-size: 22px; font-weight: 600; letter-spacing: -0.015em; }

.auth-field { display: grid; gap: 5px; }
.auth-field > span {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

.auth-nip-row { display: flex; gap: 8px; }
.auth-nip-row .pay-input { flex: 1; }

.auth-consent {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.45;
  cursor: pointer;
}

.auth-consent input {
  width: 16px;
  height: 16px;
  margin-top: 1px;
  accent-color: var(--brand);
  flex: none;
}

.auth-switch { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); text-align: center; }

/* ============================= USER BOX ============================= */

.user-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.user-info { min-width: 0; display: grid; line-height: 1.3; flex: 1; }
.user-info strong { color: var(--ink); font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-info span { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.user-box .button { min-height: 28px; padding: 0 10px; font-size: 11.5px; }

/* ============================= API KEYS ============================= */

.new-key-box {
  margin: 16px 20px 0;
  padding: 12px 14px;
  border: 1px solid #cdddfd;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
}

.new-key-box code {
  display: block;
  margin-top: 6px;
  font: 12px/1.5 ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--ink);
  overflow-wrap: anywhere;
  user-select: all;
}

.api-example { margin: 16px 20px 20px; }

/* ============================= ASYSTENT (floating mini chat) ============================= */

.chat-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 54px;
  height: 54px;
  border-radius: 999px;
  border: 0;
  background: var(--brand);
  color: var(--brand-ink);
  display: grid;
  place-items: center;
  box-shadow: 0 8px 20px rgba(201, 100, 66, 0.35);
  z-index: 60;
  transition: background 0.15s, transform 0.1s;
}

.chat-fab svg { width: 23px; height: 23px; }
.chat-fab:hover { background: var(--brand-dark); transform: translateY(-1px); }

.chat-panel {
  position: fixed;
  right: 22px;
  bottom: 88px;
  width: min(380px, calc(100vw - 44px));
  max-height: min(560px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 60;
  animation: pop 0.18s ease;
  overflow: hidden;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.chat-title { display: grid; line-height: 1.25; }
.chat-title strong { font-size: 14.5px; font-weight: 700; }
.chat-title span { font-size: 11.5px; color: var(--muted); }

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 180px;
}

.chat-msg {
  max-width: 85%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-msg.user {
  justify-self: end;
  background: var(--ink);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg.bot {
  justify-self: start;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  border-bottom-left-radius: 4px;
}

.chat-suggests {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 0 14px 10px;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: #f8fafc;
}

/* ============================= AGENT VIEW ============================= */

.agent-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  gap: 18px;
  height: 100%;
  min-height: 0;
  align-items: stretch;
}

.agent-main {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 8px 14px 14px;
}

.agent-main-top { display: none; }

.agent-context {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ctx-card {
  flex: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.ctx-head {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.ctx-head .feed-dot { margin-left: auto; }

.ctx-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); }
.ctx-stat { background: var(--surface); padding: 13px 14px; display: grid; gap: 3px; }
.ctx-stat.wide { grid-column: 1 / -1; }
.ctx-stat span { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.ctx-stat strong { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
.ctx-stat.wide.accent strong { font-size: 25px; }
.ctx-stat.accent strong { color: var(--ink); }

.ctx-pipe { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; padding: 14px 15px; }
.ctx-pipe-cell { display: grid; justify-items: center; gap: 5px; padding: 9px 2px; border-radius: 9px; border: 1px solid transparent; transition: background 0.12s, border-color 0.12s; }
.ctx-pipe-cell.on { background: var(--surface-2); border-color: var(--line); cursor: pointer; }
.ctx-pipe-cell.on:hover { background: var(--brand-soft); border-color: var(--brand-soft); }
.ctx-pipe-cell.zero { opacity: 0.5; }
.ctx-pipe-cell.zero b { color: var(--muted); }

.ctx-stat-ic { display: inline-flex; vertical-align: -2px; margin-right: 5px; color: var(--brand); }
.ctx-stat-ic svg { width: 13px; height: 13px; }
.ctx-stat.accent strong.grad {
  color: var(--brand-dark);
}

.ctx-empty-fun {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 6px;
  padding: 22px 16px;
}
.ctx-empty-fun.small { padding: 16px 14px; }
.ctx-empty-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; }
.ctx-empty-ic svg { width: 18px; height: 18px; }
.ctx-empty-fun strong { font-size: 13px; font-weight: 600; color: var(--ink); }
.ctx-empty-fun span { font-size: 11.5px; color: var(--muted); max-width: 240px; line-height: 1.45; }
.ctx-empty-actions { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; justify-content: center; }
.ctx-mini-btn {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 8px;
  padding: 5px 11px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-soft);
  transition: background 0.12s, border-color 0.12s;
}
.ctx-mini-btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.ctx-mini-btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.ctx-mini-btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.ctx-pipe-cell .pi { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: var(--surface-2); color: var(--muted); }
.ctx-pipe-cell .pi svg { width: 14px; height: 14px; }
.ctx-pipe-cell.on .pi { background: var(--brand-soft); color: var(--brand-dark); }
.ctx-pipe-cell b { font-size: 14px; font-weight: 700; }
.ctx-pipe-cell em { font-style: normal; font-size: 9px; color: var(--muted); text-align: center; line-height: 1.15; }

.ctx-list { padding: 6px 0 8px; }
.ctx-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%; border: 0; background: transparent; text-align: left;
  padding: 8px 14px; transition: background 0.12s;
}
.ctx-row:hover { background: var(--surface-2); cursor: pointer; }
.ctx-ic { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; flex: none; background: var(--surface-2); color: var(--ink-soft); }
.ctx-ic svg { width: 14px; height: 14px; }
.ctx-rtext { min-width: 0; display: grid; line-height: 1.3; flex: 1; }
.ctx-rtext strong { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-rtext span { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-ramt { font-size: 12px; font-weight: 700; white-space: nowrap; }
.ctx-rtime { font-size: 10.5px; color: var(--muted); white-space: nowrap; padding-top: 2px; }
.ctx-empty { padding: 14px; color: var(--muted); font-size: 12px; }

.feed-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  padding: 6px 12px 6px 11px;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--ink-soft);
  box-shadow: var(--shadow-sm);
  transition: background 0.12s, border-color 0.12s;
}

.feed-toggle:hover { background: #f8fafc; border-color: #cbd5e1; }

.feed-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--green-500);
  animation: feedpulse 1.8s ease-in-out infinite;
}

@keyframes feedpulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.feed-count {
  min-width: 20px;
  text-align: center;
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
}

.agent-log {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  padding: 8px 4px 16px;
  display: grid;
  gap: 16px;
  align-content: start;
}

.agent-log .chat-msg {
  max-width: 86%;
  font-size: 14px;
  line-height: 1.55;
  padding: 12px 15px;
}

.agent-log .chat-msg.has-wide { max-width: 100%; width: 100%; }

.chat-msg.thinking { color: var(--muted); letter-spacing: 2px; }

/* ---- rich agent blocks ---- */
.msg-text + .msg-blocks { margin-top: 10px; }
.msg-blocks { display: grid; gap: 10px; }
.blk { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); overflow: hidden; }

.blk-timeline { padding: 4px 0; background: var(--surface); }
.blk-tl { display: flex; gap: 10px; padding: 7px 12px; }
.blk-tl-ic { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; flex: none; }
.blk-tl-ic svg { width: 14px; height: 14px; }
.blk-tl-t { min-width: 0; display: grid; line-height: 1.35; }
.blk-tl-t strong { font-size: 12.5px; font-weight: 600; }
.blk-tl-t span { font-size: 12px; color: var(--muted); }
.blk-tl-t time { font-size: 11px; color: var(--muted); opacity: 0.8; }

.blk-steps { padding: 4px 0; background: var(--surface); }
.blk-step { display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.blk-step-n { width: 20px; height: 20px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-dark); font-size: 11px; font-weight: 700; display: grid; place-items: center; flex: none; }
.blk-step-ic { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; flex: none; }
.blk-step-ic svg { width: 14px; height: 14px; }
.blk-step-t { min-width: 0; display: grid; line-height: 1.35; }
.blk-step-t strong { font-size: 12.5px; font-weight: 600; }
.blk-step-t span { font-size: 11.5px; color: var(--muted); }

.blk-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 0; }
.blk-stat { background: var(--surface); padding: 11px 13px; display: grid; gap: 3px; }
.blk-stat span { font-size: 11px; color: var(--muted); font-weight: 600; }
.blk-stat strong { font-size: 17px; font-weight: 700; }
.blk-stat.tint-brand strong { color: var(--brand); }
.blk-stat.tint-green strong { color: var(--green); }
.blk-stat.tint-amber strong { color: var(--amber); }

.blk-case { display: flex; align-items: center; gap: 11px; padding: 11px 13px; width: 100%; text-align: left; cursor: pointer; background: var(--surface); transition: background 0.12s; }
.blk-case:hover { background: var(--surface-2); }
.blk-case-av { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.blk-case-t { min-width: 0; display: grid; line-height: 1.35; flex: 1; }
.blk-case-t > strong { font-size: 13px; font-weight: 600; }
.blk-case-t > span { font-size: 11.5px; color: var(--muted); }
.blk-case-note { color: var(--ink-soft) !important; font-weight: 500; }
.blk-case-amt { font-size: 13px; font-weight: 700; white-space: nowrap; }

/* ---- report block (weekly activity) ---- */
.blk-report { background: var(--surface); padding: 14px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(188px, 236px); gap: 16px; align-items: start; }
.blk-rep-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(146px, 1fr)); gap: 8px; align-content: start; }
.blk-rep-tile { display: flex; align-items: center; gap: 9px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 9px 11px; }
.blk-rep-ic { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; flex: none; }
.blk-rep-ic svg { width: 15px; height: 15px; }
.blk-rep-t { display: grid; line-height: 1.25; min-width: 0; }
.blk-rep-t strong { font-size: 16px; font-weight: 700; }
.blk-rep-t span { font-size: 11px; color: var(--muted); white-space: normal; }
.blk-rep-heat-h { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.blk-rep-heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.heat-c { aspect-ratio: 1; border-radius: 3px; background: var(--line); }
.heat-0 { background: #eef1f6; }
.heat-1 { background: #c7d2fe; }
.heat-2 { background: #a5b4fc; }
.heat-3 { background: #818cf8; }
.heat-4 { background: var(--brand); }

/* ---- confirm (billing) ---- */
.blk-confirm { background: var(--brand-soft); border-color: #cdd7fb; padding: 12px 13px; display: grid; gap: 10px; }
.blk-confirm-t { display: grid; gap: 2px; }
.blk-confirm-t strong { font-size: 13px; font-weight: 600; }
.blk-confirm-t span { font-size: 12px; color: var(--ink-soft); }
.blk-confirm-t b { color: var(--brand-dark); }
.blk-confirm-actions { display: flex; gap: 8px; }
.blk-confirm.done { opacity: 0.55; }

/* ---- agent welcome hero ---- */
.agent-hero { text-align: center; padding: 36px 16px 20px; }
.agent-hero h2 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
.agent-hero p { margin: 8px 0 0; color: var(--muted); font-size: 14px; }

.agent-composer { padding-top: 10px; }

.agent-composer .chat-suggests { padding: 11px 0 2px; }

.composer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 6px 6px 6px 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.composer-row:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.agent-composer { position: relative; }

.mention-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-radius: 999px;
  padding: 4px 6px 4px 9px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}
.mention-chip svg { width: 13px; height: 13px; }
.mention-chip > span { max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
.mention-chip button { border: 0; background: transparent; color: var(--brand-dark); display: grid; place-items: center; padding: 2px; border-radius: 999px; transform: rotate(90deg); }
.mention-chip button svg { width: 13px; height: 13px; }
.mention-chip button:hover { background: rgba(79, 70, 229, 0.15); }

.mention-pop {
  position: absolute;
  left: 0;
  right: 56px;
  bottom: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 5px;
  display: grid;
  gap: 1px;
  z-index: 30;
  max-height: 260px;
  overflow-y: auto;
}
.mention-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  cursor: pointer;
}
.mention-opt:hover { background: var(--surface-2); }
.mention-opt .avatar { width: 30px; height: 30px; border-radius: 8px; font-size: 11px; }
.mention-opt-t { min-width: 0; display: grid; line-height: 1.3; }
.mention-opt-t strong { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mention-opt-t span { font-size: 11px; color: var(--muted); }

.ctx-distbar {
  display: flex;
  gap: 3px;
  height: 9px;
  margin: 14px 15px 0;
}
.ctx-distbar span { display: block; min-width: 6px; border-radius: 999px; }

/* ---- flow strip (per-case 7-stage flow) ---- */
.flow-strip { display: flex; gap: 3px; width: 100%; }
.flow-seg { height: 5px; flex: 1; border-radius: 999px; background: var(--line); }
.flow-seg.done { background: var(--brand); }
.flow-seg.now { background: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.flow-seg.future { background: var(--line); }

.blk-case-top { display: flex; align-items: center; gap: 11px; }
.blk-case { display: grid; gap: 9px; }

.drawer-flow { display: grid; gap: 5px; }
.drawer-flow-labels { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); }

/* ---- aging buckets ---- */
.ctx-age { padding: 12px 14px; display: grid; gap: 9px; }
.ctx-age-row { display: grid; grid-template-columns: 64px 1fr 22px; align-items: center; gap: 9px; }
.ctx-age-lbl { font-size: 11px; color: var(--muted); }
.ctx-age-bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.ctx-age-bar span { display: block; height: 100%; border-radius: 999px; min-width: 2px; }
.ctx-age-n { font-size: 12px; font-weight: 700; text-align: right; }
.age-green { background: #84ad94; }
.age-amber { background: #c6ab6a; }
.age-orange { background: #c4906a; }
.age-red { background: #bd7670; }

.composer-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  min-height: 42px;
  font-size: 14px;
}

.composer-input::placeholder { color: #98a2b3; }

.composer-send {
  flex: none;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: var(--brand);
  color: var(--brand-ink);
  transition: background 0.15s;
}

.composer-send svg { width: 19px; height: 19px; }
.composer-send:hover { background: var(--brand-dark); }

.feed-drawer { width: min(420px, 100%); }

.live-feed { display: grid; }
.live-feed .tl-item { padding-bottom: 16px; }

@media (max-width: 1100px) {
  .agent-workspace { grid-template-columns: 1fr; }
  .agent-context { display: none; }
  .agent-main-top { display: flex; justify-content: flex-end; padding: 2px 0 8px; }
}

@media (max-width: 860px) {
  .content { height: auto; overflow: visible; }
  .views, .views:has(#view-agent.active) { overflow-y: visible; }
  .agent-workspace { height: calc(100vh - 150px); }
  .agent-log .chat-msg { max-width: 92%; }
  .blk-report { grid-template-columns: 1fr; }
  .cal-wrap { grid-template-columns: 1fr; }
  .cal-day { position: static; }
}

/* ============================= TOAST ============================= */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  font-weight: 500;
  font-size: 13px;
  z-index: 100;
  max-width: min(480px, calc(100vw - 40px));
  animation: pop 0.18s ease;
}

.toast.error { background: var(--red); }

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

@media (max-width: 1100px) {
  .pulpit-grid { grid-template-columns: 1fr; }
  .ustawienia-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pipeline { grid-template-columns: repeat(4, minmax(0, 1fr)); row-gap: 10px; }
  .pipe-stage:nth-child(4)::after { display: none; }
}

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }

  .sidebar {
    min-width: 0;
    position: sticky;
    top: 0;
    z-index: 40;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
  }

  .brand { padding: 0; }
  .brand-text { display: none; }

  .nav { display: flex; flex: 1; gap: 4px; overflow-x: auto; min-width: 0; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-item { width: auto; padding: 8px 11px; white-space: nowrap; }
  .nav-item svg { display: none; }

  .sidebar-foot { margin: 0; display: flex; align-items: center; gap: 8px; }
  .safe-badge { display: none; }
  .reset-link { display: none; }
  .user-box { padding: 4px 6px; border: 0; background: transparent; }
  .user-info { display: none; }

  .topbar { padding: 18px 16px 0; flex-wrap: wrap; }
  .views { padding: 16px 16px 26px; }

  .toolbar-right { width: 100%; }
  .search-box { flex: 1; width: auto; }

  th:nth-child(4), td:nth-child(4),
  th:nth-child(5), td:nth-child(5),
  th:nth-child(6), td:nth-child(6),
  th:nth-child(8), td:nth-child(8) { display: none; }

  td:nth-child(2) { min-width: 200px; }

  .field-grid, .status-buttons { grid-template-columns: 1fr; }

  .kpi-value { font-size: 19px; }
  .kpi { padding: 14px; gap: 7px; }

  .pipeline { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .pipe-stage::after { display: none; }

  .drawer { width: 100%; }

  .batch-item { flex-wrap: wrap; }
  .batch-links { margin-left: 51px; justify-content: flex-start; }
}

/* ===================== OPERACJE (control center) ===================== */
.ops-root { display: flex; flex-direction: column; gap: 16px; }
.ops-loading, .ops-empty, .ops-empty-s { color: var(--muted); padding: 22px; font-size: 14px; }
.ops-empty { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.ops-empty strong { color: var(--ink); }
.ops-empty p { margin: 6px 0 0; }

.nav-dot-live { width: 7px; height: 7px; border-radius: 50%; background: #34c759; margin-left: auto; animation: opspulse 2.2s infinite; }
@keyframes opspulse { 0% { box-shadow: 0 0 0 0 rgba(52,199,89,.5); } 70% { box-shadow: 0 0 0 5px rgba(52,199,89,0); } 100% { box-shadow: 0 0 0 0 rgba(52,199,89,0); } }

.ops-banner { display: flex; justify-content: space-between; align-items: center; gap: 12px 16px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; }
.ops-banner-l { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ops-live-pill { color: #2f7d4f; font-weight: 600; font-size: 12px; background: #e7f5ec; padding: 3px 10px; border-radius: 999px; white-space: nowrap; flex: none; }
.ops-banner-txt { font-size: 13px; color: var(--ink-soft); }
.ops-banner-r { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ops-gen { font-size: 12px; color: var(--muted); }
.button.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink-soft); }
.button.ghost[disabled] { opacity: .5; cursor: not-allowed; }

.ops-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.ops-kpi { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.ops-kpi-ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.ops-kpi-ic svg { width: 18px; height: 18px; }
.ops-kpi strong { display: block; font-size: 19px; line-height: 1.15; color: var(--ink); }
.ops-kpi div span { font-size: 12px; color: var(--muted); }

.ops-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.ops-card { padding: 16px; }
.ops-card-h { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; font-size: 14px; margin-bottom: 12px; color: var(--ink); }
.ops-card-h span { font-weight: 500; font-size: 12px; color: var(--muted); }

.ops-funnel { display: flex; align-items: stretch; gap: 6px; flex-wrap: wrap; }
.ops-stage { flex: 1 1 120px; min-width: 120px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.ops-stage.has-pending { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand-soft); }
.ops-stage-ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; }
.ops-stage-ic svg { width: 16px; height: 16px; }
.ops-stage-meta strong { display: block; font-size: 13px; color: var(--ink); }
.ops-stage-meta span { font-size: 11px; color: var(--muted); }
.ops-stage-nums { margin-top: auto; }
.ops-stage-pending { font-size: 22px; font-weight: 700; color: var(--ink); display: block; line-height: 1; }
.ops-stage-cum { font-size: 11px; color: var(--muted); }
.ops-stage-arrow { align-self: center; color: var(--line-strong); font-size: 14px; }

.ops-sched { display: flex; flex-direction: column; }
.ops-sched-row { display: grid; grid-template-columns: 92px 1fr auto; gap: 10px; align-items: center; padding: 9px 4px; border-bottom: 1px solid var(--line); font-size: 13px; }
.ops-sched-row:last-child { border-bottom: 0; }
.ops-sched-when { font-weight: 600; color: var(--brand-dark); white-space: nowrap; }
.ops-sched-label { color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ops-sched-tz { font-size: 11px; color: var(--muted); white-space: nowrap; }

.ops-feed-card { min-height: 0; }
.ops-feed { display: flex; flex-direction: column; gap: 8px; max-height: 440px; overflow-y: auto; }
.ops-run { display: flex; gap: 10px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.ops-run-mode { font-size: 10px; font-weight: 700; letter-spacing: .04em; padding: 3px 7px; border-radius: 5px; height: fit-content; flex: none; }
.ops-run-mode.live { background: #e7f5ec; color: #2f7d4f; }
.ops-run-mode.dry { background: var(--surface-2); color: var(--muted); }
.ops-run-main { flex: 1; min-width: 0; }
.ops-run-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--ink); }
.ops-run-when { color: var(--muted); font-size: 11px; white-space: nowrap; }
.ops-run-bot { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; align-items: center; font-size: 11px; }
.ops-run-sent { color: #2f7d4f; font-weight: 600; }
.ops-run-dry, .ops-run-idle { color: var(--muted); }
.ops-run-fail { color: #c0392b; font-weight: 600; }
.ops-run-chip { background: var(--surface-2); border-radius: 4px; padding: 1px 6px; color: var(--ink-soft); }
.ops-run-status { margin-left: auto; font-weight: 600; }
.ops-run-status.ok { color: #6a994e; }
.ops-run-status.warn { color: #c08a2f; }

.ops-issues { display: flex; flex-direction: column; gap: 8px; }
.ops-issue { display: flex; gap: 10px; padding: 10px 12px; border-radius: 9px; background: #fff8ef; border: 1px solid #f0e0c0; }
.ops-issue-ic { color: #c08a2f; flex: none; }
.ops-issue-ic svg { width: 16px; height: 16px; }
.ops-issue strong { display: block; font-size: 13px; color: var(--ink); }
.ops-issue span { font-size: 12px; color: var(--ink-soft); }
.ops-ok { color: #6a994e; font-size: 13px; padding: 6px 2px; }

@media (max-width: 1100px) {
  .ops-kpis { grid-template-columns: repeat(2, 1fr); }
  .ops-cols { grid-template-columns: 1fr; }
}

/* ===================== Segments (client / cleaner) ===================== */
.seg-chips { margin: 10px 0 2px; border-top: 1px solid var(--line); padding-top: 10px; }
.chip-n { font-size: 11px; color: var(--muted); margin-left: 5px; font-weight: 600; }
.chip.active .chip-n { color: inherit; opacity: .85; }
.seg-badge { display: inline-block; font-size: 10px; font-weight: 600; line-height: 1.5; padding: 0 6px; border-radius: 999px; vertical-align: middle; }
.seg-client { background: var(--brand-soft); color: var(--brand-dark); }
.seg-cleaner { background: #ede9fe; color: #6d28d9; }
.seg-type { background: #ecfdf5; color: #047857; }

/* ===================== LANDING (public, clean / ChatGPT-style) ===================== */
.landing { position: fixed; inset: 0; overflow-y: auto; background: #fff; z-index: 50; color: #0d0d0d; font-family: var(--font); }
.landing .button.primary { background: #0d0d0d; border-color: #0d0d0d; color: #fff; }
.landing .button.primary:hover { background: #262626; }
.landing .button.ghost { background: #fff; border: 1px solid #e5e5e5; color: #0d0d0d; }
.landing .button.ghost:hover { background: #f7f7f8; }

.lp-nav { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 28px; background: rgba(255,255,255,.9); backdrop-filter: blur(10px); border-bottom: 1px solid #f0f0f0; }
.lp-nav .brand-text strong { color: #0d0d0d; }
.lp-nav-links { display: flex; gap: 26px; }
.lp-nav-links a { font-size: 14px; color: #555; text-decoration: none; }
.lp-nav-links a:hover { color: #0d0d0d; }
.lp-nav-actions { display: flex; gap: 8px; }

.lp-hero { max-width: 720px; margin: 0 auto; padding: 64px 20px 8px; text-align: center; }
.lp-eyebrow { display: inline-block; font-size: 13px; font-weight: 500; color: #6b6b6b; padding: 5px 13px; border: 1px solid #ececec; border-radius: 999px; }
.lp-title { font-size: clamp(36px, 6vw, 60px); line-height: 1.04; font-weight: 700; letter-spacing: -0.03em; margin: 22px 0 16px; color: #0d0d0d; }
.lp-sub { font-size: clamp(16px, 2.2vw, 19px); color: #5b5b5b; max-width: 600px; margin: 0 auto 26px; line-height: 1.55; }
.lp-cta { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 36px; }
.lp-cta-main { height: 48px; padding: 0 22px; font-size: 15px; border-radius: 10px; }
.lp-trust { font-size: 13px; color: #8a8a8a; margin: 18px 0 0; }

.lp-chat { max-width: 600px; margin: 0 auto; text-align: left; background: #fff; border: 1px solid #e8e8e8; border-radius: 18px; overflow: hidden; box-shadow: 0 18px 50px rgba(0,0,0,.07); }
.lp-chat-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid #f0f0f0; }
.lp-chat-av { width: 36px; height: 36px; border-radius: 9px; background: #0d0d0d; color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.lp-chat-id strong { display: block; font-size: 14px; color: #0d0d0d; }
.lp-chat-id span { font-size: 12px; color: #8a8a8a; display: flex; align-items: center; gap: 5px; }
.lp-dot { width: 7px; height: 7px; border-radius: 50%; background: #19c37d; display: inline-block; }
.lp-chat-log { padding: 18px 16px; display: flex; flex-direction: column; gap: 10px; min-height: 180px; max-height: 320px; overflow-y: auto; }
.lp-msg { max-width: 84%; padding: 10px 14px; border-radius: 16px; font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; }
.lp-msg.bot { align-self: flex-start; background: #f7f7f8; color: #0d0d0d; border-bottom-left-radius: 5px; }
.lp-msg.user { align-self: flex-end; background: #0d0d0d; color: #fff; border-bottom-right-radius: 5px; }
.lp-typing { color: #b0b0b0; letter-spacing: 3px; animation: lpblink 1s infinite; }
@keyframes lpblink { 50% { opacity: .35; } }
.lp-chat-row { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid #f0f0f0; }
.lp-chat-row input { flex: 1; min-width: 0; padding: 11px 14px; border: 1px solid #e5e5e5; border-radius: 12px; font-size: 14.5px; background: #fff; color: #0d0d0d; }
.lp-chat-row input:focus { outline: none; border-color: #0d0d0d; }
.lp-chat-send { width: 44px; height: 44px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 12px; background: #0d0d0d; color: #fff; cursor: pointer; }
.lp-chat-send:hover { background: #262626; }
.lp-chat-send svg { width: 18px; height: 18px; }
.lp-chat-suggest { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 14px 16px; }
.lp-chat-suggest button { font-size: 12.5px; color: #444; background: #fff; border: 1px solid #e5e5e5; border-radius: 999px; padding: 7px 13px; cursor: pointer; }
.lp-chat-suggest button:hover { background: #f4f4f5; color: #0d0d0d; }

.lp-section { max-width: 1040px; margin: 0 auto; padding: 76px 24px 0; }
.lp-h2 { font-size: clamp(26px, 4vw, 38px); font-weight: 700; letter-spacing: -0.02em; text-align: center; margin: 0 0 32px; color: #0d0d0d; }
.lp-section-sub { text-align: center; color: #6b6b6b; font-size: 16px; margin: -20px auto 32px; max-width: 560px; }

.lp-features { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.lp-feat { background: #fff; border: 1px solid #ececec; border-radius: 16px; padding: 22px; }
.lp-feat-ic { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 11px; background: #f4f4f5; color: #0d0d0d; margin-bottom: 14px; }
.lp-feat-ic svg { width: 21px; height: 21px; }
.lp-feat strong { display: block; font-size: 15.5px; margin-bottom: 6px; color: #0d0d0d; }
.lp-feat p { font-size: 13.5px; color: #6b6b6b; line-height: 1.55; margin: 0; }

.lp-channels { text-align: center; }
.lp-chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.lp-chips span { font-size: 14px; color: #0d0d0d; background: #f7f7f8; border: 1px solid #ececec; border-radius: 999px; padding: 9px 16px; }

.lp-steps-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.lp-step { background: #fff; border: 1px solid #ececec; border-radius: 16px; padding: 24px; }
.lp-step-n { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #0d0d0d; color: #fff; font-weight: 700; font-size: 14px; margin-bottom: 12px; }
.lp-step strong { display: block; font-size: 16px; margin-bottom: 6px; color: #0d0d0d; }
.lp-step p { font-size: 14px; color: #6b6b6b; line-height: 1.55; margin: 0; }

.lp-price { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; max-width: 720px; margin: 0 auto; }
.lp-price-card { border: 1px solid #ececec; border-radius: 16px; padding: 26px; text-align: center; }
.lp-price-card strong { display: block; font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: #8a8a8a; }
.lp-price-big { font-size: 23px; font-weight: 700; margin: 8px 0 10px; color: #0d0d0d; }
.lp-price-card p { font-size: 14px; color: #6b6b6b; line-height: 1.55; margin: 0; }

.lp-faq-list { max-width: 720px; margin: 0 auto; }
.lp-faq-list details { border-bottom: 1px solid #ececec; padding: 16px 4px; }
.lp-faq-list summary { font-size: 16px; font-weight: 600; color: #0d0d0d; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.lp-faq-list summary::after { content: "+"; color: #8a8a8a; font-weight: 400; font-size: 20px; }
.lp-faq-list details[open] summary::after { content: "−"; }
.lp-faq-list summary::-webkit-details-marker { display: none; }
.lp-faq-list details p { font-size: 14.5px; color: #5b5b5b; line-height: 1.6; margin: 12px 0 0; }

.lp-band { max-width: 1040px; margin: 80px auto 0; padding: 56px 24px; text-align: center; background: #0d0d0d; border-radius: 22px; color: #fff; }
.lp-band h2 { font-size: clamp(26px, 4vw, 36px); font-weight: 700; letter-spacing: -0.02em; color: #fff; margin: 0 0 10px; }
.lp-band p { color: rgba(255,255,255,.72); margin: 0 0 24px; font-size: 16px; }
.lp-band .button.primary { background: #fff; color: #0d0d0d; border-color: #fff; }
.lp-band .button.primary:hover { background: #ededed; }

.lp-footer { max-width: 1040px; margin: 64px auto 0; padding: 30px 24px 56px; border-top: 1px solid #f0f0f0; display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: space-between; }
.lp-footer-brand { font-size: 13px; color: #5b5b5b; font-weight: 500; }
.lp-footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
.lp-footer-links a { font-size: 13px; color: #8a8a8a; text-decoration: none; }
.lp-footer-links a:hover { color: #0d0d0d; }
.lp-footer-note { font-size: 12px; color: #a0a0a0; width: 100%; }

@media (max-width: 920px) {
  .lp-features { grid-template-columns: repeat(2, 1fr); }
  .lp-nav-links { display: none; }
}
@media (max-width: 620px) {
  .lp-features, .lp-steps-row, .lp-price { grid-template-columns: 1fr; }
  .lp-nav { padding: 12px 16px; }
  .lp-section { padding-top: 56px; }
}

.drawer-type { margin: 14px 0 4px; }
.drawer-type label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.drawer-type label span { font-weight: 400; color: var(--muted); }
.drawer-type-row { display: flex; gap: 8px; }
.drawer-type-input { flex: 1; min-width: 0; padding: 8px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font-size: 13px; }
.drawer-type-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

/* ===================== Operacje — cockpit (run pipeline) ===================== */
.ops-run-card { border: 1px solid var(--line); }
.ops-arm { font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px; margin-left: 6px; }
.ops-arm.on { background: #fdecec; color: #c0392b; }
.ops-arm.off { background: var(--surface-2); color: var(--muted); }
.ops-run-note { font-size: 12.5px; color: var(--muted); margin: -4px 0 12px; }
.ops-jobs { display: flex; flex-direction: column; }
.ops-job-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); }
.ops-job-row:last-child { border-bottom: 0; }
.ops-job-meta { min-width: 0; }
.ops-job-meta strong { display: block; font-size: 13.5px; color: var(--ink); }
.ops-job-meta span { font-size: 11.5px; color: var(--muted); font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.ops-job-actions { display: flex; gap: 8px; flex: none; }
.ops-live-btn { background: #c0392b; border-color: #c0392b; color: #fff; }
.ops-live-btn:hover:not([disabled]) { background: #a93226; }
.ops-live-btn[disabled] { opacity: .45; cursor: not-allowed; }
.ops-run-out { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.ops-run-loading { font-size: 13px; color: var(--ink-soft); }
.ops-run-head { font-size: 12.5px; font-weight: 700; margin-bottom: 8px; }
.ops-run-head.dry { color: var(--ink-soft); }
.ops-run-head.live { color: #c0392b; }
.ops-run-log { margin: 0; max-height: 280px; overflow: auto; background: #0f172a; color: #cbd5e1; border-radius: 8px; padding: 12px; font-size: 11.5px; line-height: 1.55; white-space: pre-wrap; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
