/* Správa zakázek – styly. Bez inline stylů (CSP style-src 'self'). */

@font-face { font-family: 'Inconsolata'; font-weight: 400; font-display: swap; src: url('../fonts/Inconsolata-Regular.ttf') format('truetype'); }
@font-face { font-family: 'Inconsolata'; font-weight: 500; font-display: swap; src: url('../fonts/Inconsolata-Medium.ttf') format('truetype'); }
@font-face { font-family: 'Inconsolata'; font-weight: 600; font-display: swap; src: url('../fonts/Inconsolata-SemiBold.ttf') format('truetype'); }
@font-face { font-family: 'Inconsolata'; font-weight: 700; font-display: swap; src: url('../fonts/Inconsolata-Bold.ttf') format('truetype'); }

:root {
    --c-primary: #0c4b6a;
    --c-primary-hover: #093a52;
    --c-accent: #84a4a8;
    --c-text: #343a40;
    --c-muted: #6c757d;
    --c-line: #e5eaed;
    --c-bg: #fafbfc;
    --c-surface: #ffffff;
    --c-danger: #c62e3d;
    --c-success: #2f8f2a;
    --c-warning: #b9770e;
    --c-info: #0077b6;

    --s-new: #0077b6;
    --s-progress: #b9770e;
    --s-waiting: #7b47c2;
    --s-completed: #2f8f2a;
    --s-cancelled: #6c757d;

    --radius: 6px;
    --gap: 16px;
    --font: 'Inconsolata', ui-monospace, SFMono-Regular, Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.55; color: var(--c-text); background: var(--c-bg); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; font-weight: 600; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; margin-top: 1.2em; }
p { margin: 0 0 .8em; }
a { color: var(--c-primary); }
a:hover { color: var(--c-primary-hover); }
.container { max-width: 1240px; margin: 0 auto; padding: 0 var(--gap); }
.muted { color: var(--c-muted); }
.small { font-size: .85rem; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-line; }
.right { text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.is-hidden { display: none; }
[hidden] { display: none !important; }
.icon { vertical-align: -0.2em; flex-shrink: 0; }

/* ---- Hlavička ---- */
.site-header { background: var(--c-surface); border-bottom: 1px solid var(--c-line); position: sticky; top: 0; z-index: 10; }
.header-inner { display: flex; align-items: center; gap: 24px; min-height: 60px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; font-weight: 600; color: var(--c-text); text-decoration: none; }
.logo .icon { color: var(--c-accent); }
.main-nav { display: flex; gap: 4px; flex: 1; }
.main-nav a { padding: 6px 12px; border-radius: var(--radius); text-decoration: none; color: var(--c-text); }
.main-nav a:hover { background: var(--c-bg); }
.main-nav a.active { background: var(--c-primary); color: #fff; }
.user-menu { display: flex; align-items: center; gap: 12px; }
.user-menu form { margin: 0; }
.user-email { color: var(--c-muted); font-size: .9rem; }
.nav-toggle { display: none; }
.main { padding-top: 24px; padding-bottom: 48px; min-height: calc(100vh - 140px); }
.site-footer { border-top: 1px solid var(--c-line); padding: 16px 0; color: var(--c-muted); font-size: .85rem; }

/* ---- Tlačítka ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border: 1px solid transparent; border-radius: var(--radius); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; line-height: 1.3; background: none; color: inherit; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-hover); color: #fff; }
.btn-secondary { background: var(--c-surface); border-color: var(--c-line); color: var(--c-text); }
.btn-secondary:hover { border-color: var(--c-accent); color: var(--c-text); }
.btn-danger { background: var(--c-danger); color: #fff; }
.btn-danger:hover { filter: brightness(.92); color: #fff; }
.btn-link { color: var(--c-primary); text-decoration: underline; padding-left: 4px; padding-right: 4px; }
.btn-template { background: #eef4f5; border-color: #d7e3e5; color: var(--c-text); }
.btn-template:hover { border-color: var(--c-accent); }
.btn-small { padding: 4px 10px; font-size: .9rem; }
.btn-block { width: 100%; }
.btn-icon { border: 1px solid var(--c-line); background: var(--c-surface); border-radius: var(--radius); width: 30px; height: 30px; cursor: pointer; font: inherit; font-size: 1.05rem; line-height: 1; color: var(--c-text); }
.btn-icon:hover:not(:disabled) { border-color: var(--c-accent); }
.btn-icon:disabled { opacity: .35; cursor: default; }
.btn-icon.danger { color: var(--c-danger); }
form.inline { display: inline; margin: 0; }

/* ---- Formuláře ---- */
.form-control { width: 100%; padding: 8px 10px; border: 1px solid #ced4da; border-radius: var(--radius); font: inherit; background: #fff; color: inherit; }
.form-control:focus { outline: 2px solid rgba(12, 75, 106, .25); border-color: var(--c-primary); }
.form-control-small { padding: 4px 8px; width: auto; font-size: .9rem; }
.form-control-narrow { max-width: 160px; }
textarea.form-control { resize: vertical; }
label { display: block; font-size: .9rem; margin-bottom: 4px; color: #495057; }
.form-group { margin-bottom: 14px; position: relative; min-width: 0; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-size: .9rem; margin-bottom: 6px; color: #495057; padding: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 var(--gap); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-4 { grid-column: 1 / -1; }
.field-error { color: var(--c-danger); font-size: .85rem; margin: 4px 0 0; }
.hint { color: var(--c-muted); font-size: .85rem; margin: 4px 0 0; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; margin: 0 16px 6px 0; cursor: pointer; }
.checkbox input { margin: 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.inline-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0; }
.inline-form label { margin: 0; }
.stack > * + * { margin-top: 12px; }
.radio-list label { display: block; padding: 8px 10px; border: 1px solid var(--c-line); border-radius: var(--radius); margin-bottom: 8px; cursor: pointer; font-size: 1rem; color: var(--c-text); }
.radio-list label:hover { border-color: var(--c-accent); }

/* ---- Rozvržení ---- */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--gap); margin-bottom: 20px; flex-wrap: wrap; }
.page-header h1 { margin-bottom: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: 8px; padding: 20px; margin-bottom: 20px; }
.card.narrow { max-width: 480px; }
.card-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-header h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 0 20px; }
.empty { padding: 40px; text-align: center; color: var(--c-muted); background: var(--c-surface); border: 1px dashed var(--c-line); border-radius: 8px; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--c-line); }
.danger-zone p { margin: 0; }

/* ---- Hlášky ---- */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }
.alert-success { background: #edf7ec; border-color: #c4e3c1; color: #1e5e1a; }
.alert-error { background: #fdeeee; border-color: #f2c4c8; color: #8a1f2a; }
.alert-info { background: #eaf4fb; border-color: #bcdcf0; color: #0b4f78; }

/* ---- Tabulky ---- */
.table-wrap { overflow-x: auto; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: 8px; }
.card .table-wrap { border: 0; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--c-line); vertical-align: top; }
.table thead th { font-weight: 600; font-size: .9rem; color: #495057; background: #f6f8f9; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.table tfoot td { font-weight: 600; border-bottom: 0; border-top: 1px solid var(--c-line); }
.table tfoot .subtotal td { font-weight: 400; color: var(--c-muted); font-size: .9rem; border-top: 0; padding-top: 4px; padding-bottom: 4px; }
.table-clickable tbody tr { cursor: pointer; }
.table-clickable tbody tr:hover { background: #f6f9fa; }
.table-clickable td a { color: inherit; text-decoration: none; }
.truncate { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sort-link { color: inherit; text-decoration: none; }
.sort-link.active { color: var(--c-primary); }
.diff-table th { width: 140px; }

/* ---- Nástrojová lišta, stránkování ---- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input[type="search"] { flex: 1 1 260px; width: auto; }
.toolbar select { width: auto; }
.column-picker { position: relative; margin-left: auto; }
.column-picker summary { list-style: none; }
.column-picker summary::-webkit-details-marker { display: none; }
.column-picker-panel { position: absolute; right: 0; top: calc(100% + 6px); background: var(--c-surface); border: 1px solid var(--c-line); border-radius: 8px; padding: 12px 16px; z-index: 5; min-width: 220px; box-shadow: 0 8px 24px rgba(0, 0, 0, .08); }
.column-picker-panel label { display: flex; gap: 8px; align-items: center; color: var(--c-text); font-size: .95rem; }
.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.page { min-width: 36px; padding: 6px 10px; text-align: center; border: 1px solid var(--c-line); border-radius: var(--radius); background: var(--c-surface); text-decoration: none; color: var(--c-text); }
.page.active { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.page.dots { border-color: transparent; background: none; }

/* ---- Stavy ---- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: #eef1f3; color: var(--c-muted); white-space: nowrap; }
.status-new { background: #e3f1fa; color: var(--s-new); }
.status-in-progress { background: #fbf1df; color: var(--s-progress); }
.status-waiting-for-payment { background: #f1e9fb; color: var(--s-waiting); }
.status-completed { background: #e7f4e6; color: var(--s-completed); }
.status-cancelled { background: #eef0f2; color: var(--s-cancelled); text-decoration: line-through; }

/* ---- Dashboard ---- */
.search-form { display: flex; gap: 8px; min-width: min(420px, 100%); }
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.action-tile { display: flex; align-items: center; gap: 10px; padding: 14px 16px; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: 8px; text-decoration: none; color: var(--c-text); font-weight: 500; }
.action-tile:hover { border-color: var(--c-accent); color: var(--c-primary); }
.action-tile .icon { color: var(--c-accent); }
.segmented { display: inline-flex; border: 1px solid var(--c-line); border-radius: var(--radius); overflow: hidden; }
.segmented a { padding: 4px 12px; text-decoration: none; color: var(--c-text); font-size: .9rem; }
.segmented a + a { border-left: 1px solid var(--c-line); }
.segmented a.active { background: var(--c-primary); color: #fff; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 12px; }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 1px solid var(--c-line); border-radius: 8px; background: var(--c-surface); text-decoration: none; color: inherit; border-left-width: 4px; }
a.stat:hover { border-color: var(--c-accent); }
.stat-label { font-size: .85rem; color: var(--c-muted); }
.stat-value { font-size: 1.6rem; font-weight: 700; }
.stat-sub { font-size: .85rem; color: var(--c-muted); }
.stat-new { border-left-color: var(--s-new); }
.stat-in-progress { border-left-color: var(--s-progress); }
.stat-waiting { border-left-color: var(--s-waiting); }
.stat-completed { border-left-color: var(--s-completed); }
.stat-revenue { border-left-color: var(--c-primary); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--c-line); margin-bottom: 20px; }
.tabs a { padding: 8px 16px; text-decoration: none; color: var(--c-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--c-primary); border-bottom-color: var(--c-primary); font-weight: 600; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline-item a { display: grid; grid-template-columns: 110px 1fr; gap: 2px 12px; padding: 10px 12px; border-left: 3px solid var(--c-line); text-decoration: none; color: inherit; }
.timeline-item a:hover { background: #f6f9fa; }
.timeline-date { font-weight: 600; grid-row: span 2; }
.timeline-meta { font-size: .85rem; color: var(--c-muted); }
.deadline-overdue a { border-left-color: var(--c-danger); }
.deadline-overdue .timeline-date { color: var(--c-danger); }
.deadline-urgent a { border-left-color: var(--c-warning); }
.deadline-normal a { border-left-color: var(--c-accent); }
.event-new a { border-left-color: var(--s-new); }
.event-update a { border-left-color: var(--c-accent); }
.event-completed a { border-left-color: var(--s-completed); }
.simple-list { list-style: none; padding: 0; margin: 0; }
.simple-list li { padding: 6px 0; border-bottom: 1px solid var(--c-line); display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.simple-list li:last-child { border-bottom: 0; }

/* Kalendář */
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--c-line); border-left: 1px solid var(--c-line); margin-bottom: 16px; }
.calendar-weekday { padding: 6px; font-size: .85rem; font-weight: 600; text-align: center; background: #f6f8f9; border-right: 1px solid var(--c-line); border-bottom: 1px solid var(--c-line); }
.calendar-day { min-height: 96px; padding: 4px; border-right: 1px solid var(--c-line); border-bottom: 1px solid var(--c-line); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.calendar-day.other-month { background: #fafafa; color: #adb5bd; }
.calendar-day.today { background: #eef6f9; }
.calendar-day.today .calendar-num { background: var(--c-primary); color: #fff; border-radius: 999px; padding: 0 6px; }
.calendar-num { font-size: .85rem; align-self: flex-end; }
.calendar-event { display: block; font-size: .78rem; padding: 2px 6px; border-radius: 4px; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-event.overdue { outline: 1px solid var(--c-danger); }

/* ---- Formulář zakázky ---- */
.decision { border-color: var(--c-warning); background: #fffaf0; }
.autocomplete-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; margin: 2px 0 0; padding: 4px 0; list-style: none; background: #fff; border: 1px solid var(--c-line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0, 0, 0, .1); max-height: 280px; overflow-y: auto; }
.autocomplete-list li { padding: 6px 12px; cursor: pointer; }
.autocomplete-list li[aria-selected="true"], .autocomplete-list li:hover { background: #eef4f5; }
.autocomplete-list .ac-meta { display: block; font-size: .8rem; color: var(--c-muted); }
.items { display: flex; flex-direction: column; gap: 12px; }
.item-row { border: 1px solid var(--c-line); border-radius: 8px; padding: 10px 14px 0; background: #fcfdfd; }
.item-row-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.item-number { font-weight: 600; color: var(--c-muted); }
.item-grid { grid-template-columns: 2fr 1fr 1fr; }
.item-grid .span-2 { grid-column: span 1; }
.template-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.order-summary { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--c-line); }
.type-totals { display: flex; gap: 16px; flex-wrap: wrap; color: var(--c-muted); font-size: .9rem; }
.grand-total { font-size: 1.1rem; }

/* ---- Detail ---- */
.details { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 12px; }
.details dt { color: var(--c-muted); }
.details dd { margin: 0; }

/* ---- Nastavení ---- */
.settings-menu { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.settings-item { display: flex; gap: 14px; align-items: flex-start; padding: 18px; border: 1px solid var(--c-line); border-radius: 8px; background: var(--c-surface); text-decoration: none; color: var(--c-text); }
.settings-item:hover { border-color: var(--c-accent); }
.settings-item .icon { color: var(--c-accent); }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px; }
.icon-option { display: flex; align-items: center; justify-content: center; height: 56px; border: 1px solid var(--c-line); border-radius: 8px; cursor: pointer; margin: 0; color: var(--c-text); }
.icon-option input { position: absolute; opacity: 0; pointer-events: none; }
.icon-option:has(input:checked) { border-color: var(--c-primary); background: #eef4f7; color: var(--c-primary); }
.icon-option:has(input:focus-visible) { outline: 2px solid var(--c-primary); }
.template-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.template-item { border: 1px solid var(--c-line); border-radius: 8px; padding: 8px 12px; }
.template-item summary { display: flex; gap: 12px; align-items: center; cursor: pointer; flex-wrap: wrap; }
.template-item[open] summary { margin-bottom: 12px; }
.template-actions { margin-left: auto; display: flex; gap: 4px; }

/* ---- Statistiky ---- */
.filters .form-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.type-filter { margin-bottom: 10px; }
.quick-ranges { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; font-size: .9rem; }
.trend { font-weight: 600; }
.trend-up { color: var(--c-success); }
.trend-down { color: var(--c-danger); }
.trend-flat { color: var(--c-muted); }
.chart-wrap { width: 100%; overflow-x: auto; }
.chart { width: 100%; min-width: 600px; height: auto; display: block; }
.chart .grid { stroke: var(--c-line); stroke-width: 1; }
.chart .axis-line { stroke: #adb5bd; stroke-width: 1; }
.chart .axis { font-family: var(--font); font-size: 11px; fill: var(--c-muted); }
.chart .trend { fill: none; stroke: var(--c-danger); stroke-width: 2.5; stroke-dasharray: 6 4; }
.chart .bar:hover rect { opacity: .8; }
.series-0 { fill: #0c4b6a; background: #0c4b6a; }
.series-1 { fill: #84a4a8; background: #84a4a8; }
.series-2 { fill: #d08c2a; background: #d08c2a; }
.series-3 { fill: #7b47c2; background: #7b47c2; }
.series-4 { fill: #3c9a5f; background: #3c9a5f; }
.series-5 { fill: #c04d6a; background: #c04d6a; }
.series-6 { fill: #3a86c8; background: #3a86c8; }
.series-7 { fill: #8d8d55; background: #8d8d55; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 16px; list-style: none; padding: 0; margin: 12px 0 0; font-size: .9rem; }
.chart-legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.swatch-trend { height: 0; border-top: 3px dashed var(--c-danger); border-radius: 0; }

/* ---- Přihlášení ---- */
.auth-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; background: linear-gradient(160deg, #eef4f5 0%, var(--c-bg) 60%); }
.auth-container { width: 100%; max-width: 420px; padding: var(--gap); }
.auth-card { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: 10px; padding: 32px; box-shadow: 0 10px 30px rgba(12, 75, 106, .06); }
.auth-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; font-size: .9rem; flex-wrap: wrap; }

/* ---- Mobil ---- */
@media (max-width: 800px) {
    /* Bez JS zůstane menu rozbalené; s JS (třída .js na <html>) se skládá pod tlačítko. */
    .main-nav { flex-direction: column; width: 100%; }
    .user-menu { width: 100%; justify-content: space-between; padding-bottom: 12px; }
    .js .nav-toggle { display: inline-flex; margin-left: auto; padding: 6px 12px; border: 1px solid var(--c-line); border-radius: var(--radius); background: var(--c-surface); font: inherit; }
    .js .main-nav, .js .user-menu { display: none; }
    .js .site-header.nav-open .main-nav, .js .site-header.nav-open .user-menu { display: flex; }
    .form-grid .span-2 { grid-column: 1 / -1; }
    .item-grid { grid-template-columns: 1fr 1fr; }
    .item-grid .span-2 { grid-column: 1 / -1; }
    .calendar-day { min-height: 64px; }
    .calendar-event { font-size: .7rem; padding: 1px 3px; }
    .timeline-item a { grid-template-columns: 1fr; }
    .timeline-date { grid-row: auto; }
    .card { padding: 16px; }
    .column-picker { margin-left: 0; }
    .column-picker-panel { left: 0; right: auto; }
}

@media print {
    .site-header, .site-footer, .actions, .danger-zone, .toolbar, .pagination { display: none !important; }
    body { background: #fff; }
    .card { border: 0; padding: 0; }
}
