/* MILL Field Control Panel — styles. Base shared with MILL Warehouse so both apps look like one family. */
:root {
    --brand: #083030;
    --brand-soft: #19524b;
    --accent: #c9a96e;
    --bg: #f6f7f6;
    --surface: #ffffff;
    --border: #d8ddd9;
    --text: #1c2421;
    --muted: #5b6661;
    --danger: #c0392b;
    --ok: #2e7d4f;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.06);
    --max-w: 760px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    padding-bottom: 72px;
}

/* ---- Header ---- */
.app-header {
    background: var(--brand);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { height: 48px; width: auto; display: block; }
.brand-sub  { font-weight: 700; letter-spacing: .15em; font-size: 14px; opacity: .95; text-transform: uppercase; }
#back-nav a {
    color: #fff;
    background: rgba(255,255,255,.12);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
}
#lang-toggle {
    background: rgba(255,255,255,.12);
    color: #fff;
    border: 1px solid rgba(255,255,255,.35);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .06em;
    cursor: pointer;
}

/* ---- Main ---- */
main {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 16px;
}

h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 16px 0 8px; color: var(--muted); font-weight: 600; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 12px;
}

/* ---- Home tiles ---- */
.tiles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 14px;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-height: 110px;
    justify-content: center;
}
.tile:active { transform: scale(0.98); }
.tile .icon { font-size: 28px; line-height: 0; }
/* Inline SVG icons render on every machine even when emoji fonts are missing. */
.tile .icon svg { width: 32px; height: 32px; display: block; }
.tile .label { font-weight: 600; }
.tile .sub { font-size: 12px; color: var(--muted); }
.tile.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.tile.primary .sub { color: rgba(255,255,255,.75); }

/* ---- Forms ---- */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea, button {
    font: inherit;
    color: inherit;
}
input[type=text], input[type=number], input[type=password], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    margin-bottom: 12px;
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--brand);
    outline-offset: 1px;
}

button, .btn {
    display: inline-block;
    background: var(--brand);
    color: #fff;
    border: 0;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
}
button.secondary, .btn.secondary {
    background: #fff;
    color: var(--brand);
    border: 1px solid var(--brand);
}
button.danger { background: var(--danger); }
button:disabled { opacity: .5; cursor: not-allowed; }

.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: left; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

/* ---- Register grid ---- */
.grid-table { width: 100%; }
.grid-table th { font-size: 11px; }
.grid-table input, .grid-table select {
    margin: 0;
    padding: 6px 8px;
    border-radius: 6px;
}
.grid-table td { padding: 4px; vertical-align: top; }
.grid-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Tags / pills ---- */
.tag {
    display: inline-block;
    padding: 2px 8px;
    background: #e9efed;
    color: var(--brand);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.tag.leftover { background: #f8efd8; color: #8a6d1c; }

/* ---- Footer nav ---- */
.app-footer {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 8px 4px env(safe-area-inset-bottom);
    z-index: 10;
}
.app-footer a {
    text-decoration: none;
    color: var(--muted);
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 8px;
}
.app-footer a.active { color: var(--brand); font-weight: 700; }

/* ---- Misc ---- */
.muted { color: var(--muted); font-size: 13px; }
.bar-id { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; }
.toast {
    position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
    background: var(--brand); color: #fff; padding: 10px 16px;
    border-radius: 999px; box-shadow: var(--shadow); z-index: 20;
    font-size: 14px;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--ok); }

.warning-banner {
    background: var(--danger);
    color: #fff;
    padding: 14px 16px;
    border-radius: var(--radius);
    margin: 12px 0;
    box-shadow: var(--shadow);
}
.warning-banner .warning-title {
    display: block;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    margin-bottom: 6px;
}
.warning-banner .warning-body { font-size: 14px; line-height: 1.4; }

#qr-reader { width: 100%; max-width: 480px; margin: 0 auto; border-radius: var(--radius); overflow: hidden; }

/* ---- Auth pages (login + first-run setup) ---- */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-soft) 100%);
}
.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 28px 24px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, .25);
}
.auth-brand {
    text-align: center;
    margin-bottom: 20px;
}
.auth-brand-logo {
    display: block;
    width: 70%;
    max-width: 220px;
    margin: 0 auto 10px;
    border-radius: 8px;
}
.auth-brand-mark {
    font-weight: 800;
    letter-spacing: .15em;
    font-size: 28px;
    color: var(--brand);
}
.auth-brand-sub {
    font-weight: 300;
    letter-spacing: .2em;
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    margin-top: 2px;
}
.auth-card input {
    margin-bottom: 18px;
}
.auth-card label {
    margin-top: 8px;
}
.auth-card button {
    margin-top: 28px;
}

.scanner-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .9);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

/* ======================================================================
   Field Control Panel additions
   ====================================================================== */
:root {
    --st-done: #2e7d4f;   --st-done-bg: #e3f2e8;
    --st-prog: #1f6fb2;   --st-prog-bg: #e3eef9;
    --st-late: #c0392b;   --st-late-bg: #fbe5e2;
    --st-soon: #b7791f;   --st-soon-bg: #fdf1dc;
    --st-na:   #8a948f;   --st-na-bg:   #eef0ef;
}
.brand { text-decoration: none; color: #fff; }
.header-right { display: flex; align-items: center; gap: 8px; }
main.wide { max-width: none; }
input[type=date], input[type=search] {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border);
    border-radius: 8px; background: #fff; margin-bottom: 12px;
}
textarea { min-height: 80px; resize: vertical; }
button.small, .btn.small { padding: 6px 10px; font-size: 13px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.page-head h1 { margin: 0; }

/* ---- KPI strip ---- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 12px 14px; box-shadow: var(--shadow); cursor: pointer; text-align: left; color: var(--text);
}
.kpi .n { font-size: 26px; font-weight: 800; line-height: 1.1; }
.kpi .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi.late .n { color: var(--st-late); }
.kpi.soon .n { color: var(--st-soon); }
.kpi.done .n { color: var(--st-done); }
.kpi.active { outline: 2px solid var(--brand); }
@media (max-width: 560px) { .kpis { grid-template-columns: 1fr 1fr; } }

/* ---- Filters ---- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.filters input, .filters select { margin: 0; width: auto; flex: 1 1 180px; }
.filters label.check { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; color: var(--text); white-space: nowrap; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 4px 0 10px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; border: 1px solid rgba(0,0,0,.08); }

/* ---- The board ---- */
.board-wrap {
    overflow: auto; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); max-height: calc(100vh - 290px); min-height: 240px;
}
table.board { border-collapse: separate; border-spacing: 0; width: max-content; font-size: 12px; }
.board th, .board td { border-bottom: 1px solid var(--border); border-right: 1px solid #edf0ee; padding: 0; }
.board thead th {
    position: sticky; background: #f1f4f2; z-index: 2; text-transform: none; letter-spacing: 0;
    color: var(--text); font-size: 11px; text-align: center;
}
.board thead tr.phase th { top: 0; height: 26px; background: var(--brand); color: #fff; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: 10px; }
.board thead tr.labels th { top: 26px; padding: 6px 4px; width: 118px; min-width: 118px; max-width: 118px; line-height: 1.2; vertical-align: bottom; height: 44px; }
.board .proj-col { position: sticky; left: 0; z-index: 3; background: var(--surface); width: 260px; min-width: 260px; max-width: 260px; text-align: left; border-right: 2px solid var(--border); }
.board thead .proj-col { z-index: 4; background: #f1f4f2; padding: 6px 10px; vertical-align: bottom; }
.board thead tr.phase .proj-col { background: var(--brand); }
.proj-cell { padding: 8px 10px; }
.proj-cell a.name { font-weight: 700; font-size: 13px; color: var(--brand); text-decoration: none; display: block; }
.proj-cell .meta { color: var(--muted); font-size: 11px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { height: 5px; background: #e6ebe8; border-radius: 99px; margin-top: 6px; overflow: hidden; }
.progress > div { height: 100%; background: var(--st-done); }
.warn-tag { display: inline-block; margin-top: 4px; margin-right: 4px; background: var(--st-soon-bg); color: var(--st-soon); border-radius: 99px; padding: 1px 8px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.warn-tag.late-tag { background: var(--st-late-bg); color: var(--st-late); }
.warn-tag.ok-tag { background: var(--st-done-bg); color: var(--st-done); }

.cell {
    width: 118px; min-width: 118px; max-width: 118px; height: 56px; padding: 5px 0 !important;
    text-align: center; cursor: pointer; position: relative; font-size: 11px; line-height: 1.25; vertical-align: top;
}
.cell:hover { outline: 2px solid var(--brand); outline-offset: -2px; }
.cell .sym { font-size: 15px; font-weight: 800; display: block; }
.cell .dt  { display: block; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cell .files { display: block; font-size: 12px; font-weight: 700; margin-top: 2px; color: #1c2421; }
/* The milestone note, readable straight on the board (max 4 lines; full text on hover / tap). */
.cell .cell-note {
    display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
    margin: 5px 5px 0; padding: 3px 5px; text-align: left; font-size: 11.5px; line-height: 1.3;
    font-weight: 400; color: var(--text); background: rgba(255,255,255,.8);
    border-left: 2px solid var(--accent); border-radius: 3px; word-break: break-word; white-space: pre-line;
}
.cell.readonly { cursor: default; }
.cell.readonly:hover { outline: 1px dashed #b9c2bd; }

.f-done, .f-done_early { background: var(--st-done-bg); color: var(--st-done); }
.f-done_late  { background: var(--st-done-bg); color: var(--st-done); box-shadow: inset 0 -3px 0 var(--st-late); }
.f-progress   { background: var(--st-prog-bg); color: var(--st-prog); }
.f-late       { background: var(--st-late-bg); color: var(--st-late); font-weight: 700; }
.f-due_soon   { background: var(--st-soon-bg); color: var(--st-soon); }
.f-na         { background: var(--st-na-bg);   color: var(--st-na); }
.f-todo       { background: #fff; color: var(--muted); }
tr.is-complete td { opacity: .7; }

/* ---- Status chips ---- */
.chip { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; }

/* ---- Modal ---- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 640px) { .modal-back { align-items: center; } }
.modal {
    background: var(--surface); width: 100%; max-width: 460px; border-radius: 16px 16px 0 0;
    padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); max-height: 92vh; overflow: auto;
}
@media (min-width: 640px) { .modal { border-radius: 16px; } }
.modal h2 { margin: 0 0 2px; color: var(--text); font-size: 17px; }
.modal .sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 14px; }
.seg button { background: #fff; color: var(--text); border: 1px solid var(--border); padding: 10px 4px; font-size: 13px; }
.seg button.on[data-s=todo]     { background: #fff; border: 2px solid var(--muted); }
.seg button.on[data-s=progress] { background: var(--st-prog); color: #fff; border-color: var(--st-prog); }
.seg button.on[data-s=done]     { background: var(--st-done); color: #fff; border-color: var(--st-done); }
.seg button.on[data-s=na]       { background: var(--st-na); color: #fff; border-color: var(--st-na); }
.modal .actions { display: flex; gap: 8px; margin-top: 4px; }
.modal .actions > * { flex: 1; }

/* ---- Agenda ---- */
.agenda-group h2 { display: flex; align-items: center; gap: 8px; }
.agenda-item { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.agenda-item:last-child { border-bottom: 0; }
.agenda-date { width: 64px; flex: none; text-align: center; border-radius: 8px; padding: 6px 0; font-weight: 700; font-size: 13px; line-height: 1.2; }
.agenda-date small { display: block; font-weight: 500; font-size: 11px; }
.agenda-body { flex: 1; min-width: 0; }
.agenda-body .t { font-weight: 700; }
.agenda-body .m { color: var(--muted); font-size: 12px; }

/* ---- Project page ---- */
.ms-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.ms-row:last-child { border-bottom: 0; }
.ms-row .lbl { font-weight: 600; }
.ms-row .dates { color: var(--muted); font-size: 12px; grid-column: 1 / -1; }
.ms-row .note { font-size: 13px; grid-column: 1 / -1; background: #f7f5ef; border-left: 3px solid var(--accent); padding: 4px 8px; border-radius: 4px; white-space: pre-wrap; }
.phase-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--brand); font-weight: 800; margin: 14px 0 0; }
.log-item { font-size: 12px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.log-item b { color: var(--brand); }
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px; margin-bottom: 12px; }
.check-list label { display: flex; gap: 6px; align-items: center; color: var(--text); font-size: 14px; margin: 0; }
.danger-zone { border-color: #f0c4be; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
/* Login / setup fill the whole screen (main is otherwise width-capped). */
main:has(> .auth-shell) { max-width: none; padding: 0; }

/* ---- Phone tweaks ---- */
@media (max-width: 560px) {
    .app-header { padding: 10px 12px; }
    .brand { gap: 8px; }
    .brand-logo { height: 34px; }
    .brand-sub { font-size: 11px; letter-spacing: .1em; line-height: 1.2; }
    .hi-name { display: none; }
    .board .proj-col { width: 170px; min-width: 170px; max-width: 170px; }
    .proj-cell { padding: 6px 8px; }
}

/* ---- Files + inline korlap picker ---- */
.file-list { display: flex; flex-direction: column; gap: 6px; }
.file-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fafbfa; }
.file-main { flex: 1; min-width: 0; }
.file-main .tag { margin-left: 6px; vertical-align: middle; }
.file-main .muted { font-size: 12px; }
.file-link { color: var(--brand); font-weight: 600; text-decoration: none; word-break: break-all; }
.file-link:hover { text-decoration: underline; }
.files-row { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; }
select.inline-select { margin: 0; padding: 6px 8px; width: 100%; max-width: 320px; }

/* ---- PSP and NPK page ---- */
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.seg.seg-2 { grid-template-columns: repeat(2, 1fr); max-width: 320px; }
.seg button.on-brand { background: var(--brand); color: #fff; border-color: var(--brand); }
.info-box { background: #f7f5ef; border-left: 3px solid var(--accent); padding: 10px 12px; border-radius: 6px; margin-bottom: 12px; font-size: 14px; }
.info-box b { display: block; margin-bottom: 2px; }
.or-line { text-align: center; color: var(--muted); font-size: 12px; margin: 10px 0; text-transform: uppercase; letter-spacing: .1em; }
.doc-cell { cursor: pointer; }
.doc-cell:hover { background: #f1f4f2; }
.doc-proj { font-weight: 700; color: var(--brand); text-decoration: none; }

/* ---- Live clock (board head) ---- */
.page-head .clock { margin: 0; padding: 8px 18px; text-align: center; box-shadow: none; }
.clock-date { font-weight: 700; font-size: 14px; }
.clock-time { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 24px; font-weight: 700; letter-spacing: 1px; line-height: 1.15; }
@media (max-width: 560px) { .page-head .clock { order: 3; width: 100%; } }

/* ---- Accounts online ---- */
.online-card { margin-top: 12px; }
.online-card h2 .muted { font-weight: 500; margin-left: 6px; }
.online-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.online-item { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: #fafbfa; }
.online-item.on { background: var(--st-done-bg); border-color: #bfdfca; }
.online-dot { width: 10px; height: 10px; border-radius: 50%; background: #c3cac6; margin-top: 5px; flex: none; }
.online-item.on .online-dot { background: #2ecc71; box-shadow: 0 0 0 3px rgba(46,204,113,.25); }
.online-name { font-weight: 700; font-size: 14px; }
.online-item .muted { font-size: 12px; }

/* ---- WO numbers ---- */
.wo-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.wo-chip { display: inline-flex; align-items: center; background: #e9efed; color: var(--brand); border-radius: 999px; padding: 3px 12px; font-weight: 700; font-size: 13px; letter-spacing: .02em; }
.wo-chip button { background: none; border: 0; color: var(--muted); padding: 0 0 0 8px; margin-right: -4px; font-size: 16px; line-height: 1; cursor: pointer; }
.wo-chip button:hover { color: var(--danger); }
.wo-add { display: flex; gap: 6px; margin-top: 8px; max-width: 360px; }
.wo-add input { margin: 0; flex: 1; min-width: 0; padding: 7px 10px; }
.wo-add button { padding: 7px 12px; white-space: nowrap; }
.tag.wo-tag { background: #e3eef9; color: var(--st-prog); margin: 0 4px 2px 0; text-transform: none; }
.file-main .tag.wo-tag { margin-left: 6px; }

/* ---- Service board / links ---- */
h1 .tag { vertical-align: middle; margin-left: 8px; font-size: 12px; }
.svc-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.svc-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.svc-item a { font-weight: 700; color: var(--brand); text-decoration: none; }
.doc-block { margin-bottom: 8px; }
.doc-block h3 { margin: 6px 0 6px; font-size: 15px; }

/* ---- NPK / PSP drawn 1:1 from the owner's Excel templates ---- */
.doc-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.doc-status { font-size: 12px; color: var(--muted); margin-left: 4px; }
.doc-status.dirty { color: var(--st-soon); font-weight: 700; }
.doc-help { margin: 0 0 8px; }
.paper-wrap { overflow: auto; padding: 6px 2px 28px; }
.paper { position: relative; background: #fff; margin: 0 auto; box-shadow: 0 2px 16px rgba(0,0,0,.2);
         overflow: hidden; color: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.paper-sheet { position: absolute; transform-origin: 0 0; }
.pc, .pf { position: absolute; display: flex; box-sizing: border-box; padding: 0 2px 1px; white-space: pre; line-height: 1.1; }
.pc { pointer-events: none; }
.pbd { position: absolute; pointer-events: none; }
.pf.editable { background: rgba(255, 224, 102, .28); }
.pf.editable:hover { background: rgba(255, 213, 79, .5); }
/* In-place inputs: beat the app's general input / select / button styles. */
.paper input.pin, .paper select.pin, .paper button.pin {
    display: block; width: 100%; height: 100%; min-width: 0; border: 0; margin: 0; padding: 0;
    background: transparent; font: inherit; color: inherit; outline: none; border-radius: 0; box-shadow: none;
    line-height: inherit; text-align: inherit; }
.paper .pin:focus { background: rgba(31, 111, 178, .12); box-shadow: inset 0 0 0 1px #1f6fb2; }
/* Chrome keeps ~14px inside an input with a suggestion list for its arrow,
   which cut narrow cells ("GF", "11902"); the list still opens while typing. */
.paper input.pin::-webkit-calendar-picker-indicator { display: none !important; }
.paper select.pin { appearance: none; -webkit-appearance: none; cursor: pointer; }
.paper button.pin { position: relative; cursor: pointer; white-space: pre; overflow: visible; }
.paper .pdate-input { position: absolute; left: 0; bottom: 0; width: 100%; height: 100%; opacity: 0;
                      pointer-events: none; border: 0; padding: 0; margin: 0; }
.pchk { position: absolute; width: 10px; height: 10px; border: 1px solid #000; background: #fff; font-size: 10px;
        line-height: 10px; text-align: center; box-sizing: content-box; }
.pchk.on::after { content: "✓"; font-weight: 700; }
.pchk.clickable { cursor: pointer; box-shadow: 0 0 0 3px rgba(255, 213, 79, .7); }
.pfooter { position: absolute; left: 0; right: 0; text-align: center; font: 11pt Calibri, Carlito, Arial, sans-serif; }
.doc-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 6px; grid-column: 1 / -1; }
.doc-chip { display: inline-block; padding: 3px 10px; border-radius: 999px; background: #e9efed; color: var(--brand);
            font-weight: 700; font-size: 12px; text-decoration: none; }
.doc-chip:hover { background: #d6e3de; }
.doc-section { margin: 8px 0 12px; }
.print-root { display: none; }
@media print {
  body.printing > *:not(.print-root) { display: none !important; }
  body.printing .print-root { display: block !important; }
  body.printing { padding: 0 !important; margin: 0 !important; background: #fff !important; }
  body.printing .paper { box-shadow: none; margin: 0; }
  body.printing .print-root .paper { break-after: page; page-break-after: always; }
  body.printing .print-root .paper:last-child { break-after: auto; page-break-after: auto; }
}
.zoom-seg { max-width: 180px; margin-bottom: 4px; }
.zoom-seg button { padding: 6px 4px; font-size: 12px; }

/* ---- Board box lines: dates, text, rows ----
   Dark, larger text on the light status colour so it reads easily (owner,
   2026-09-29). Only the status symbol keeps the status colour; a late /
   due-soon deadline is shown in red / dark amber. */
.cell .cd, .cell .ct, .cell .ce { color: #1c2421; font-weight: 400; text-align: left; margin: 2px 5px 0;
                                  padding: 1px 3px; border-radius: 4px; position: relative; }
.cell .cd { display: block; font-size: 12.5px; line-height: 1.35; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cell .cd-l { font-size: 11px; font-weight: 600; color: #4a5551; }
.cell .cd-v { font-weight: 700; }
.cell .cd-unset .cd-v, .cell .cd-unset .ct-v { font-weight: 400; color: #7a847f; }
.cell.f-late .cd.is-plan .cd-v { color: #b3261e; }
.cell.f-due_soon .cd.is-plan .cd-v { color: #8a5300; }
.cell .edit { cursor: pointer; }
.cell .edit:hover { background: rgba(255, 255, 255, .95); box-shadow: 0 0 0 1px rgba(8, 48, 48, .45); }
.cell .cd-picker { position: absolute; left: 0; top: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none;
                   border: 0; padding: 0; margin: 0; }
.cell .ct, .cell .ce { font-size: 12px; line-height: 1.35; white-space: normal; word-break: break-word;
                       display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cell .ct.edit { cursor: text; }
.cell .ct-input { width: 100%; font-size: 12px; padding: 3px 4px; margin: 0; border: 1px solid #1f6fb2;
                  border-radius: 4px; background: #fff; color: #1c2421; }
.cell .ce b { font-weight: 700; }
.cell .ce.more { color: #4a5551; }
.cell .ce-add { color: var(--brand); font-weight: 700; font-size: 12px; }
.entries-section { margin: 2px 0 12px; }
.entry-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.entry-row { display: grid; grid-template-columns: 150px 1fr auto; gap: 6px; align-items: center; }
.entry-row input { margin: 0 !important; padding: 7px 8px !important; }
.entries-list { grid-column: 1 / -1; font-size: 13px; background: #f4f7f6; border-radius: 6px; padding: 4px 8px; }
.entries-list b { color: var(--brand); }

/* ---- Pop-up: three status buttons on date-driven boxes ---- */
.seg.seg-3 { grid-template-columns: repeat(3, 1fr); }
.seg-hint { margin: -6px 0 12px; }

/* ---- WO folder (owner, 2026-10-01) ---- */
.table-card { padding: 0; overflow-x: auto; }
table.wo-folders th.num, table.wo-folders td.num { text-align: center; width: 64px; }
table.wo-folders tbody tr { cursor: pointer; }
table.wo-folders tbody tr:hover td { background: #f4f7f6; }
table.wo-folders .wo-cell a { font-weight: 700; color: var(--brand); text-decoration: none; white-space: nowrap; }
.folder-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.folder-head h2 { margin: 0; display: flex; align-items: center; gap: 8px; }
.folder-head .count { background: #e9efed; color: var(--brand); border-radius: 999px; padding: 1px 9px; font-size: 13px; font-weight: 700; }
.folder-sec .file-item { margin-top: 6px; }
.folder-note { margin: -4px 0 10px; font-size: 13px; }
.wo-dates { margin-left: 8px; font-weight: 400; }
.wo-folder-links { display: flex; gap: 6px; flex-wrap: wrap; }
.btn.wide-btn { display: block; width: 100%; text-align: center; }
.folder-counts { display: none; }
@media (max-width: 560px) {
    table.wo-folders .num { display: none; }
    table.wo-folders .folder-counts { display: block; margin-top: 2px; }
}

/* ---- Ukur: files on each progress row (owner, 2026-10-02) ---- */
.entry { display: flex; flex-direction: column; gap: 4px; }
.entry-files { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 0 2px 4px; font-size: 13px; }
.entry-file { display: inline-flex; align-items: center; gap: 2px; }
button.link-x { background: none; border: 0; color: var(--muted); padding: 0 4px; font-size: 16px; line-height: 1; cursor: pointer; }
button.link-x:hover { color: var(--danger); }
.entries-list .entry-files-view { display: flex; flex-wrap: wrap; gap: 2px 12px; margin: 2px 0 4px; font-size: 13px; }

/* ---- Owner's list 2026-10-05: two-button boxes, ETD vs Target, pictures ---- */
.seg.seg-2b { grid-template-columns: repeat(2, 1fr); }
.ref-val { padding: 10px 12px; margin-bottom: 12px; border: 1px dashed var(--border); border-radius: 8px;
           background: #f4f7f6; color: var(--text); font-weight: 600; }
.cell .cd.etd-warn { color: #8a5300; font-size: 11.5px; font-weight: 700; }
/* Production % from the Production Control Panel (B26). */
.cell .cd.prod-pct { color: var(--brand); font-size: 11.5px; font-weight: 700; }
.cell .cd.prod-held, .info-box .prod-held { color: #8a5a12; font-size: 11.5px; font-weight: 700; }
.etd-hint { margin: -4px 0 12px; padding: 8px 10px; border-radius: 8px; background: var(--st-soon-bg);
            color: #8a5300; font-size: 13px; }
.entry-file { gap: 6px; }
.thumb-link { display: inline-block; line-height: 0; }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); background: #fff; }
.entries-list .entry-file { display: inline-flex; align-items: center; gap: 6px; }

/* ---- Nopen first, WO / Batch column, Project Folder (owner, 2026-10-05) ---- */
.proj-cell .nopen { font-weight: 800; font-size: 13.5px; color: var(--brand); letter-spacing: .02em; }
.proj-cell a.name { color: var(--text); font-size: 12.5px; }
/* WO / Batch: wide enough for long WO numbers such as R15226/D/R7/Q2409/26
   (owner, 2026-10-05: the text ran into Quo Deal); longer ones wrap. */
.board .wo-col { position: sticky; left: 260px; z-index: 3; background: var(--surface); width: 200px; min-width: 200px;
                 max-width: 200px; text-align: left; vertical-align: top; border-right: 2px solid var(--border); cursor: pointer; }
.board thead .wo-col { z-index: 4; background: #f1f4f2; }
.board thead tr.phase .wo-col { background: var(--brand); }
.board thead tr.labels th.wo-col { width: 200px; min-width: 200px; max-width: 200px; text-align: left; padding: 6px 8px; }
.wo-list { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.wo-stack { display: flex; flex-direction: column; gap: 6px; }
.wo-b a, .wo-b b { font-weight: 700; color: var(--brand); text-decoration: none; font-size: 12px; }
.wo-b .batch { display: block; color: var(--muted); font-size: 11px; line-height: 1.25; }
.wo-chip .wo-batch { margin-left: 6px; font-weight: 500; color: var(--muted); }
.wo-add .wo-batch-in { max-width: 150px; }
table.folders td { vertical-align: top; }
table.folders th.num, table.folders td.num { text-align: center; width: 56px; }
table.folders tbody tr { cursor: pointer; }
table.folders tbody tr:hover td { background: #f4f7f6; }
table.folders .nopen-cell a { font-weight: 800; color: var(--brand); text-decoration: none; white-space: nowrap; }
.folder-sec.focus { outline: 2px solid var(--brand); }
.folder-part { margin-top: 10px; }
.folder-part-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.folder-part-head h3 { margin: 6px 0; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.folder-part-head .count { background: #e9efed; color: var(--brand); border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 700; }
.folder-row { margin-top: 8px; }
.folder-row-head { font-size: 13px; margin-bottom: 2px; }
.file-item .thumb-link { margin-right: 2px; }
@media (max-width: 560px) {
    .board .wo-col, .board thead tr.labels th.wo-col { position: static; width: 150px; min-width: 150px; max-width: 150px; }
    table.folders .num { display: none; }
    table.folders .folder-counts { display: block; margin-top: 2px; }
}

/* ---- WO / batch lines (owner, 2026-10-05): one row of boxes per WO / batch ---- */
.board tbody tr.proj-start > td { border-top: 2px solid #c9d3ce; }
.board tbody tr:first-child > td { border-top: 0; }
.board td.proj-col { vertical-align: top; }
.line-cell { padding: 8px; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.line-cell .wo-no { font-weight: 700; color: var(--brand); text-decoration: none; font-size: 12.5px; }
.line-cell > * { max-width: 100%; overflow-wrap: anywhere; }   /* never past the column */
.line-cell .wo-no:hover { text-decoration: underline; }
.line-cell .wo-none { color: var(--muted); font-style: italic; font-size: 12px; }
.line-cell .batch { color: var(--text); font-size: 11.5px; line-height: 1.25; }
.line-cell .progress { width: 100%; margin-top: 3px; }
.line-cell .warn-tag { margin: 0; }
button.add-line { margin-top: 4px; background: none; border: 1px dashed #b9c7c0; color: var(--brand); padding: 3px 8px;
                  font-size: 11px; font-weight: 600; border-radius: 6px; cursor: pointer; }
button.add-line:hover { border-color: var(--brand); background: #f1f6f4; }
tr.line-done > td:not(.proj-col) { opacity: .7; }
.line-list { display: flex; flex-direction: column; gap: 6px; }
.line-item { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.line-item .wo-add { margin-top: 0; }
.wo-chip.no-wo { color: var(--muted); font-style: italic; }
.line-hint { margin: 6px 0 0; font-size: 12.5px; }
.tag.line-tag { margin-left: 6px; vertical-align: middle; }
.line-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 6px; }
.line-tabs button { background: #fff; color: var(--text); border: 1px solid var(--border); padding: 7px 12px; font-size: 13px;
                    font-weight: 600; border-radius: 8px; display: inline-flex; align-items: center; gap: 6px; }
.line-tabs button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.line-tabs .tab-late { background: var(--st-late); color: #fff; border-radius: 99px; padding: 0 7px; font-size: 11px; line-height: 18px; }
.line-sum { margin: 0 0 4px; font-size: 13px; }
.doc-line { cursor: pointer; margin: 2px 0; }
.folder-empty { margin-top: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 13px; }
button.link-btn { background: none; border: 0; padding: 0; color: var(--brand); text-decoration: underline; cursor: pointer;
                  font-size: 13px; font-weight: 500; }

/* ---- WO from the SD Production (owner, 2026-10-06) ---- */
.pclip { position: absolute; overflow: hidden; }
.pbreak { position: absolute; left: 0; right: 0; border-top: 2px dashed #9aa7a1; pointer-events: none; z-index: 2; }
.pbreak span { position: absolute; right: 6px; top: -18px; background: #fff; color: var(--muted); font-size: 11px;
               padding: 0 6px; border-radius: 4px; }
@media print { .pbreak { display: none; } }
.paper .pf.rowno { cursor: pointer; background: rgba(31, 111, 178, .08); }
.paper .pf.rowno:hover { background: rgba(31, 111, 178, .2); }
.row-menu { position: absolute; z-index: 60; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
            box-shadow: 0 6px 24px rgba(0,0,0,.18); padding: 6px; display: flex; flex-direction: column; gap: 4px; min-width: 170px; }
.row-menu .rm-title { font-size: 12px; font-weight: 700; color: var(--muted); padding: 2px 6px; }
.row-menu button { background: #fff; color: var(--text); border: 1px solid var(--border); padding: 7px 10px; font-size: 13px;
                   text-align: left; border-radius: 7px; }
.row-menu button:hover { border-color: var(--brand); }
.row-menu button.rm-del { color: var(--danger); }
.wo-result { margin: 8px 0 4px; padding: 9px 11px; border-radius: 8px; font-size: 13px; }
.wo-result.ok { background: var(--st-done-bg); color: var(--text); }
.wo-result.bad { background: var(--st-late-bg); color: var(--st-late); }
.wo-result-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.wo-result-head .btn { margin-left: auto; }
.wo-result ul { margin: 6px 0 0; padding-left: 18px; }
.warn-text { color: #8a5300; font-weight: 600; }
.doc-chip.replaced { background: #f1f1f1; color: var(--muted); }
.doc-replaced { margin-left: 6px; font-size: 10px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }

/* ---- WO approval (owner, 2026-10-06) ---- */
.paper .psig { position: absolute; object-fit: contain; pointer-events: none; }
.paper .psig-text { position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center;
                    font: 6pt Arial, 'Liberation Sans', Helvetica, sans-serif; line-height: 1.15; color: #000; pointer-events: none; }
.pdraft { position: absolute; left: 0; right: 0; text-align: center; font: 700 110px Arial, sans-serif; letter-spacing: .12em;
          color: rgba(200, 40, 40, .14); transform: rotate(-28deg); pointer-events: none; z-index: 3; }
.sigpad { display: block; border: 1px dashed var(--border); border-radius: 8px; background: #fff; touch-action: none;
          max-width: 100%; margin: 4px 0 10px; cursor: crosshair; }
.sig-preview { display: inline-block; padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px; background: #fff; margin: 0 0 8px; }
.sig-preview img { display: block; max-width: 260px; max-height: 90px; }
.card.appr { padding: 12px 14px; }
.card.appr.approved { border-color: #b9dcc7; background: #f3faf6; }
.appr-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 10px; }
.appr-head .tag { margin-left: 0; }
.appr-approve { margin-left: auto; }
.appr-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.appr-slot { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; min-height: 92px; background: #fff;
             display: flex; flex-direction: column; align-items: flex-start; gap: 3px; font-size: 13px; }
.appr-slot.signed { border-color: #b9dcc7; background: #f3faf6; }
.appr-slot.mine { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(31, 111, 178, .12); }
.appr-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.appr-sig { max-width: 100%; max-height: 42px; }
.appr-name { font-weight: 600; }
.appr-badge { display: inline-block; margin-left: 6px; min-width: 18px; padding: 0 6px; border-radius: 99px; background: var(--st-late);
              color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
table.appr-table td.num.ok { color: var(--st-done); font-weight: 700; }
table.appr-table td.num.you { color: var(--brand); font-weight: 700; }
table.appr-table tr.my-turn td { background: #f4f9ff; }
.doc-chip.draft { background: #fff4e0; color: #8a5300; }
.cell .wo-doc, .cell .wo-draft { display: inline-block; margin-top: 3px; font-size: 11.5px; font-weight: 700; text-decoration: none; }
.cell .wo-doc { color: var(--st-done); }
.cell .wo-draft { color: #8a5300; }
/* WO steps in order (owner, 2026-10-09; B25a) */
.cell .wo-draft.stage-returned { color: var(--st-late); }
.cell .wo-doc + .wo-draft { margin-left: 8px; }
.appr-steps { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 10px; }
.appr-step { font-size: 12px; padding: 2px 10px; border-radius: 99px; border: 1px solid var(--border); color: var(--muted); background: #fff; }
.appr-step.done { border-color: #b9dcc7; background: #f3faf6; color: var(--ok); }
.appr-step.now { border-color: var(--brand); background: #f4f9ff; color: var(--brand); font-weight: 700; }
.appr-back { margin: 0 0 10px; }
.ret-opts { display: grid; gap: 8px; margin: 8px 0 12px; }
.ret-opt { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; color: inherit; font-size: 14px; }
.ret-opt input { margin-top: 3px; width: auto; }
.ret-opt span { display: grid; gap: 2px; }
.ret-opt .muted { font-size: 12.5px; }

/* ---- Notifications (owner, 2026-10-06; header standard H7: the bell pill) ---- */
#back-nav { display: flex; align-items: center; gap: 8px; }   /* one row, 8 px apart (H7) */
#back-nav a.bell { position: relative; display: inline-block; line-height: 1; }
.bell-count, .tab-count { display: inline-block; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px;
                          background: #e5484d; color: #fff; font-size: 11px; font-weight: 700; line-height: 18px;
                          text-align: center; box-sizing: border-box; }
.bell-count { position: absolute; top: -7px; right: -7px; }
.tab-count { margin-left: 4px; vertical-align: 1px; }
.bell-count:empty, .tab-count:empty { display: none; }
.bell-panel { position: fixed; top: 70px; right: 12px; width: min(380px, calc(100vw - 24px)); max-height: 72vh; overflow: auto;
              background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.2);
              z-index: 40; }
.bell-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border);
             position: sticky; top: 0; background: var(--surface); }
.bell-head a { font-size: 13px; color: var(--brand); }
.notif-list { display: flex; flex-direction: column; }
a.notif { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
a.notif:last-child { border-bottom: 0; }
a.notif:hover { background: #f4f7f6; }
a.notif.unread { background: #f4f9ff; }
a.notif.todo .notif-title { color: var(--brand); }
.notif-icon { flex: none; width: 22px; text-align: center; font-size: 16px; line-height: 1.3; }
.notif-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif-title { font-weight: 600; font-size: 13.5px; }
a.notif.unread .notif-title::before { content: "● "; color: #1f6fb2; font-size: 10px; vertical-align: 2px; }
.notif-detail { font-size: 12.5px; color: var(--muted); }
.notif-when { font-size: 11.5px; color: var(--muted); }
.card .notif-list a.notif { padding-left: 4px; padding-right: 4px; }
@media (max-width: 560px) {
    .bell-panel { top: 56px; }
    .app-footer a { padding: 6px 4px; font-size: 11.5px; }
}
/* Live updates (owner, 2026-10-13): shown instead of redrawing over someone's work. */
.live-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 78px; z-index: 60; margin: 0;
            padding: 10px 18px; border-radius: 99px; border: 0; background: #083030; color: #fff; font-weight: 700;
            box-shadow: 0 4px 16px rgba(0,0,0,.25); cursor: pointer; font-size: 14px; }
