:root {
    --bg: #f7f7f8;
    --card: #fff;
    --ink: #111418;
    --muted: #8a909a;
    --line: #ececee;
    --pill-border: #e4e4e7;
    --black: #111418;
    --ceka: #ef4444;
    --zpracovava: #f59e0b;
    --zpracovano: #22c55e;
    --fakturovano: #3b82f6;
    --radius: 16px;
}

* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--ink); }
a { color: inherit; }
h1 { font-size: 34px; font-weight: 800; letter-spacing: -.5px; margin: 26px 0 18px; }
h2 { font-size: 16px; font-weight: 700; margin: 0 0 12px; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }

/* ---------- topbar ---------- */
.topbar { background: #fff; border-bottom: 1px solid var(--line); }
.topbar .wrap { display: flex; align-items: center; gap: 22px; min-height: 64px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 2px; text-decoration: none; font-weight: 800; font-size: 22px; letter-spacing: -.5px; }
.logo .logo-txt { color: var(--ink); }
.logo .logo-badge { background: var(--black); color: #fff; border-radius: 50%; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 800; margin-left: 1px; }
.logo em { font-style: normal; font-weight: 500; font-size: 13px; color: var(--muted); margin-left: 8px; }
.logo.big { font-size: 30px; justify-content: center; margin-bottom: 6px; }
.logo.big .logo-badge { width: 52px; height: 52px; font-size: 19px; }
.logo.big em { display: none; }

.topbar nav { display: flex; gap: 8px; flex: 1; flex-wrap: wrap; }
.pill { text-decoration: none; padding: 9px 18px; border: 1px solid var(--pill-border); border-radius: 999px; background: #fff; font-weight: 600; font-size: 14px; color: var(--ink); }
.pill:hover { background: #f1f1f3; }
.pill.active { background: var(--black); border-color: var(--black); color: #fff; }
.pill.pill-new { border-style: dashed; }
.pill.pill-new:hover { background: var(--black); border-color: var(--black); color: #fff; }

.userbox { display: flex; align-items: center; gap: 10px; background: #f4f4f5; border-radius: 999px; padding: 5px 8px 5px 5px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--black); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; text-decoration: none; }
.username { text-decoration: none; font-weight: 600; font-size: 14px; }
.username:hover { text-decoration: underline; }
.role-badge { background: var(--black); color: #fff; font-size: 10.5px; font-weight: 700; letter-spacing: .8px; padding: 3px 10px; border-radius: 999px; }
.logout { text-decoration: none; color: var(--muted); font-size: 17px; padding: 0 6px; }
.logout:hover { color: var(--ink); }

/* ---------- karty ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(17,20,24,.03); }
.card.narrow { max-width: 640px; }
.grid2 { display: grid; grid-template-columns: minmax(280px, 420px) 1fr; gap: 16px; align-items: start; }
.job-grid { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .grid2, .job-grid { grid-template-columns: 1fr; } }

/* ---------- formuláře ---------- */
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label { display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; font-weight: 500; color: #3f4650; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=search], select, textarea {
    font: inherit; padding: 10px 14px; border: 1px solid #dcdce0; border-radius: 12px; background: #fff; width: 100%;
}
.row input, .row select { width: auto; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #c8c9ce; border-color: var(--black); }
.check { display: flex; gap: 7px; align-items: center; font-size: 13.5px; }
.check input { width: auto; }

.btn { font: inherit; font-weight: 600; font-size: 14px; padding: 10px 20px; border: 1px solid var(--pill-border); background: #fff; border-radius: 999px; cursor: pointer; }
.btn:hover { background: #f1f1f3; }
.btn.primary { background: var(--black); border-color: var(--black); color: #fff; }
.btn.primary:hover { background: #2b2f36; }
.btn.small { padding: 6px 14px; font-size: 12.5px; }
.btn.danger { color: #dc2626; border-color: #f1c7c5; }
.btn.danger:hover { background: #fdf0ef; }
.btn.wide { width: 100%; }

/* ---------- tabulky ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 600; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.total td { border-top: 2px solid var(--line); }
.tbl tr.inactive { opacity: .45; }
.tbl .actions { text-align: right; }
.tbl .actions form { display: inline; }
.jobs-tbl a { text-decoration: none; }
.jobs-tbl a:hover { text-decoration: underline; }
.jobs-tbl td:first-child a { font-weight: 700; }

/* popover menu v tabulkách */
.tbl td.actions { position: relative; }
.popover summary { cursor: pointer; list-style: none; font-size: 20px; padding: 0 8px; color: var(--muted); border-radius: 8px; display: inline-block; }
.popover summary::-webkit-details-marker { display: none; }
.popover summary:hover { color: var(--ink); background: #f1f1f3; }
.popover .menu { position: absolute; right: 8px; top: 36px; width: 280px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: 0 12px 32px rgba(17,20,24,.14); z-index: 20; display: flex; flex-direction: column; gap: 12px; text-align: left; }
.popover .menu .btn { width: 100%; }

/* ---------- semafor ---------- */
.semafor { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 700px) { .semafor { grid-template-columns: repeat(2, 1fr); } }
.sem-box { display: flex; align-items: center; gap: 14px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 18px; text-decoration: none; box-shadow: 0 1px 2px rgba(17,20,24,.03); }
.sem-box:hover { border-color: #d4d4d8; }
.sem-box b { display: block; font-size: 32px; font-weight: 800; line-height: 1.05; }
.sem-box span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 600; margin-top: 2px; }

.dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; flex: 0 0 auto; }
.dot.st-ceka { background: var(--ceka); }
.dot.st-zpracovava { background: var(--zpracovava); }
.dot.st-zpracovano { background: var(--zpracovano); }
.dot.st-fakturovano { background: var(--fakturovano); }

.badge { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.badge .dot { width: 11px; height: 11px; }

.hl-ceka { color: var(--ceka); font-weight: 700; }

/* ---------- deadliny ---------- */
tr.dl-over td:first-child { box-shadow: inset 3px 0 0 var(--ceka); }
tr.dl-soon td:first-child { box-shadow: inset 3px 0 0 var(--zpracovava); }
.dl-row { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.dl-row:last-child { border-bottom: 0; }
.dl-row a { text-decoration: none; }
.dl-row a:hover { text-decoration: underline; }
.dl-row.dl-over > span { color: var(--ceka); font-weight: 600; }
.alert-card { border-color: #f3c0bb; background: #fffafa; }
td.dl-over { color: var(--ceka); font-weight: 700; }

/* ---------- detail jobu ---------- */
.job-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; margin: 26px 0 16px; flex-wrap: wrap; }
.job-head h1 { margin: 4px 0 0; }
.jobnum { color: var(--muted); font-weight: 700; }
.crumbs { font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.job-head-right { text-align: right; }
.job-head-right .deadline { font-size: 13.5px; margin-top: 6px; }
.brief { white-space: normal; }

/* ---------- komunikace ---------- */
.thread { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.msg { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: #fafafa; }
.msg-mine { background: #fff; }
.msg-internal { background: #fffbeb; border-color: #f1e2b6; }
.msg-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; margin-bottom: 4px; }
.msg-body { white-space: normal; }
.tag-internal { background: #111418; color: #fff; font-size: 10px; font-weight: 700; padding: 2px 10px; border-radius: 999px; text-transform: uppercase; letter-spacing: .6px; }
.attach { display: inline-block; margin-top: 6px; font-size: 13.5px; }
.msg-form textarea { width: 100%; }

/* ---------- stav v sidebaru ---------- */
.status-list { display: flex; flex-direction: column; gap: 8px; }
.status-opt { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; font-size: 13.5px; font-weight: 500; background: #fff; }
.status-opt:hover { border-color: #d4d4d8; }
.status-opt input { width: auto; accent-color: var(--black); }
.status-opt.disabled { opacity: .4; cursor: default; }
.status-opt.st-ceka { box-shadow: inset 4px 0 0 var(--ceka); }
.status-opt.st-zpracovava { box-shadow: inset 4px 0 0 var(--zpracovava); }
.status-opt.st-zpracovano { box-shadow: inset 4px 0 0 var(--zpracovano); }
.status-opt.st-fakturovano { box-shadow: inset 4px 0 0 var(--fakturovano); }

/* ---------- filtry ---------- */
.filters { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.filters input[type=search] { width: 240px; border-radius: 999px; }
.filters select { border-radius: 999px; }

/* ---------- flash ---------- */
.flash { padding: 12px 16px; border-radius: 12px; margin: 14px 0; font-weight: 500; }
.flash-ok { background: #ecfdf3; color: #15803d; border: 1px solid #bbe7c9; }
.flash-err { background: #fef2f2; color: #dc2626; border: 1px solid #f3c4c2; }

/* ---------- login ---------- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.login-box { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 38px; width: 380px; box-shadow: 0 16px 40px rgba(17,20,24,.08); }
.login-box form { display: flex; flex-direction: column; gap: 14px; }
.login-box label { display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; font-weight: 500; color: #3f4650; }

.foot { color: var(--muted); font-size: 12.5px; padding: 22px 20px 30px; }
.calc { border-color: #e9e2c8; background: #fffdf6; }
.ts-form { margin-top: 12px; }
