/* Colours live only in the two blocks below (light in :root, dark under
   prefers-color-scheme). A colour literal further down is a bug: use a token,
   or add one to both blocks. */
:root {
    color-scheme: light;

    /* Brand: identical in both themes. */
    --brand-dark: #1a1a1a;
    --brand-green: #8bc53f;
    --brand-green-dark: #6fa22f;
    --brand-green-text: #4d7c23;

    --bg: #f5f5f5;
    --scrim: rgba(245, 245, 245, 0.88);
    --surface: #ffffff;
    --shadow: rgba(0, 0, 0, 0.1);
    --text: #1a1a1a;
    --text-muted: #6b7280;
    --link: var(--brand-green-text);
    --border: #e5e7eb;

    --chrome-bg: var(--brand-dark);
    --chrome-text: #ffffff;
    --chrome-link: #d1d5db;
    --chrome-border: #000000;

    --input-bg: #ffffff;
    --input-border: #ccc;
    --focus-ring: rgba(139, 197, 63, 0.35);

    --btn-secondary-bg: #e5e7eb;
    --btn-secondary-text: var(--brand-dark);
    --btn-secondary-hover: #d1d5db;
    --btn-danger-bg: #fecaca;
    --btn-danger-text: #7f1d1d;
    --btn-danger-hover: #fca5a5;

    --success-bg: #d1fae5;
    --success-text: #065f46;
    --error-bg: #fee2e2;
    --error-text: #991b1b;
    --pending-bg: #fde68a;
    --pending-text: #78350f;
    --row-pending-bg: #fef3c7;
    --badge-bg: #e5e7eb;
    --badge-text: #374151;
}
@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;

        --bg: #14161a;
        --scrim: rgba(20, 22, 26, 0.90);
        --surface: #1e2228;
        --shadow: rgba(0, 0, 0, 0.45);
        --text: #e8eaed;
        --text-muted: #9aa3ae;
        --link: #a3d160;
        --border: #333941;

        /* Header and nav a step lighter than the near-black page. */
        --chrome-bg: #22262c;
        --chrome-text: #e8eaed;
        --chrome-link: #c3c8d0;
        --chrome-border: #0d0f12;

        --input-bg: #14171b;
        --input-border: #3d444d;

        --btn-secondary-bg: #333941;
        --btn-secondary-text: #e8eaed;
        --btn-secondary-hover: #414852;
        --btn-danger-bg: #5a2222;
        --btn-danger-text: #ffd5d5;
        --btn-danger-hover: #6e2a2a;

        --success-bg: #123a2c;
        --success-text: #8ff0c4;
        --error-bg: #4a1f1f;
        --error-text: #ffc9c9;
        --pending-bg: #5a4410;
        --pending-text: #ffdf8a;
        --row-pending-bg: #3a3010;
        --badge-bg: #333941;
        --badge-text: #d0d5dc;
    }
}
* { box-sizing: border-box; }
body {
    font-family: system-ui, -apple-system, sans-serif;
    margin: 0;
    padding-bottom: 88px;
    background-color: var(--bg);
    background-image: linear-gradient(var(--scrim), var(--scrim)), url("../img/background.743a460a4288.jpg");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    color: var(--text);
}
a { color: var(--link); }
header {
    background: var(--chrome-bg);
    color: var(--chrome-text);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
header a { color: var(--chrome-text); text-decoration: none; font-weight: 700; letter-spacing: 0.02em; }
header .logo { height: 32px; width: auto; display: block; }
header .header-actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; justify-content: flex-end; }
header a.header-link {
    color: var(--chrome-link);
    font-weight: 600;
    letter-spacing: normal;
}
header a.header-link:hover { color: var(--brand-green); text-decoration: underline; }
header form.logout-form { margin: 0; }
header button.logout-link {
    width: auto;
    margin: 0;
    padding: 0;
    background: none;
    border: none;
    color: var(--chrome-link);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}
header button.logout-link:hover { background: none; color: var(--brand-green); text-decoration: underline; }
main { padding: 1rem; max-width: 480px; margin: 0 auto; }
.card {
    background: var(--surface);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px var(--shadow);
}
label { display: block; font-weight: 600; margin-top: 0.75rem; margin-bottom: 0.25rem; }
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--input-border);
    border-radius: 6px;
}
/* Otherwise a textarea keeps the browser's monospace font and its own width. */
textarea { font-family: inherit; resize: vertical; box-sizing: border-box; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand-green);
    box-shadow: 0 0 0 3px var(--focus-ring);
}
button, .btn {
    display: inline-block;
    width: 100%;
    padding: 0.9rem;
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 700;
    border: none;
    border-radius: 6px;
    background: var(--brand-green);
    color: var(--brand-dark);
    margin-top: 1rem;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
}
button:hover, .btn:hover { background: var(--brand-green-dark); }
/* Load-bearing: the `display` above beats the UA `[hidden]` rule, so without
   this a hidden „− odebrat řádek" still renders. */
button[hidden], .btn[hidden] { display: none; }
/* „Odesílám…" (static/js/submit_feedback.js). */
button:disabled { opacity: 0.7; cursor: progress; }
.messages { list-style: none; padding: 0; }
.messages li { padding: 0.75rem; border-radius: 6px; margin-bottom: 0.5rem; }
.messages .success { background: var(--success-bg); color: var(--success-text); }
.messages .error { background: var(--error-bg); color: var(--error-text); }
/* Above Zpracování: the user's own jobs still awaiting approval. */
.pending-notice { padding: 0.75rem; border-radius: 6px; margin: 0 0 0.5rem; background: var(--row-pending-bg); color: var(--text); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.5rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text); border-bottom: 2px solid var(--brand-green); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* job_detail's label/value table: values wrap, so a long „Poznámky" (up to
   2000 characters, maybe one unbroken URL) stays inside the card. `anywhere`,
   not `break-word`, because only it lowers the cell's min-content width. */
.detail-fields th { vertical-align: top; }
.detail-fields td { white-space: normal; overflow-wrap: anywhere; }
nav.bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: var(--chrome-bg);
    border-top: 1px solid var(--chrome-border);
}
/* Sized to its label rather than an equal share, so a manager's six entries
   fit a phone without breaking „Zpracování" mid-word. */
nav.bottom a {
    flex: 1 1 auto;
    min-width: 0;
    text-align: center;
    padding: 0.7rem 0.25rem;
    text-decoration: none;
    color: var(--chrome-link);
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.2;
    overflow-wrap: break-word;
}
nav.bottom a:hover, nav.bottom a:active { color: var(--brand-green); }
/* A row wraps rather than crushing its boxes. Number boxes are three
   characters wide (placeholders are bare units) and the pickers take the rest,
   so even the machines row and the two-picker refuel row fit a phone. .tons, .mth and .hours are
   five characters (five-digit values; .hours only to line up with the tonnes
   boxes), and the picker's basis is one character narrower to compensate.
   Spin buttons are removed: they would eat the box. */
.item-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: flex-end; margin-bottom: 0.5rem; }
.date-override { margin-top: 1rem; }
.item-row > div { flex: 1 1 calc(7rem - 1ch); }
.item-row > div:has(> input[type="number"]) { flex: 0 0 auto; }
.item-row input[type="number"] {
    width: calc(3ch + 1rem + 2px);
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    appearance: textfield;
    -moz-appearance: textfield;
}
.item-row input[type="number"]:is(.tons, .mth, .hours) { width: calc(5ch + 1rem + 2px); }
.item-row input[type="number"]::-webkit-inner-spin-button,
.item-row input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
/* Pending jobs must stand out on Přehled. */
tr.row-pending > td { background: var(--row-pending-bg); }
.status-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
    background: var(--badge-bg);
    color: var(--badge-text);
}
.status-badge.pending { background: var(--pending-bg); color: var(--pending-text); }
.status-badge.approved { background: var(--success-bg); color: var(--success-text); }
/* Equal grid columns rather than flex, which made the padded links wider than
   the <form> around „Schválit". `minmax(0, …)` stops a long label widening
   its column. */
.job-actions { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 0.5rem; }
.quick-filters { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.quick-filters .btn {
    flex: 1 1 auto;
    width: auto;
    margin: 0;
    padding: 0.6rem 0.75rem;
    font-size: 0.95rem;
}
/* The form is the grid item, so make it a grid too and let its button stretch. */
.job-actions form { display: grid; grid-template-columns: minmax(0, 1fr); }
.job-actions form, .job-actions button, .job-actions .btn { margin: 0; }
.job-actions button, .job-actions .btn { padding-left: 0.5rem; padding-right: 0.5rem; }
.btn.secondary { background: var(--btn-secondary-bg); color: var(--btn-secondary-text); }
.btn.secondary:hover { background: var(--btn-secondary-hover); }
.btn.danger { background: var(--btn-danger-bg); color: var(--btn-danger-text); }
.btn.danger:hover { background: var(--btn-danger-hover); }
.muted { color: var(--text-muted); }
/* „Zobrazeno 5 z 481 záznamů" above a report table. */
.table-count { font-size: 0.875rem; margin: 0 0 0.5rem; }
/* The row buttons under each job-form section: smaller and not full width. */
.row-controls { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.row-controls button {
    width: auto;
    margin: 0;
    padding: 0.5rem 0.9rem;
    font-size: 0.9rem;
}
/* „= součet výstupů" (sum the produced rows) sits at the right, under the quantity box it fills. */
.row-controls .sum-rows { margin-left: auto; }
/* Searchable pickers (static/js/searchable_select.js). Without .combo
   relative and .combo-list absolute, the list renders inline and pushes the
   rows down. `select[hidden]` is a safeguard. */
.combo select[hidden] { display: none; }
.combo { position: relative; }
.combo-list {
    position: absolute;
    z-index: 5;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    max-height: 13rem;
    overflow-y: auto;
    margin: 0;
    padding: 0;
    list-style: none;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--input-border);
    border-radius: 6px;
    box-shadow: 0 4px 12px var(--shadow);
}
.combo-option, .combo-empty { padding: 0.65rem 0.75rem; font-size: 1rem; }
.combo-option { cursor: pointer; }
.combo-option.active { background: var(--btn-secondary-bg); }
.combo-empty { color: var(--text-muted); }
/* „Fotky" (static/js/photo_picker.js). The `[hidden]` rule is load-bearing:
   `label`, `input` and `.photo-menu` all set a `display` that beats the UA
   rule. The `input[hidden]` half matches the specificity of the input rule's
   `:not()`s. */
.photo-picker { margin-bottom: 1rem; }
.photo-menu { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
.photo-menu button { flex: 1; width: auto; margin: 0; }
.photo-list { list-style: none; margin: 0; padding: 0; }
.photo-chosen { display: flex; align-items: center; gap: 0.5rem; margin: 0.5rem 0 0; }
.photo-chosen > span { flex: 1; overflow-wrap: anywhere; }
.photo-chosen button { width: auto; margin: 0; padding: 0.5rem 0.9rem; font-size: 0.9rem; }
.photo-field [hidden], .photo-field input[hidden] { display: none; }
/* Stored photos: links on job_detail, links with „Odebrat" boxes on job_edit. */
.stored-photos { list-style: none; margin: 0 0 1rem; padding: 0; }
.stored-photos li { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.35rem 0; }
.stored-photos label { display: inline-flex; align-items: center; gap: 0.4rem; margin: 0; font-weight: normal; }
/* A photo (job_photo, and the desktop panel) in a fixed-height frame, so
   „Předchozí fotka" / „Další fotka" stay put between photos of any shape. */
.photo-frame { display: block; height: min(55vh, 32rem); cursor: zoom-in; }
.photo-frame img { display: block; width: 100%; height: 100%; object-fit: contain; }
/* Two equal halves: a lone button keeps its own side. */
.photo-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; margin-top: 0.75rem; }
.photo-nav .btn { margin: 0; }
.photo-nav .photo-previous { grid-column: 1; }
.photo-nav .photo-next { grid-column: 2; }
/* Full size, while it is the :target; scrolls both ways over the whole page. */
.photo-full {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 20;
    overflow: auto;
    background: var(--bg);
}
.photo-full:target { display: block; }
.photo-full img { display: block; max-width: none; cursor: zoom-out; }
.photo-full .btn { position: sticky; top: 0.5rem; left: 0.5rem; width: auto; margin: 0.5rem; padding: 0.6rem 1rem; }
/* The pinned panel and the links into it are desktop only (below). */
.photo-panel, .photo-panel-link { display: none; }

/* Desktop layout: the same markup, rearranged from 900px up. Below that
   everything above applies unchanged (phones, portrait tablets). The bottom
   nav stays as it is on every width.
   - main widens to 640px, and to 1200px on pages that set
     `{% block main_class %}wide{% endblock %}` (the reports and Přehled).
   - The filter card lays its fields side by side; a field's errorlist,
     which Django renders before the field's <p>, takes a row of its own. */
@media (min-width: 900px) {
    main { max-width: 640px; padding: 1.5rem 1rem; }
    main.wide { max-width: 1200px; }
    .filter-form {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
        gap: 0 1rem;
        align-items: end;
    }
    .filter-form > p { margin: 0; }
    .filter-form > .errorlist { grid-column: 1 / -1; margin-bottom: 0; }
    .filter-form button { margin-top: 0.75rem; }
    .quick-filters .btn { flex: 0 1 auto; }
    /* job_detail and job_edit with photos: the photos pinned at the right,
       fixed (not sticky, so a #fotka-<n> jump never scrolls the page), between
       the header and the bottom nav; the page sits beside them. */
    main.with-photo-panel { margin-right: calc(min(45vw, 760px) + 2rem); }
    .photo-panel {
        display: block;
        position: fixed;
        top: 5rem;
        bottom: 4rem;
        right: 1rem;
        width: min(45vw, 760px);
        padding: 1rem;
        background: var(--surface);
        border-radius: 8px;
        box-shadow: 0 1px 3px var(--shadow);
    }
    /* The first photo, until a link targets another. */
    .photo-slide { display: none; height: 100%; flex-direction: column; }
    .photo-slide:first-child, .photo-slide:target { display: flex; }
    .photo-panel:has(.photo-slide:target) .photo-slide:not(:target) { display: none; }
    .photo-caption { margin: 0 0 0.5rem; font-weight: 700; }
    .photo-panel .photo-frame { flex: 1 1 auto; min-height: 0; height: auto; }
    .photo-page-link { display: none; }
    .photo-panel-link { display: inline; }
}
