/* SERWIS — układ pod tablet trzymany w rękawicy: duże pola, duże przyciski. */

:root {
    --bg:        #f4f6f8;
    --card:      #ffffff;
    --ink:       #1f2933;
    --ink-soft:  #52606d;
    --line:      #d7dce2;
    --accent:    #0b6bcb;
    --accent-in: #ffffff;
    --danger:    #b42318;
    --ok:        #067647;
    --warn:      #b54708;
    --radius:    10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    -webkit-text-size-adjust: 100%;
}

/* --- pasek górny ---
   Bez justify-content i bez auto-marginesów: przy wąskim ekranie menu ma się
   zawijać pod tytuł, a nie uciekać poza prawą krawędź. */
.top {
    background: #1f2933;
    color: #fff;
    padding: 10px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    align-items: center;
}
.top-title {
    font-weight: 600;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.top-nav {
    flex: 0 1 auto;
    min-width: 0;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.top-nav a {
    color: #cbd2d9;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: var(--radius);
    min-height: 40px;
    display: inline-flex;
    align-items: center;
}
.top-nav a.on { background: #323f4b; color: #fff; }
.top-nav a.out { color: #9aa5b1; }

/* --- treść --- */
.page { max-width: 780px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin: 4px 0 16px; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
}
.card.narrow { max-width: 420px; margin: 40px auto; }

.hint  { color: var(--ink-soft); font-size: 14px; }
.error {
    background: #fef3f2; color: var(--danger);
    border: 1px solid #fda29b; border-radius: var(--radius);
    padding: 10px 12px; margin: 0 0 16px;
}
.flash {
    background: #ecfdf3; color: var(--ok);
    border: 1px solid #a6f4c5; border-radius: var(--radius);
    padding: 10px 12px; margin: 0 0 16px;
}
.empty {
    background: var(--card); border: 1px dashed var(--line);
    border-radius: var(--radius); padding: 28px; text-align: center;
    color: var(--ink-soft);
}

/* --- formularze: pola na palec, nie na kursor --- */
label {
    display: block;
    margin: 16px 0 6px;
    font-weight: 600;
    font-size: 14px;
}
input[type=text], input[type=password], input[type=number],
input[type=date], input[type=time], select, textarea {
    width: 100%;
    padding: 12px;
    font-size: 17px;          /* 16px+ blokuje samoczynne przybliżanie na iOS */
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--ink);
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}
button {
    margin-top: 20px;
    width: 100%;
    min-height: 52px;
    font-size: 17px;
    font-weight: 600;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--ink);
    cursor: pointer;
}
button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-in);
}

/* --- listy zleceń i protokołów --- */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.item {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
}
.item-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 4px; }
.item-head .no { font-weight: 700; }
.item-main { font-size: 17px; }
.item-sub  { color: var(--ink-soft); font-size: 14px; }
.item-fault { margin-top: 6px; font-size: 14px; }

.tag {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #e4e7eb;
    color: var(--ink-soft);
    white-space: nowrap;
}
.tag-wysoki    { background: #fee4e2; color: var(--danger); }
.tag-normalny  { background: #e4e7eb; }
.tag-niski     { background: #eef2f6; }
.tag-draft     { background: #fef0c7; color: var(--warn); }
.tag-completed { background: #d1fadf; color: var(--ok); }
.tag-exported  { background: #d1e9ff; color: var(--accent); }
.tag-rejected  { background: #fee4e2; color: var(--danger); }

/* --- tabela użytkowników --- */
.tablewrap { overflow-x: auto; margin-bottom: 20px; }
.grid {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.grid th, .grid td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
    white-space: nowrap;
}
.grid th { font-size: 13px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .03em; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tr.off td { color: #9aa5b1; }
.grid td.actions { display: flex; gap: 12px; align-items: baseline; }
.grid .item-sub { white-space: normal; }

form.inline { display: inline; margin: 0; }
button.link {
    margin: 0; padding: 0; width: auto; min-height: 0;
    background: none; border: 0; color: var(--accent);
    font: inherit; text-decoration: underline; cursor: pointer;
}

/* --- dwie kolumny tam, gdzie się mieszczą --- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 520px) {
    .grid2 { grid-template-columns: 1fr; }
}
.grid2 label { margin-top: 16px; }

label.check {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 400;
    margin-top: 20px;
}
label.check input[type=checkbox] { width: 22px; height: 22px; flex: 0 0 auto; }

h2 { font-size: 18px; margin: 0 0 4px; }
h3 { font-size: 15px; margin: 24px 0 0; color: var(--ink-soft); }

/* --- protokół --- */
section.card { margin-bottom: 16px; }
.ordercard { margin-bottom: 16px; }
.item-actions { margin-top: 12px; }

a.btn, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--ink);
    font-weight: 600;
    text-decoration: none;
}
a.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

.item-head a.no { color: var(--accent); text-decoration: none; }
.warn { color: var(--warn); }

textarea { resize: vertical; }

/* wyszukiwarka i wiersz wyniku */
.searchrow { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-top: 8px; }
.searchrow input[type=search], .searchrow select { flex: 1 1 200px; }
.searchrow button { margin-top: 0; width: auto; padding: 0 20px; }
.searchrow input.qty, .hit input.qty { flex: 0 0 96px; width: 96px; }

.hit {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}
.hit-info { flex: 1 1 240px; min-width: 0; }
.hit button { margin-top: 0; width: auto; padding: 0 18px; min-height: 48px; }

.freeitem { margin-top: 20px; }
.freeitem summary { cursor: pointer; padding: 10px 0; font-weight: 600; }

/* zdjęcia */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.thumbs figure { margin: 0; }
.thumbs img {
    width: 100%; height: 140px; object-fit: cover;
    border-radius: var(--radius); border: 1px solid var(--line); display: block;
}
.thumbs form { margin-top: 4px; text-align: center; }

/* podpis */
canvas.signpad {
    width: 100%;
    max-width: 600px;
    height: 200px;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    background: #fff;
    touch-action: none;      /* bez tego przeciąganie palcem przewija stronę zamiast rysować */
    display: block;
    margin-top: 12px;
}
img.signature {
    max-width: 320px; width: 100%;
    border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
}
.signbtns { display: flex; gap: 8px; }
.signbtns button { width: auto; flex: 1 1 auto; }

/* braki przed zamknięciem */
.problems { margin: 8px 0 0; padding-left: 20px; color: var(--warn); }
.problems li { margin: 2px 0; }

/* pasek kopii zapasowej z przeglądarki */
.draftbar {
    display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
    background: #fef0c7; color: var(--warn);
    border: 1px solid #fedf89; border-radius: var(--radius);
    padding: 10px 12px; margin: 12px 0;
    font-size: 14px;
}
.draftbar span { flex: 1 1 200px; }
.draftbar button {
    margin: 0; width: auto; min-height: 40px; padding: 0 14px;
    font-size: 14px; background: #fff;
}

button[disabled] { opacity: .5; cursor: not-allowed; }

/* nagłówek strony z przyciskiem po prawej */
.pagehead {
    display: flex; gap: 12px; align-items: center;
    justify-content: space-between; flex-wrap: wrap;
}
.pagehead h1 { margin: 4px 0 16px; }

/* filtry na liście wszystkich protokołów */
.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0 16px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 4px 16px 20px;
    margin-bottom: 20px;
}
.filters label { margin-top: 14px; }
.filters .filter-actions {
    display: flex; gap: 8px; align-items: flex-end; padding-bottom: 2px;
}
.filters .filter-actions button,
.filters .filter-actions .btn { margin-top: 20px; width: auto; flex: 1 1 auto; }

.grid td.actions a { color: var(--accent); }
