/* KRUKO24 — system UI.
   Tokeny tenanta (--primary, --accent, --radius) wstrzykiwane w base.html;
   reszta to neutralna, powściągliwa baza wspólna dla wszystkich tenantów. */

:root {
  --primary: #1e3a5f;
  --accent: #2563eb;
  --radius: 6px;

  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;

  --green: #16a34a;
  --green-bg: #f0fdf4;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --amber: #d97706;
  --amber-bg: #fffbeb;

  --sidebar-w: 232px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Layout ------------------------------------------------------------ */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-logo {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 15px;
  color: var(--primary);
  letter-spacing: -0.01em;
}
.sidebar-logo img { max-height: 28px; display: block; }
.sidebar nav { padding: 10px 8px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  margin: 1px 0;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-weight: 500;
}
.nav-item:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-item.active { background: color-mix(in srgb, var(--primary) 8%, transparent); color: var(--primary); }
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-muted);
}
.sidebar-footer a { color: var(--text-muted); }

.main { flex: 1; min-width: 0; padding: 24px 32px 48px; }
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.page-header h1 { font-size: 20px; font-weight: 650; margin: 0; letter-spacing: -0.01em; }
.page-actions { display: flex; gap: 8px; align-items: center; }

/* --- Przyciski --------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--primary) 88%, black); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-danger { color: var(--red); }

/* --- Karty i tabele ---------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13.5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-body { padding: 16px; }

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  padding: 9px 14px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-subtle);
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg); }
.num { font-variant-numeric: tabular-nums; text-align: right; }

/* --- Badge, avatar, kropki --------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-subtle); flex-shrink: 0; }
.badge-green { border-color: color-mix(in srgb, var(--green) 30%, transparent); background: var(--green-bg); color: var(--green); }
.badge-red { border-color: color-mix(in srgb, var(--red) 30%, transparent); background: var(--red-bg); color: var(--red); }
.badge-amber { border-color: color-mix(in srgb, var(--amber) 30%, transparent); background: var(--amber-bg); color: var(--amber); }

.avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* --- Formularze -------------------------------------------------------- */
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="url"], input[type="file"], select, textarea {
  font-family: var(--font);
  font-size: 13.5px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-color: var(--accent);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-field label { display: block; font-size: 12.5px; font-weight: 550; margin-bottom: 4px; color: var(--text-muted); }
.form-field.full { grid-column: 1 / -1; }
.form-field .errorlist { color: var(--red); font-size: 12px; margin: 4px 0 0; padding: 0; list-style: none; }
.search-input { max-width: 280px; }

/* --- Kanban ------------------------------------------------------------ */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.board-col {
  width: 268px;
  flex-shrink: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.board-col-header {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.board-col-header .count { color: var(--text-subtle); font-weight: 500; }
.board-col-header .sum { margin-left: auto; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.board-cards { padding: 8px; min-height: 60px; display: flex; flex-direction: column; gap: 8px; }
.deal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  cursor: grab;
  display: block;
  color: var(--text);
}
.deal-card:hover { text-decoration: none; border-color: var(--text-subtle); }
.deal-card .name { font-weight: 550; margin-bottom: 4px; }
.deal-card .meta { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-muted); }
.deal-card .value { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); }
.deal-card.sortable-ghost { opacity: 0.4; }
.deal-card.sortable-drag { transform: rotate(2deg); }

/* --- Pulpit ------------------------------------------------------------ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { padding: 14px 16px; }
.stat-card .label { font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px; }
.stat-card .value { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat-card .row { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.stat-card .delta { font-size: 12px; font-weight: 600; }
.stat-card .delta.up { color: var(--green); }
.stat-card .delta.down { color: var(--red); }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.chart-grid .card figure { margin: 0; }
.chart-card svg { width: 100%; height: auto; display: block; }
@media (max-width: 1100px) { .chart-grid { grid-template-columns: 1fr; } .form-grid { grid-template-columns: 1fr; } }

/* --- Timeline ----------------------------------------------------------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: none; }
.timeline .kind {
  width: 78px;
  flex-shrink: 0;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding-top: 2px;
}
.timeline .body { flex: 1; }
.timeline .when { font-size: 12px; color: var(--text-subtle); margin-top: 2px; }

/* --- Detale (dwie kolumny) --------------------------------------------- */
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .detail-grid { grid-template-columns: 1fr; } }
.props { margin: 0; }
.props div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.props div:last-child { border-bottom: none; }
.props dt { color: var(--text-muted); font-size: 13px; }
.props dd { margin: 0; font-weight: 500; text-align: right; }

/* --- Edycja inline (panel deala) ---------------------------------------- */
.inline-field { margin-bottom: 10px; }
.inline-field label {
  display: block;
  font-size: 12px;
  font-weight: 550;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.inline-pair { display: flex; gap: 6px; }
.panel-error {
  padding: 7px 10px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--red) 35%, transparent);
  background: var(--red-bg);
  color: var(--red);
  font-size: 12.5px;
  margin-bottom: 10px;
}
.task-quick-add { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.task-items { display: flex; flex-direction: column; }
.task-item {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.task-item:last-child { border-bottom: none; }
.task-item input[type="checkbox"] { margin-top: 3px; }
.task-item-body { flex: 1; font-size: 13.5px; }

/* --- Komunikaty --------------------------------------------------------- */
.messages { list-style: none; margin: 0 0 16px; padding: 0; }
.messages li {
  padding: 9px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 6px;
  font-size: 13.5px;
}
.messages li.success { border-color: color-mix(in srgb, var(--green) 35%, transparent); background: var(--green-bg); color: var(--green); }
.messages li.error { border-color: color-mix(in srgb, var(--red) 35%, transparent); background: var(--red-bg); color: var(--red); }

/* --- Pomocnicze --------------------------------------------------------- */
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); font-size: 12.5px; }
.mb { margin-bottom: 16px; }
.empty {
  padding: 36px 16px;
  text-align: center;
  color: var(--text-subtle);
}
.pagination { display: flex; gap: 6px; margin-top: 14px; align-items: center; font-size: 13px; }
.pagination a, .pagination span { padding: 4px 10px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.pagination span.current { background: var(--primary); border-color: var(--primary); color: #fff; }
.filter-tabs { display: flex; gap: 6px; }
.filter-tabs a {
  padding: 5px 12px;
  border-radius: 99px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}
.filter-tabs a.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.filter-tabs a:hover { text-decoration: none; }
.task-done { text-decoration: line-through; color: var(--text-subtle); }

/* --- Szybkie dodawanie --------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  z-index: 100;
}
.modal-box { width: 480px; max-width: calc(100vw - 32px); box-shadow: 0 10px 40px rgba(15, 23, 42, 0.18); }
.modal-tab {
  padding: 4px 12px;
  border-radius: 99px;
  color: var(--text-muted);
  font-weight: 550;
  margin-right: 4px;
}
.modal-tab.active { background: var(--primary); color: #fff; }
.modal-tab:hover { text-decoration: none; }
.modal-close {
  border: none;
  background: none;
  font-size: 20px;
  line-height: 1;
  color: var(--text-subtle);
  cursor: pointer;
  padding: 0 2px;
}
.modal-close:hover { color: var(--text); }

.quick-row { display: flex; gap: 8px; }
.quick-row input[name="smart"] { flex: 1; }

.dup-hint {
  margin-top: 8px;
  padding: 7px 10px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--amber) 35%, transparent);
  background: var(--amber-bg);
  color: var(--amber);
  font-size: 12.5px;
}
.dup-hint a { color: var(--amber); font-weight: 600; }

.col-add { border-bottom: 1px solid var(--border); }
.col-add summary {
  padding: 6px 12px;
  font-size: 12.5px;
  color: var(--text-subtle);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.col-add summary::-webkit-details-marker { display: none; }
.col-add summary:hover { color: var(--primary); }
.col-add form { padding: 4px 10px 10px; display: flex; flex-direction: column; gap: 6px; }

/* --- Baner szkicu -------------------------------------------------------- */
.draft-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border: 1px solid color-mix(in srgb, var(--amber) 40%, transparent);
  background: var(--amber-bg);
  border-radius: var(--radius);
}
.draft-banner strong { color: var(--amber); }

/* --- Dropzone (dokumenty) ------------------------------------------------ */
.dropzone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 22px 16px 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover { border-color: var(--text-subtle); }
.dropzone.dragover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}
.dropzone.uploading { opacity: 0.55; pointer-events: none; }
.dropzone-title { font-weight: 550; margin-bottom: 3px; }
.dropzone-fields {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
}
.dropzone-fields select { width: auto; }
.dropzone-compact { padding: 12px 10px 10px; }
.dropzone-compact .dropzone-title { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.doc-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.doc-row:last-child { border-bottom: none; }

/* --- Pasek postępu (cele) ------------------------------------------------ */
.progress {
  height: 7px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin: 5px 0;
}
.progress-bar { height: 100%; background: var(--primary); border-radius: 99px; transition: width 0.3s; }
.progress-bar.done { background: var(--green); }
.goal-row { display: flex; align-items: center; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.goal-row:last-child { border-bottom: none; }
.goal-name { width: 200px; flex-shrink: 0; display: flex; align-items: center; gap: 8px; font-weight: 500; }
.goal-track { flex: 1; }
.goal-user-block { padding: 12px 0; border-bottom: 1px solid var(--border); }
.goal-user-block:last-child { border-bottom: none; }
.goal-user-head { font-weight: 600; display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.goals-grid input { font-variant-numeric: tabular-nums; }
.team-goal-row td { background: color-mix(in srgb, var(--primary) 5%, transparent); }

/* --- Badge w nawigacji + powiadomienia ----------------------------------- */
.nav-badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 99px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  line-height: 18px;
}
.line-item { padding: 6px 0; border-bottom: 1px solid var(--border); }
.line-item:last-child { border-bottom: none; }
.note-row { border-bottom: 1px solid var(--border); margin: 0; }
.note-row:last-child { border-bottom: none; }
.note-row.unread { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.note-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 16px;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  text-align: left;
  color: var(--text);
}
.note-btn:hover { background: var(--bg); }
.note-text { flex: 1; }

/* --- Paleta Cmd+K -------------------------------------------------------- */
.cmdk-box { width: 560px; padding: 0; overflow: hidden; }
.cmdk-box input {
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 14px 16px;
  font-size: 15px;
}
.cmdk-box input:focus { outline: none; }
.cmdk-results { max-height: 380px; overflow-y: auto; padding: 6px; }
.cmdk-group {
  padding: 8px 10px 3px;
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
}
.cmdk-item {
  display: block;
  padding: 7px 10px;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13.5px;
}
.cmdk-item:hover, .cmdk-item.active {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
  text-decoration: none;
}
.cmdk-empty { padding: 20px 12px; text-align: center; color: var(--text-subtle); font-size: 13px; }

/* --- Oferty -------------------------------------------------------------- */
.offer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}
.offer-row:last-child { border-bottom: none; }
.offer-actions { display: flex; gap: 6px; }

/* --- Login -------------------------------------------------------------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-box { width: 360px; }
.login-box .card-body { padding: 24px; }
.login-logo { text-align: center; font-size: 18px; font-weight: 700; color: var(--primary); margin-bottom: 18px; }
