/* Vzhled aplikace – tmavý režim a sdílené prvky (prefix ui-).
   Prefix „html“ zvyšuje specificitu nad třídy generované Tailwind CDN.
   Paleta slate je přemapovaná v theme.js. */
:root {
  --ui-bg:       #0f1114;
  --ui-surface:  #17191d;
  --ui-raised:   #1e2126;
  --ui-hover:    #262a30;
  --ui-border:   #2b2f36;
  --ui-border-2: #3b4048;
  --ui-text:     #ecedef;
  --ui-text-2:   #a8adb5;
  --ui-text-3:   #7f858e;
  --ui-accent:   #0e8175;
  --ui-accent-h: #0b6e64;
  --ui-side:     236px;
}

html { color-scheme: dark; }
html body {
  color: var(--ui-text); background-color: var(--ui-bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-feature-settings: 'cv11', 'ss03';
  -webkit-font-smoothing: antialiased;
}

/* bílé karty, navbar, modaly */
html .bg-white { background-color: var(--ui-surface); }

/* barevné texty (stejné odstíny se používají i jako pozadí tlačítek, proto přes CSS) */
html .text-indigo-600, html .hover\:text-indigo-600:hover { color: #5eead4; }
html .hover\:text-indigo-700:hover { color: #99f6e4; }
html .text-red-500, html .text-red-600, html .hover\:text-red-600:hover { color: #f87171; }
html .text-red-700, html .hover\:text-red-700:hover { color: #fca5a5; }
html .text-emerald-700 { color: #6ee7b7; }
html .text-amber-600, html .hover\:text-amber-600:hover { color: #fbbf24; }
html .text-amber-700 { color: #fcd34d; }

/* overlay modalů */
html .bg-black\/40 { background-color: rgba(3, 7, 18, .68); backdrop-filter: blur(3px); }

/* stíny jsou na tmavém pozadí neviditelné – přitmavit */
html .shadow-sm, html .shadow, html .shadow-md, html .shadow-lg, html .shadow-xl { --tw-shadow-color: rgba(0, 0, 0, .45); --tw-shadow: var(--tw-shadow-colored); }

/* month.php – dny v kalendáři */
html .day-weekend { background: #121418; }
html .day-working { background: var(--ui-surface); }

/* ── Postranní menu ─────────────────────────────────────────────────────── */
html body:has(.ui-side) { padding-left: var(--ui-side); }
.ui-side {
  position: fixed; inset: 0 auto 0 0; width: var(--ui-side); z-index: 40;
  display: flex; flex-direction: column; gap: 18px; padding: 16px 12px;
  background: var(--ui-surface); border-right: 1px solid var(--ui-border);
}
.ui-brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px; font-size: 14px; font-weight: 600; letter-spacing: -.01em; color: var(--ui-text); }
.ui-brand-mark { width: 26px; height: 26px; border-radius: 8px; flex: none; display: flex; align-items: center; justify-content: center; color: #fff; background: var(--ui-accent); }
.ui-brand-mark svg { width: 15px; height: 15px; }

.ui-ws { position: relative; }
.ui-ws > summary {
  list-style: none; cursor: pointer; user-select: none; display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 10px;
  border: 1px solid var(--ui-border); border-radius: 10px; background: var(--ui-raised); transition: border-color .12s;
}
.ui-ws > summary::-webkit-details-marker { display: none; }
.ui-ws > summary:hover, .ui-ws[open] > summary { border-color: var(--ui-border-2); }
.ui-ws-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ui-text); }
.ui-ws-chev { width: 14px; height: 14px; flex: none; color: var(--ui-text-3); }
.ui-ws-dot { width: 8px; height: 8px; border-radius: 99px; flex: none; }
.ui-ws-menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 220px; padding: 5px;
  background: var(--ui-raised); border: 1px solid var(--ui-border-2); border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.5);
}
.ui-ws-opt { display: flex; align-items: center; gap: 10px; padding: 8px 9px; border-radius: 8px; color: var(--ui-text); }
.ui-ws-opt:hover { background: var(--ui-hover); }
.ui-ws-opt b { display: block; font-size: 13px; font-weight: 600; }
.ui-ws-opt svg { width: 15px; height: 15px; margin-left: auto; flex: none; color: #5eead4; }

.ui-nav { display: flex; flex-direction: column; gap: 2px; }
.ui-nav a {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: 8px;
  font-size: 13.5px; font-weight: 500; color: var(--ui-text-2); transition: background .12s, color .12s;
}
.ui-nav a:hover { background: var(--ui-hover); color: var(--ui-text); }
.ui-nav a.is-on { background: rgba(20,184,166,.16); color: #99f6e4; }
.ui-nav svg { width: 17px; height: 17px; flex: none; }
.ui-side-foot { margin-top: auto; }

@media (max-width: 860px) {
  html body:has(.ui-side) { padding-left: 0; }
  .ui-side { position: static; width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--ui-border); }
  .ui-brand { display: none; }
  .ui-ws { flex: 1; min-width: 180px; }
  .ui-ws > summary { height: 38px; }
  .ui-nav { flex-direction: row; order: 3; width: 100%; overflow-x: auto; }
  .ui-side-foot { margin: 0; }
  .ui-side-foot .ui-nav { width: auto; order: 0; }
  .ui-nav-label { display: none; }
  .ui-side-foot a span { display: none; }
}

/* ── Stránka ────────────────────────────────────────────────────────────── */
.ui-page { max-width: 1180px; margin: 0 auto; padding: 28px 32px 64px; display: flex; flex-direction: column; gap: 18px; }
@media (max-width: 640px) { .ui-page { padding: 18px 14px 48px; } }
.ui-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; min-height: 38px; }
.ui-head h1 { font-size: 22px; font-weight: 650; letter-spacing: -.02em; color: var(--ui-text); line-height: 1.2; }
.ui-head p { font-size: 13px; color: var(--ui-text-3); margin-top: 2px; }
.ui-head-actions { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.ui-card { background: var(--ui-surface); border: 1px solid var(--ui-border); border-radius: 14px; }
.ui-section-title { font-size: 12px; font-weight: 600; color: var(--ui-text-3); }

/* ── Ovládací prvky: všechny stejně vysoké ──────────────────────────────── */
.ui-label { display: block; font-size: 12px; font-weight: 500; color: var(--ui-text-2); margin-bottom: 5px; white-space: nowrap; }
html .ui-ctl {
  display: block; width: 100%; min-width: 0; height: 38px; padding: 0 11px; margin: 0;
  -webkit-appearance: none; appearance: none;
  font-size: 13.5px; line-height: 36px; color: var(--ui-text);
  background-color: #121418; border: 1px solid var(--ui-border-2); border-radius: 9px; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
html .ui-ctl::placeholder { color: var(--ui-text-3); }
html .ui-ctl:hover { border-color: #50565f; }
html .ui-ctl:focus { border-color: #2dd4bf; box-shadow: 0 0 0 3px rgba(20,184,166,.22); }
html textarea.ui-ctl { height: auto; line-height: 1.5; padding: 8px 11px; resize: vertical; }
html select.ui-ctl {
  padding-right: 30px; cursor: pointer; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%237f858e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
html select.ui-ctl option, html select.ui-ctl optgroup { background: var(--ui-raised); color: var(--ui-text); }
html input[type="date"].ui-ctl { line-height: normal; }
.ui-ctl::-webkit-date-and-time-value { text-align: left; }
.ui-ctl::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .55; }
.ui-ctl[list]::-webkit-calendar-picker-indicator { display: none !important; }
.ui-ctl-sm, html .ui-ctl.ui-ctl-sm { height: 32px; line-height: 30px; font-size: 13px; border-radius: 8px; padding: 0 9px; }

.ui-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 14px; white-space: nowrap;
  font-size: 13.5px; font-weight: 550; color: var(--ui-text); background: var(--ui-raised);
  border: 1px solid var(--ui-border-2); border-radius: 9px; cursor: pointer; transition: background .12s, border-color .12s, opacity .12s;
}
.ui-btn:hover { background: var(--ui-hover); border-color: #50565f; }
.ui-btn:focus-visible { outline: 2px solid #2dd4bf; outline-offset: 2px; }
.ui-btn svg { width: 15px; height: 15px; flex: none; }
.ui-btn-primary { background: var(--ui-accent); border-color: transparent; color: #fff; }
.ui-btn-primary:hover { background: var(--ui-accent-h); border-color: transparent; }
.ui-btn-success { background: var(--ui-accent); border-color: transparent; color: #fff; }
.ui-btn-success:hover { background: var(--ui-accent-h); border-color: transparent; }
.ui-btn-danger { background: #dc2626; border-color: transparent; color: #fff; }
.ui-btn-danger:hover { background: #b91c1c; border-color: transparent; }
.ui-btn-quiet { background: transparent; border-color: transparent; color: var(--ui-text-2); }
.ui-btn-quiet:hover { background: var(--ui-hover); border-color: transparent; color: var(--ui-text); }
.ui-btn.is-off { opacity: .45; pointer-events: none; }

.ui-seg { display: inline-flex; height: 38px; padding: 3px; gap: 2px; background: #121418; border: 1px solid var(--ui-border); border-radius: 9px; overflow-x: auto; max-width: 100%; }
.ui-seg a { display: flex; align-items: center; padding: 0 11px; border-radius: 6px; font-size: 12.5px; font-weight: 500; color: var(--ui-text-2); white-space: nowrap; }
.ui-seg a:hover { color: var(--ui-text); }
.ui-seg a.is-on { background: var(--ui-raised); color: var(--ui-text); box-shadow: 0 1px 2px rgba(0,0,0,.4); }

.ui-pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 11.5px; font-weight: 550; white-space: nowrap; }
.ui-pill svg { width: 11px; height: 11px; }
.ui-pill-ok   { background: rgba(16,185,129,.13); color: #6ee7b7; }
.ui-pill-warn { background: rgba(245,158,11,.13); color: #fcd34d; }
.ui-pill-late { background: rgba(239,68,68,.14); color: #fca5a5; }
.ui-pill-mute { background: var(--ui-raised); color: var(--ui-text-2); }

/* ── Tabulky a seznamy ──────────────────────────────────────────────────── */
.ui-sum { display: flex; flex-wrap: wrap; gap: 4px 20px; padding: 11px 16px; font-size: 12.5px; color: var(--ui-text-3); border-bottom: 1px solid var(--ui-border); }
.ui-sum b { font-weight: 600; color: var(--ui-text); }
.ui-num { font-variant-numeric: tabular-nums; }
.ui-day { display: flex; align-items: center; gap: 8px; padding: 8px 16px; font-size: 12.5px; background: #131519; border-bottom: 1px solid var(--ui-border); }
.ui-day:not(:first-child) { border-top: 1px solid var(--ui-border); }
.ui-day b { font-weight: 600; color: var(--ui-text); }
.ui-day span { color: var(--ui-text-3); }
.ui-day .ui-num { margin-left: auto; font-weight: 600; color: var(--ui-text-2); padding-right: 58px; }
.ui-row { display: flex; align-items: flex-start; gap: 12px; padding: 10px 16px; transition: background .1s; }
.ui-row + .ui-row { border-top: 1px solid rgba(43,47,54,.55); }
.ui-row:hover { background: rgba(38,42,48,.45); }
.ui-row:last-child { border-radius: 0 0 13px 13px; }
.ui-row-main { flex: 1; min-width: 0; }
.ui-row-title { font-size: 13.5px; line-height: 1.45; color: var(--ui-text); overflow-wrap: anywhere; }
.ui-row-meta { font-size: 12px; color: var(--ui-text-3); margin-top: 1px; }
.ui-row-time { width: 46px; flex: none; text-align: right; font-size: 13.5px; font-weight: 600; line-height: 1.45; color: var(--ui-text); }
.ui-row-tools { width: 46px; flex: none; display: flex; justify-content: flex-end; gap: 2px; opacity: 0; transition: opacity .1s; }
.ui-row:hover .ui-row-tools, .ui-row-tools:focus-within { opacity: 1; }
@media (hover: none) { .ui-row-tools { opacity: 1; } }
.ui-icon { width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; border-radius: 6px; font-size: 13px; color: var(--ui-text-3); cursor: pointer; background: transparent; border: 0; }
.ui-icon:hover { background: var(--ui-hover); color: var(--ui-text); }
.ui-icon.is-danger:hover { color: #f87171; }

.ui-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.ui-table th { padding: 10px 16px; text-align: left; font-size: 12px; font-weight: 500; color: var(--ui-text-3); background: #131519; border-bottom: 1px solid var(--ui-border); white-space: nowrap; }
.ui-table th:first-child { border-top-left-radius: 13px; }
.ui-table th:last-child { border-top-right-radius: 13px; }
.ui-table td { padding: 12px 16px; border-top: 1px solid rgba(43,47,54,.55); vertical-align: middle; }
.ui-table tbody tr:first-child td { border-top: 0; }
.ui-table tbody tr:hover td { background: rgba(38,42,48,.4); }
.ui-table .is-right { text-align: right; }

.ui-avatar { width: 32px; height: 32px; border-radius: 9px; flex: none; display: flex; align-items: center; justify-content: center; font-size: 11.5px; font-weight: 600; color: var(--ui-text-2); background: var(--ui-raised); border: 1px solid var(--ui-border); }
.ui-tag { display: inline-flex; align-items: center; gap: 2px; height: 22px; padding: 0 3px 0 8px; font-size: 11.5px; color: var(--ui-text-2); background: var(--ui-raised); border-radius: 6px; }
.ui-tag button { background: none; border: 0; color: inherit; cursor: pointer; }
.ui-tag button:hover { color: var(--ui-text); }
.ui-tag .ui-tag-x { width: 16px; height: 16px; line-height: 15px; border-radius: 4px; color: var(--ui-text-3); }
.ui-tag .ui-tag-x:hover { background: var(--ui-hover); color: #f87171; }

/* ── Měsíční kartičky (Přehledy) ────────────────────────────────────────── */
.ui-months { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.ui-month { display: block; padding: 15px 18px; background: var(--ui-surface); border: 1px solid var(--ui-border); border-radius: 14px; transition: border-color .12s, background .12s, transform .12s; }
.ui-month-hours { margin-top: 6px; font-size: 24px; font-weight: 650; letter-spacing: -.02em; color: var(--ui-text); }
.ui-month-hours small { font-size: 14px; font-weight: 500; letter-spacing: 0; color: var(--ui-text-3); }
.ui-month:hover { border-color: rgba(45,212,191,.55); background: #1c1f24; transform: translateY(-1px); }

/* ── Faktury po letech ───────────────────────────────────────────────────── */
.ui-year-head { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; }
.ui-year-title { font-size: 18px; font-weight: 650; letter-spacing: -.01em; color: var(--ui-text); }
.ui-year-sum { font-size: 18px; font-weight: 650; letter-spacing: -.01em; color: var(--ui-text); }
.ui-year .ui-table th { border-radius: 0; border-top: 1px solid var(--ui-border); }
.ui-meter { height: 6px; border-radius: 99px; overflow: hidden; background: var(--ui-border); }
.ui-meter span { display: block; height: 100%; border-radius: 99px; background: var(--ui-accent); }
.ui-meter.is-near span { background: #f59e0b; }
.ui-meter.is-over span { background: #ef4444; }
.ui-meter-left.is-near { color: #fcd34d; }
.ui-meter-left.is-over { color: #fca5a5; }

/* ── Přidané prvky: AI pole, přepínač, ARES, položky faktury, kalendář ─────── */
.ui-nav-label { padding: 4px 10px 6px; font-size: 11.5px; font-weight: 500; color: var(--ui-text-3); }
.ui-ai { display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 14px; background: var(--ui-surface); border: 1px solid var(--ui-border); border-radius: 12px; }
.ui-ai:focus-within { border-color: #2dd4bf; box-shadow: 0 0 0 3px rgba(20,184,166,.15); }
.ui-ai-badge { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; font-weight: 500; color: #5eead4; background: rgba(20,184,166,.16); padding: 3px 7px; border-radius: 5px; }
.ui-ai-input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 14px; color: var(--ui-text); height: 38px; }
.ui-ai-input::placeholder { color: var(--ui-text-3); }
.ui-ai .ui-btn[disabled] { opacity: .6; cursor: progress; }

.ui-switch { display: inline-flex; align-items: center; gap: 9px; height: 38px; font-size: 13.5px; font-weight: 500; color: var(--ui-text-2); cursor: pointer; user-select: none; white-space: nowrap; }
.ui-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.ui-switch-track { position: relative; width: 36px; height: 20px; flex: none; border-radius: 99px; background: var(--ui-border-2); transition: background .15s; }
.ui-switch-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 99px; background: #fff; transition: transform .15s; }
.ui-switch input:checked + .ui-switch-track { background: #059669; }
.ui-switch input:checked + .ui-switch-track::after { transform: translateX(16px); }
.ui-switch input:focus-visible + .ui-switch-track { outline: 2px solid #2dd4bf; outline-offset: 2px; }

.ui-ares { margin-top: 6px; padding: 6px; font-size: 12.5px; color: var(--ui-text-2); background: #121418; border: 1px solid var(--ui-border); border-radius: 9px; }
.ui-ares-opt { display: block; width: 100%; text-align: left; padding: 6px 8px; border-radius: 6px; background: none; border: 0; color: var(--ui-text); cursor: pointer; }
.ui-ares-opt:hover { background: var(--ui-hover); }
.ui-ares-opt b { display: block; font-weight: 600; font-size: 13px; }
.ui-ares-opt small { color: var(--ui-text-3); font-size: 11.5px; }

.ui-items td { padding: 8px 6px; }
.ui-items td:first-child, .ui-items th:first-child { padding-left: 16px; }
.ui-items td:last-child, .ui-items th:last-child { padding-right: 12px; }
.ui-items th { padding-left: 6px; padding-right: 6px; }
.ui-items input:disabled { opacity: .7; }
.ui-target:target td { background: rgba(20,184,166,.14); }
html .ui-ctl:disabled { opacity: .7; cursor: default; }

.flatpickr-calendar.open { z-index: 60; }
html .flatpickr-calendar, html .flatpickr-months .flatpickr-month, html .flatpickr-current-month .flatpickr-monthDropdown-months, html span.flatpickr-weekday, html .flatpickr-weekdays { background: var(--ui-raised); }
html .flatpickr-calendar { border: 1px solid var(--ui-border-2); box-shadow: 0 16px 40px rgba(0,0,0,.5); }
html .flatpickr-calendar.arrowTop:before, html .flatpickr-calendar.arrowTop:after { display: none; }
html .flatpickr-day.selected, html .flatpickr-day.startRange, html .flatpickr-day.endRange, html .flatpickr-day.selected:hover, html .flatpickr-day.startRange:hover, html .flatpickr-day.endRange:hover { background: var(--ui-accent); border-color: var(--ui-accent); color: #fff; }
html .flatpickr-day.inRange { background: #123f3b; border-color: transparent; box-shadow: -5px 0 0 #123f3b, 5px 0 0 #123f3b; }
html .flatpickr-day:hover { background: var(--ui-hover); border-color: transparent; }
html .flatpickr-day.today { border-color: var(--ui-text-3); }
