/* ============================================================
   TLAKOVÁ ČETA CRM — styly
   Paleta a typografie dle brand/brand-guide.md
   ============================================================ */

:root {
  --navy: #0B1B3D;
  --navy-2: #13294f;
  --blue: #1B98E0;
  --cyan: #38BDF8;
  --orange: #E65C00;
  --orange-h: #C74F00;
  --text: #111827;
  --muted: #5b6472;
  --bg: #F3F7FA;
  --card: #ffffff;
  --line: #e2e8f0;
  --green: #059669;
  --red: #DC2626;
  --amber: #F59E0B;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(11, 27, 61, .08), 0 4px 14px rgba(11, 27, 61, .06);
  --sidebar-w: 232px;
  --font-head: "Space Grotesk", "Inter", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 400 14.5px/1.5 Inter, system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-head); color: var(--navy); margin: 0; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- layout ---------- */
#app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; grid-template-rows: auto 1fr; min-height: 100vh; grid-template-areas: "side top" "side main"; }
#sidebar { grid-area: side; background: var(--navy); color: #d6e2f0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
#topbar { grid-area: top; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 10px 20px; position: sticky; top: 0; z-index: 40; }
#view { grid-area: main; padding: 22px 24px 90px; max-width: 1500px; width: 100%; }

.side-brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; }
.side-brand img { width: 40px; height: 40px; }
.side-brand .nm { font-family: var(--font-head); font-weight: 700; font-size: 15px; letter-spacing: .6px; color: #fff; line-height: 1.15; }
.side-brand .sub { font-size: 10.5px; color: #7d94b8; letter-spacing: .4px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; padding: 10px 10px; flex: 1; }
.side-nav a { display: flex; align-items: center; gap: 10px; color: #c3d2e6; padding: 9px 12px; border-radius: 9px; font-weight: 500; font-size: 14px; }
.side-nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.side-nav a.active { background: var(--orange); color: #fff; font-weight: 600; }
.side-nav .ico { width: 20px; text-align: center; }
.side-user { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.1); font-size: 13px; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.side-user button { background: none; border: 0; color: #8fa7c7; cursor: pointer; font-size: 12.5px; padding: 4px; }
.side-user button:hover { color: #fff; }

#globalSearch { flex: 1; max-width: 420px; position: relative; }
#globalSearch input { width: 100%; padding: 9px 12px 9px 34px; border: 1.5px solid var(--line); border-radius: 9px; font: inherit; background: var(--bg); }
#globalSearch input:focus { outline: none; border-color: var(--blue); background: #fff; }
#globalSearch .mag { position: absolute; left: 10px; top: 8px; color: var(--muted); }
.search-drop { position: absolute; top: 42px; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; z-index: 60; }
.search-drop a { display: block; padding: 9px 13px; border-bottom: 1px solid #f1f5f9; color: var(--text); }
.search-drop a:hover { background: var(--bg); text-decoration: none; }
.search-drop .grp { padding: 6px 13px 2px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 600; }
.topbar-spacer { flex: 1; }

/* ---------- tlačítka ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; font: 600 14px Inter, sans-serif; padding: 9px 16px; border-radius: 9px; border: 1.5px solid transparent; cursor: pointer; white-space: nowrap; transition: background .12s; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-h); }
.btn-secondary { background: #fff; border-color: var(--line); color: var(--navy); }
.btn-secondary:hover { border-color: var(--blue); color: var(--blue); }
.btn-ghost { background: none; color: var(--blue); padding: 6px 10px; }
.btn-ghost:hover { background: #e8f4fc; }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--red); }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }

/* ---------- karty, mřížky ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }
.page-head .grow { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 14px 16px; }
.kpi .lbl { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi .val { font-family: var(--font-mono); font-weight: 700; font-size: 22px; color: var(--navy); margin-top: 2px; }
.kpi .val.orange { color: var(--orange); }
.kpi .val.green { color: var(--green); }

/* ---------- formuláře ---------- */
label.f { display: block; margin-bottom: 11px; }
label.f > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--navy); margin-bottom: 4px; }
input[type=text], input[type=number], input[type=date], input[type=email], input[type=tel], input[type=password], select, textarea {
  width: 100%; padding: 8.5px 11px; border: 1.5px solid var(--line); border-radius: 8px; font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(27,152,224,.12); }
textarea { resize: vertical; min-height: 70px; }
.f-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.f-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.check-line { display: flex; align-items: flex-start; gap: 8px; padding: 7px 0; cursor: pointer; }
.check-line input { width: auto; margin-top: 3px; }
.hint { font-size: 12px; color: var(--muted); }

/* ---------- tabulky ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font: 600 11.5px var(--font-head); text-transform: uppercase; letter-spacing: .8px; color: var(--muted); padding: 10px 12px; border-bottom: 2px solid var(--line); }
.tbl td { padding: 11px 12px; border-bottom: 1px solid #eef2f6; vertical-align: middle; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--bg); }
.tbl .num { font-family: var(--font-mono); text-align: right; white-space: nowrap; }
.empty { padding: 34px; text-align: center; color: var(--muted); }

/* ---------- badge ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font: 600 11.5px Inter, sans-serif; padding: 3px 9px; border-radius: 99px; background: var(--bg); color: var(--navy); white-space: nowrap; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.money { font-family: var(--font-mono); font-weight: 700; white-space: nowrap; }

/* ---------- kanban ---------- */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 14px; align-items: flex-start; }
.kcol { min-width: 235px; width: 235px; flex: none; background: #eaf0f6; border-radius: var(--radius); padding: 9px; }
.kcol.drag-over { outline: 2.5px dashed var(--blue); outline-offset: -2px; }
.kcol-head { display: flex; align-items: center; gap: 7px; padding: 4px 6px 9px; font: 600 12.5px var(--font-head); color: var(--navy); }
.kcol-head .dot { width: 9px; height: 9px; border-radius: 50%; }
.kcol-head .cnt { margin-left: auto; background: #fff; border-radius: 99px; font-size: 11px; padding: 1px 8px; color: var(--muted); }
.kcol-sum { font-family: var(--font-mono); font-size: 11px; color: var(--muted); padding: 0 6px 7px; }
.kcard { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; cursor: grab; box-shadow: 0 1px 2px rgba(11,27,61,.06); }
.kcard:hover { border-color: var(--blue); }
.kcard.dragging { opacity: .45; }
.kcard .t { font-weight: 600; font-size: 13.5px; color: var(--navy); margin: 1px 0 2px; }
.kcard .meta { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); gap: 6px; }
.kcard .code { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); }
.kcard .val { font-family: var(--font-mono); font-weight: 700; font-size: 12.5px; color: var(--orange); }
.kcard .plan { margin-top: 5px; font-size: 11px; color: var(--green); font-weight: 600; }
.kcard .warn { margin-top: 5px; font-size: 11px; color: var(--red); font-weight: 600; }

/* ---------- stepper fází ---------- */
.stepper { display: flex; gap: 6px; flex-wrap: wrap; }
.step { font: 600 12px Inter, sans-serif; padding: 6px 11px; border-radius: 99px; border: 1.5px solid var(--line); background: #fff; color: var(--muted); cursor: pointer; }
.step:hover { border-color: var(--blue); color: var(--blue); }
.step.done { background: #e8f4fc; border-color: #bfe3f7; color: var(--blue); }
.step.current { background: var(--navy); border-color: var(--navy); color: #fff; }
.step.lost { border-color: #f3c9c9; }
.step.lost.current { background: var(--red); border-color: var(--red); }

/* ---------- timeline aktivit ---------- */
.timeline { display: flex; flex-direction: column; gap: 10px; }
.tl-item { display: flex; gap: 10px; }
.tl-ico { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 14px; }
.tl-body { flex: 1; background: var(--bg); border-radius: 10px; padding: 8px 12px; }
.tl-body.sys { background: transparent; padding: 4px 0 0; }
.tl-txt { white-space: pre-wrap; font-size: 13.5px; }
.tl-meta { font-size: 11.5px; color: var(--muted); margin-top: 3px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tl-meta button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 11.5px; padding: 0; }
.tl-meta button:hover { color: var(--red); }
.tl-due { font-weight: 600; color: var(--amber); }
.tl-due.over { color: var(--red); }
.tl-item.done-task .tl-txt { text-decoration: line-through; color: var(--muted); }

/* ---------- nabídkový editor ---------- */
.quote-grid { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 16px; align-items: start; }
.q-side { position: sticky; top: 70px; }
.q-item { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; background: #fff; }
.q-item-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.q-item-head .t { font-family: var(--font-head); font-weight: 600; color: var(--navy); flex: 1; }
.q-breakdown { font-size: 13px; }
.q-breakdown .sec { font: 600 12.5px var(--font-head); color: var(--navy); background: var(--bg); border-radius: 7px; padding: 5px 9px; margin: 9px 0 4px; }
.q-breakdown .ln { display: flex; justify-content: space-between; gap: 10px; padding: 3.5px 9px 3.5px 9px; }
.q-breakdown .ln b { font-family: var(--font-mono); font-weight: 500; white-space: nowrap; }
.q-breakdown .warn { color: var(--red); font-size: 12.5px; padding: 4px 9px; }
.q-total { display: flex; justify-content: space-between; align-items: center; background: var(--navy); color: #fff; border-radius: 10px; padding: 12px 15px; margin-top: 12px; }
.q-total .v { font-family: var(--font-mono); font-weight: 700; font-size: 21px; }
.save-state { font-size: 12px; color: var(--muted); }
.save-state.saved { color: var(--green); }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(11,27,61,.5); display: flex; align-items: flex-start; justify-content: center; padding: 40px 14px; z-index: 100; overflow-y: auto; }
.modal { background: #fff; border-radius: 14px; width: 560px; max-width: 100%; box-shadow: 0 20px 60px rgba(11,27,61,.35); }
.modal.wide { width: 760px; }
.modal-head { display: flex; align-items: center; padding: 16px 20px 0; }
.modal-head h2 { font-size: 17px; flex: 1; }
.modal-head button { background: none; border: 0; font-size: 20px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 14px 20px 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px 18px; }

/* ---------- toast ---------- */
#toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13.5px; max-width: 340px; animation: toast-in .18s ease-out; }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ---------- login ---------- */
body.login-page { background: var(--navy); display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: #fff; border-radius: 16px; padding: 34px 34px 28px; width: 380px; max-width: calc(100vw - 32px); box-shadow: 0 24px 80px rgba(0,0,0,.4); }
.login-card .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.login-card .brand img { width: 46px; height: 46px; }
.login-card h1 { font-size: 19px; }
.login-card .sub { color: var(--muted); font-size: 12.5px; }
.login-err { background: #fef2f2; color: var(--red); border-radius: 8px; padding: 9px 12px; font-size: 13px; margin-bottom: 10px; display: none; }
.login-err.show { display: block; }

/* ---------- kalendář ---------- */
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-title { font-family: var(--font-head); color: var(--navy); margin-left: 8px; white-space: nowrap; }
.user-drop { position: absolute; right: 0; top: 44px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 8px 12px; min-width: 220px; z-index: 70; }
.cal-legend { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-top: 12px; font-size: 12.5px; color: var(--navy); }
.cal-leg-item { display: inline-flex; align-items: center; gap: 6px; }
.cal-leg-item input[type=color] { width: 22px; height: 22px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }

.cal-chip { display: block; font: 500 11.5px Inter, sans-serif; color: var(--navy); background: color-mix(in srgb, var(--c) 16%, #fff); border-left: 3px solid var(--c); border-radius: 5px; padding: 2px 6px; margin: 2px 0; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-chip.is-done { text-decoration: line-through; opacity: .6; }
.cal-chip.is-foreign { outline: 1px dashed var(--c); background: #fff; }

.wk-head, .wk-allday { display: grid; grid-template-columns: 52px repeat(7, 1fr); border-bottom: 1px solid var(--line); }
.wk-dayhead { padding: 8px 6px; text-align: center; font: 500 12.5px Inter, sans-serif; color: var(--muted); border-left: 1px solid #eef2f6; }
.wk-dayhead.is-today { color: var(--orange); font-weight: 700; }
.wk-alldaycell { border-left: 1px solid #eef2f6; padding: 3px 4px; min-height: 26px; cursor: pointer; }
.wk-gutter { padding: 4px; }
.wk-grid { display: grid; grid-template-columns: 52px repeat(7, 1fr); overflow-y: auto; max-height: 66vh; }
.wk-grid .wk-gutter { position: relative; }
.wk-hour { height: 46px; font: 500 10.5px var(--font-mono); color: var(--muted); text-align: right; padding-right: 6px; transform: translateY(-6px); }
.wk-day { position: relative; border-left: 1px solid #eef2f6; cursor: pointer; }
.wk-day.is-today { background: #fffaf5; }
.wk-line { position: absolute; left: 0; right: 0; border-top: 1px solid #f1f5f9; }
.wk-now { position: absolute; left: 0; right: 0; border-top: 2px solid var(--red); z-index: 3; }
.wk-ev { position: absolute; z-index: 2; background: color-mix(in srgb, var(--c) 14%, #fff); border: 1px solid color-mix(in srgb, var(--c) 45%, #fff); border-left: 4px solid var(--c); border-radius: 7px; padding: 2px 6px; overflow: hidden; cursor: pointer; box-shadow: 0 1px 2px rgba(11,27,61,.08); }
.wk-ev:hover { z-index: 4; box-shadow: 0 3px 10px rgba(11,27,61,.18); }
.wk-ev.is-done { opacity: .55; }
.wk-ev.is-done .wk-ev-title { text-decoration: line-through; }
.wk-ev.is-foreign { background: repeating-linear-gradient(45deg, #fff, #fff 5px, color-mix(in srgb, var(--c) 10%, #fff) 5px, color-mix(in srgb, var(--c) 10%, #fff) 10px); }
.wk-ev-time { display: block; font: 600 10px var(--font-mono); color: var(--c); }
.wk-ev-user { background: var(--c); color: #fff; border-radius: 4px; padding: 0 3px; font-size: 9px; }
.wk-ev-title { font-size: 11.5px; line-height: 1.25; display: block; color: var(--text); }

.mo-head { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--line); }
.mo-head div { padding: 7px; text-align: center; font: 600 11px var(--font-head); text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.mo-week { display: grid; grid-template-columns: repeat(7, 1fr); }
.mo-day { min-height: 96px; border-left: 1px solid #eef2f6; border-bottom: 1px solid #eef2f6; padding: 4px; cursor: pointer; overflow: hidden; }
.mo-day.is-other { background: #f8fafc; opacity: .6; }
.mo-day.is-today { background: #fffaf5; }
.mo-day.is-today .mo-num { background: var(--orange); color: #fff; }
.mo-num { font: 600 11.5px var(--font-mono); color: var(--muted); width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; border-radius: 50%; margin-bottom: 2px; }
.conflict-warn { background: #fef3c7; border: 1px solid #fcd34d; color: #92400e; border-radius: 8px; padding: 9px 12px; font-size: 13px; margin: 6px 0; }

/* ---------- vlastní dlaždice (custom pole) ---------- */
.ct-actions { display: flex; justify-content: flex-end; margin: 2px 0 16px; }
.ct-field-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.ct-field-row .grow { flex: 1; }

/* ---------- správa fází (nastavení) ---------- */
.stage-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.stage-row input[type=color] { width: 34px; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; flex: none; }
.stage-row .lbl { flex: 2; min-width: 140px; }
.stage-row .hnt { flex: 3; min-width: 160px; }
.stage-row .btn { flex: none; }
.stage-lock { font-size: 11px; color: var(--muted); flex: none; width: 60px; }

/* ---------- mobil ---------- */
#mobilenav { display: none; }
@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; grid-template-areas: "top" "main"; }
  #sidebar { display: none; }
  #view { padding: 14px 12px 84px; }
  #mobilenav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--navy); z-index: 50; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); justify-content: space-around; }
  #mobilenav a { color: #b9c9de; text-align: center; font-size: 10px; padding: 6px 8px; border-radius: 8px; text-decoration: none; min-width: 56px; }
  #mobilenav a .i { display: block; font-size: 19px; }
  #mobilenav a.active { color: #fff; background: rgba(230,92,0,.85); }
  .grid-2, .f-row, .f-row-3 { grid-template-columns: 1fr; }
  .quote-grid { grid-template-columns: 1fr; }
  .q-side { position: static; }
  .kcol { min-width: 205px; width: 205px; }
  .page-head h1 { font-size: 18px; }
  #topbar { padding: 8px 10px; }
  .hide-mobile { display: none !important; }
  #calBody { overflow-x: auto; }
  .wk-head, .wk-allday, .wk-grid { min-width: 680px; }
  .mo-day { min-height: 64px; }
  .cal-title { font-size: 13px; }
}
