/* Connect plus – správa požadavků */

:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e3e7ef;
  --text: #1a2233;
  --muted: #687389;
  --accent: #007bc9;
  --accent-hover: #0067a8;
  --accent-soft: #e3f2fb;
  --on-accent: #ffffff;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --warning-soft: #fff6e0;
  --success-soft: #e8f7ee;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 2px 8px rgba(16, 24, 40, .05);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .12);

  /* stavy: [pozadí, text] */
  --st-novy-bg: #e0ecff;     --st-novy: #1d4ed8;
  --st-prijaty-bg: #ede7ff;  --st-prijaty: #6d28d9;
  --st-resi_se-bg: #fff1d6;  --st-resi_se: #b45309;
  --st-ceka-bg: #fde7f1;     --st-ceka: #be185d;
  --st-vyreseny-bg: #dcf5e6; --st-vyreseny: #15803d;
  --st-uzavreny-bg: #eceff4; --st-uzavreny: #475569;

  color-scheme: light;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e131c;
    --surface: #161d29;
    --surface-2: #1b2331;
    --border: #2a3446;
    --text: #e6eaf2;
    --muted: #94a0b8;
    --accent: #3aa6e8;
    --accent-hover: #63b9ee;
    --accent-soft: #12293a;
    --on-accent: #0b1220;
    --danger: #f87171;
    --danger-soft: #3a1d22;
    --warning-soft: #3a2e14;
    --success-soft: #16301f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);

    --st-novy-bg: #1c2d55;     --st-novy: #93b4ff;
    --st-prijaty-bg: #2c2152;  --st-prijaty: #c4b0ff;
    --st-resi_se-bg: #3d2d10;  --st-resi_se: #fbbf5a;
    --st-ceka-bg: #42182c;     --st-ceka: #f9a8d4;
    --st-vyreseny-bg: #133322; --st-vyreseny: #6ee7a0;
    --st-uzavreny-bg: #262e3b; --st-uzavreny: #a8b3c4;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
hr { border: 0; border-top: 1px solid var(--border); margin: .5rem 0; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.strong { font-weight: 600; }
.text-danger { color: var(--danger); }
.center { text-align: center; }
.num { text-align: right; white-space: nowrap; }

/* --- layout --------------------------------------------------------- */
.container { max-width: 1240px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: .6rem 1rem;
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .5rem; color: var(--text); font-size: 1.15rem; }
.brand:hover { text-decoration: none; }
.brand b { color: var(--accent); font-weight: 700; }
.brand img { border-radius: 8px; }
.brand small { color: var(--muted); font-size: .8rem; border-left: 1px solid var(--border); padding-left: .5rem; }
.mainnav { display: flex; gap: .25rem; flex: 1; overflow-x: auto; }
.mainnav a {
  padding: .45rem .8rem; border-radius: var(--radius-sm); color: var(--muted); font-weight: 500; white-space: nowrap;
}
.mainnav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.mainnav a.active { background: var(--accent-soft); color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: .75rem; }

.usermenu { position: relative; }
.usermenu summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: .5rem;
  padding: .25rem .5rem .25rem .25rem; border-radius: 999px;
}
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover { background: var(--surface-2); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: .9rem;
}
.usermenu-panel {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: .75rem; display: flex; flex-direction: column; gap: .5rem;
}
.usermenu-panel a, .linklike {
  display: block; padding: .4rem .5rem; border-radius: 6px; color: var(--text); text-align: left;
}
.usermenu-panel a:hover, .linklike:hover { background: var(--surface-2); text-decoration: none; }
.linklike { background: none; border: 0; font: inherit; width: 100%; cursor: pointer; }

.page-head {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.page-head p { margin: .25rem 0 0; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: .25rem; }
.crumbs a { color: var(--muted); }
.section-title { margin: 2rem 0 .85rem; font-size: 1.15rem; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1rem; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
.detail-main, .detail-side { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
@media (max-width: 900px) {
  .detail-layout { grid-template-columns: 1fr; }
}

/* --- karty ------------------------------------------------------------ */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.15rem 1.25rem;
}
.card > h2 { margin-bottom: .85rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .85rem; }
.empty { color: var(--muted); text-align: center; padding: 1.25rem; }

.collapsible > summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.collapsible > summary::-webkit-details-marker { display: none; }
.collapsible > summary::after { content: "▾"; color: var(--muted); transition: transform .15s; }
.collapsible[open] > summary { margin-bottom: .85rem; }
.collapsible[open] > summary::after { transform: rotate(180deg); }
.collapsible form + form { margin-top: .75rem; }

/* --- statistiky --------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: .2rem; color: var(--text);
  transition: transform .12s, box-shadow .12s;
}
a.stat:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-value { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; }
.stat-value small { font-size: 1rem; color: var(--muted); font-weight: 500; }
.stat-value.accent { color: var(--accent); }
.stat-value.danger { color: var(--danger); }

.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.subject-card h3 a { color: var(--text); }
.status-bar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; gap: 2px; background: var(--surface-2); margin-bottom: .85rem; }
.status-bar span { background: var(--st-bg, var(--border)); }
.status-bar .empty-bar { background: var(--border); }
.status-counts { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: .15rem .75rem; }
.status-counts a { display: flex; align-items: center; gap: .45rem; color: var(--text); padding: .2rem 0; font-size: .9rem; }
.status-counts a:hover { text-decoration: none; color: var(--accent); }
.status-counts b { margin-left: auto; font-variant-numeric: tabular-nums; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--st-fg); flex: none; }
.subject-foot {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-top: 1rem; padding-top: .85rem;
  border-top: 1px solid var(--border);
}
.subject-foot div { display: flex; flex-direction: column; min-width: 0; }
.subject-foot .small { white-space: nowrap; }
.subject-foot b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }

/* --- odznaky ---------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 99px;
  font-size: .78rem; font-weight: 600; white-space: nowrap;
  background: var(--st-bg, var(--surface-2)); color: var(--st-fg, var(--muted));
  border: 1px solid transparent;
}
.st-novy     { --st-bg: var(--st-novy-bg);     --st-fg: var(--st-novy); }
.st-prijaty  { --st-bg: var(--st-prijaty-bg);  --st-fg: var(--st-prijaty); }
.st-resi_se  { --st-bg: var(--st-resi_se-bg);  --st-fg: var(--st-resi_se); }
.st-ceka     { --st-bg: var(--st-ceka-bg);     --st-fg: var(--st-ceka); }
.st-vyreseny { --st-bg: var(--st-vyreseny-bg); --st-fg: var(--st-vyreseny); }
.st-uzavreny { --st-bg: var(--st-uzavreny-bg); --st-fg: var(--st-uzavreny); }
.status-bar .st-novy, .status-bar .st-prijaty, .status-bar .st-resi_se,
.status-bar .st-ceka, .status-bar .st-vyreseny, .status-bar .st-uzavreny { background: var(--st-fg); }
.badge-danger { --st-bg: var(--danger-soft); --st-fg: var(--danger); }
.badge-time { --st-bg: var(--accent-soft); --st-fg: var(--accent); }
.role-admin { --st-bg: var(--danger-soft); --st-fg: var(--danger); }
.role-technik { --st-bg: var(--st-prijaty-bg); --st-fg: var(--st-prijaty); }
.role-zadavatel { --st-bg: var(--st-novy-bg); --st-fg: var(--st-novy); }

.prio { display: inline-flex; align-items: center; gap: .35rem; font-size: .82rem; font-weight: 500; white-space: nowrap; }
.prio::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: currentColor; transform: rotate(45deg); }
.prio-nizka { color: var(--muted); }
.prio-normalni { color: var(--accent); }
.prio-vysoka { color: #ea7a0b; }
.prio-kriticka { color: var(--danger); font-weight: 700; }

.tag {
  display: inline-flex; align-items: center; gap: .3rem; margin: 0 .25rem .25rem 0; padding: .1rem .5rem;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2);
}
.tag i { font-style: normal; font-size: .7rem; color: var(--muted); font-weight: 700; }

.chip {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 99px;
  padding: .2rem .7rem; font: inherit; font-size: .82rem; cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.quick-times { display: flex; flex-wrap: wrap; gap: .4rem; }

/* --- tabulka ------------------------------------------------------------------ */
.table-wrap {
  overflow-x: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  font-weight: 600; padding: .7rem 1rem; background: var(--surface-2); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table th.num { text-align: right; }
.table td { padding: .7rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.rowlink { cursor: pointer; transition: background .1s; }
.rowlink:hover { background: var(--surface-2); }
.rowlink.overdue td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.inactive { opacity: .55; }

/* --- seznamy ------------------------------------------------------------------ */
.req-list, .member-list { list-style: none; margin: 0; padding: 0; }
.req-list li { padding: .65rem 0; border-bottom: 1px solid var(--border); }
.req-list li:last-child { border-bottom: 0; }
.req-list li.overdue { box-shadow: inset 3px 0 0 var(--danger); padding-left: .75rem; }
.req-list a { color: var(--text); font-weight: 550; }
.req-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .3rem; }
.member-list li {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  padding: .55rem 0; border-bottom: 1px solid var(--border);
}
.member-list li > div { display: flex; flex-wrap: wrap; gap: .25rem .6rem; align-items: center; }

/* --- detail ------------------------------------------------------------------ */
.prose { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: .6rem; }
.props { display: grid; grid-template-columns: auto 1fr; gap: .55rem 1rem; margin: 0 0 1rem; }
.props dt { color: var(--muted); font-size: .88rem; }
.props dd { margin: 0; text-align: right; }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline li { position: relative; padding: 0 0 1.1rem 1.9rem; }
.tl-dot {
  position: absolute; left: 0; top: 4px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--muted);
}
.tl-create .tl-dot { border-color: var(--st-novy); }
.tl-work .tl-dot { border-color: var(--accent); background: var(--accent); }
.tl-status .tl-dot { border-color: var(--st-resi_se); }
.tl-comment .tl-dot { border-color: var(--st-ceka); }
.tl-assign .tl-dot { border-color: var(--st-prijaty); }
.tl-head { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .5rem; }
.tl-time { margin-left: auto; }
.tl-text { margin-top: .35rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6rem .8rem; }
.comment-form { border-top: 1px solid var(--border); padding-top: 1rem; margin-top: .25rem; }

.status-pick { display: flex; flex-wrap: wrap; gap: .4rem; }
.status-opt input { position: absolute; opacity: 0; pointer-events: none; }
.status-opt .badge { cursor: pointer; padding: .3rem .7rem; font-size: .82rem; opacity: .55; border-color: transparent; }
.status-opt input:checked + .badge { opacity: 1; border-color: var(--st-fg); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--st-fg); }
.status-opt input:focus-visible + .badge { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- formuláře ---------------------------------------------------------------- */
.form { display: flex; flex-direction: column; gap: .85rem; }
.form.narrow { max-width: 760px; }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; font-weight: 550; }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 450; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=tel],
input[type=number], input[type=date], select, textarea {
  font: inherit; font-weight: 400; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .55rem .7rem; width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
input:disabled { background: var(--surface-2); color: var(--muted); }
textarea { resize: vertical; min-height: 4rem; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 1rem; height: 1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; }
.form-row-3 { grid-template-columns: 1fr 1fr 2fr; }
@media (max-width: 600px) { .form-row, .form-row-3 { grid-template-columns: 1fr; } }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; }
.input-group { display: flex; gap: .4rem; }
.inline-form { display: flex; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }
.inline-form select { flex: 1; min-width: 160px; width: auto; }

.filters {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem;
  align-items: end; margin-bottom: 1rem; padding: 1rem;
}
.filters > label:first-child { grid-column: span 2; }
.filters-actions { display: flex; gap: .4rem; }
.filter-check { padding-bottom: .6rem; white-space: nowrap; }
a.badge:hover { text-decoration: none; filter: brightness(.95); }

/* --- tlačítka ---------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  font: inherit; font-weight: 600; font-size: .9rem; padding: .55rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
  white-space: nowrap; transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; border-color: color-mix(in srgb, var(--border) 50%, var(--muted)); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); background: transparent; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-sm { padding: .35rem .7rem; font-size: .82rem; }
.btn-block { width: 100%; }

/* --- flash ---------------------------------------------------------------------- */
.flash {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem;
  background: var(--success-soft); border: 1px solid color-mix(in srgb, var(--st-vyreseny) 30%, transparent);
  animation: slidein .2s ease-out;
}
.flash-error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.flash-warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--st-resi_se) 30%, transparent); }
.flash-close { background: none; border: 0; font-size: 1.2rem; color: var(--muted); cursor: pointer; line-height: 1; }
@keyframes slidein { from { opacity: 0; transform: translateY(-4px); } }

/* --- přihlášení ------------------------------------------------------------------ */
.auth-page {
  min-height: 100vh; display: grid; place-items: center; padding: 1rem;
  background: radial-gradient(1200px 600px at 10% -10%, var(--accent-soft), transparent), var(--bg);
}
.auth-page .flash { width: min(400px, 100%); }
.auth-card { width: min(400px, 100%); padding: 2rem; }
.auth-brand { display: flex; align-items: center; gap: .85rem; margin-bottom: 1.5rem; }
.brand-lg { font-size: 1.5rem; font-weight: 500; }
.brand-lg b { color: var(--accent); }
.error-code { font-size: 4rem; font-weight: 800; color: var(--accent); line-height: 1; }

@media (max-width: 700px) {
  h1 { font-size: 1.35rem; }
  .hide-sm { display: none; }
  .topbar-inner { gap: .5rem 1rem; }
  .mainnav { order: 3; flex-basis: 100%; }
  .subject-foot { grid-template-columns: 1fr 1fr; }
  .table td, .table th { padding: .6rem .7rem; }
}
