
/* Shared styles for Työmaadokumentointi tools: list -> one-column editor, fixed action bar */
:root {
  --bg: #EDF0F3;
  --surface: #FFFFFF;
  --fg: #16202A;
  --muted: #586472;
  --line: #CFD7DF;
  --accent: #F2B705;
  --accent-ink: #16202A;
  --danger: #B8361F;
  --ok: #1D7349;
  --warn: #9A6200;
  --chip: #E3E8ED;
  --shadow: 0 1px 2px rgba(22,32,42,.08);
  --font-body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-label: "Barlow Semi Condensed", "Barlow", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1419; --surface: #172029; --fg: #E7ECF1; --muted: #97A3AF; --line: #2A3641;
    --accent: #F2B705; --accent-ink: #14181C; --danger: #FF7A63; --ok: #4CC38A; --warn: #F0B54A; --chip: #22303B;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E1419; --surface: #172029; --fg: #E7ECF1; --muted: #97A3AF; --line: #2A3641;
  --accent: #F2B705; --accent-ink: #14181C; --danger: #FF7A63; --ok: #4CC38A; --warn: #F0B54A; --chip: #22303B;
  --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 17px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
.wrap {
  max-width: 680px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 12px 128px;
  display: flex; flex-direction: column; gap: 14px;
}
h1 { margin: 0; font-family: var(--font-label); font-weight: 700; font-size: 26px; text-wrap: balance; }
.sub { margin: 0; color: var(--muted); font-size: 15px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card > h2 { margin: 0; font-family: var(--font-label); font-weight: 600; font-size: 16px; letter-spacing: .02em; display: flex; gap: 8px; align-items: baseline; }
.card > h2 .no { font-variant-numeric: tabular-nums; color: var(--fg); background: var(--accent); color: var(--accent-ink); border-radius: 6px; padding: 0 7px; font-weight: 700; }
.card > h2 .hint2 { font-family: var(--font-body); font-weight: 400; font-size: 14px; color: var(--muted); letter-spacing: 0; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 500; color: var(--muted); min-width: 0; }
input, textarea, select {
  font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%; min-width: 0; font-size: 17px;
}
textarea { resize: vertical; min-height: 88px; line-height: 1.4; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 460px) { .grid2 { grid-template-columns: 1fr; } }

button { font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); min-height: 46px; padding: 8px 14px; font-weight: 600; }
button:disabled { opacity: .5; cursor: default; }
button.small { min-height: 38px; padding: 4px 12px; font-size: 15px; font-weight: 500; }
button.ghost { background: transparent; }
button.danger { color: var(--danger); }
button.danger.arm { background: var(--danger); color: var(--surface); border-color: var(--danger); }
button.add { border-style: dashed; color: var(--muted); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* List */
.docs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.doc-item { width: 100%; text-align: left; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 14px 16px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); min-height: 0; }
.doc-item .t { font-family: var(--font-label); font-weight: 600; font-size: 18px; line-height: 1.25; min-width: 0; overflow-wrap: anywhere; }
.doc-item .m { grid-column: 1 / -1; color: var(--muted); font-size: 14px; font-weight: 400; font-variant-numeric: tabular-nums; }
.pill { font-family: var(--font-label); font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; border-radius: 999px; padding: 2px 10px; white-space: nowrap; align-self: start; border: 1px solid currentColor; }
.pill.s0 { color: var(--muted); }
.pill.s1, .pill.s4 { color: var(--ok); }
.pill.s2 { color: var(--warn); }
.pill.s3 { color: var(--danger); }
.empty { border: 2px dashed var(--line); border-radius: 12px; padding: 20px; color: var(--muted); font-size: 15px; }

/* Editor rows */
.mt-list, .att-list, .docs-list, .blk-list { display: flex; flex-direction: column; gap: 10px; }
.mt-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.att { display: grid; grid-template-columns: 1fr; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.att:first-child { border-top: 0; padding-top: 0; }
.att .two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 8px; }
@media (max-width: 460px) { .att .two { grid-template-columns: 1fr; } }
.att .bot { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; min-height: 40px; font-size: 15px; font-weight: 500; background: transparent; padding: 4px 12px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--fg); color: var(--bg); }
.att .lisa { flex: 1 1 140px; width: auto; padding: 8px 10px; font-size: 15px; }
.dl { display: grid; grid-template-columns: 1fr; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.dl:first-child { border-top: 0; padding-top: 0; }
.dl .lbl-in { font-size: 14px; padding: 6px 10px; color: var(--muted); }
.dl textarea { min-height: 52px; }

.blk { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.blk input, .blk textarea { background: var(--surface); }
.blk .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.blk .head .n { font-family: var(--font-label); font-weight: 600; font-size: 14px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.chip { flex: none; min-height: 34px; padding: 4px 10px; font-size: 14px; font-weight: 500; border-radius: 999px; background: var(--chip); border-color: transparent; white-space: nowrap; max-width: 80vw; overflow: hidden; text-overflow: ellipsis; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.ph { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ph .imgw { position: relative; }
.ph img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; display: block; background: var(--line); }
.ph .num { position: absolute; left: 6px; top: 6px; background: var(--fg); color: var(--bg); font-family: var(--font-label); font-weight: 700; font-size: 13px; border-radius: 6px; padding: 1px 7px; font-variant-numeric: tabular-nums; }
.ph input { font-size: 15px; padding: 7px 9px; }
.ph .acts { display: flex; gap: 4px; flex-wrap: wrap; }
.ph .acts button { min-height: 34px; padding: 2px 8px; font-size: 14px; font-weight: 500; }
.cam-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-cam { background: var(--fg); color: var(--bg); border-color: var(--fg); display: inline-flex; align-items: center; gap: 8px; }
.btn-cam svg, .btn-lib svg { width: 20px; height: 20px; }
.btn-lib { display: inline-flex; align-items: center; gap: 8px; }
.file-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.approve { display: flex; flex-direction: column; gap: 8px; }
.opt { display: grid; grid-template-columns: 28px 1fr; gap: 8px; align-items: start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: 16px; }
.opt input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--fg); }
.opt.on { border-color: var(--fg); box-shadow: inset 0 0 0 1px var(--fg); }
.opt .extra { grid-column: 2; display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }

.signers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 560px) { .signers { grid-template-columns: 1fr; } }
.signer { display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; min-width: 0; }
.signer input { font-size: 15px; padding: 7px 9px; }
.sigbox { height: 64px; border-radius: 8px; background: #fff; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; color: #8893A0; font-size: 14px; overflow: hidden; }
.sigbox img { max-height: 60px; }

/* Bars and overlays */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; background: var(--surface); border-top: 1px solid var(--line);
  padding-top: 10px; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.bar .in { max-width: 680px; margin: 0 auto; display: grid; grid-template-columns: auto 1fr; gap: 10px; }
.bar button { white-space: nowrap; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-size: 18px; font-weight: 700; }
.saved { font-size: 13px; color: var(--muted); text-align: right; min-height: 18px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + env(safe-area-inset-bottom, 0px)); max-width: min(560px, calc(100% - 32px)); z-index: 30; background: var(--fg); color: var(--bg); padding: 12px 16px; border-radius: 10px; font-size: 15px; font-weight: 500; }
.toast.err { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
.sheet-bg { position: fixed; inset: 0; z-index: 20; background: rgba(10,14,18,.5); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); width: 100%; max-width: 680px; max-height: 88%; overflow-y: auto; border-radius: 16px 16px 0 0; display: flex; flex-direction: column; gap: 10px;
  padding-top: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.sheet h3 { margin: 0; font-family: var(--font-label); font-size: 20px; }
.tpl { text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; min-height: 0; }
.tpl b { font-family: var(--font-label); font-size: 17px; }
.tpl span { font-weight: 400; font-size: 14px; color: var(--muted); }
.tpl-group { font-family: var(--font-label); font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }
.padwrap { display: flex; flex-direction: column; gap: 10px; }
#pad { width: 100%; height: 200px; background: #fff; border-radius: 10px; border: 1px solid var(--line); touch-action: none; display: block; }
.pad-actions { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 8px; }
.home { font-family: var(--font-label); font-weight: 600; font-size: 15px; color: var(--muted); text-decoration: none; }
.home:hover { color: var(--fg); }

/* Measurement tools */
.apt { border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.apt > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; }
.apt > summary::-webkit-details-marker { display: none; }
.apt > summary .no { font-family: var(--font-label); font-weight: 700; font-size: 20px; font-variant-numeric: tabular-nums; }
.apt > summary .st { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.apt[open] > summary { border-bottom: 1px solid var(--line); }
.apt .inner { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.apt input, .apt select { background: var(--surface); }
.mrow { display: grid; grid-template-columns: minmax(0,1.5fr) minmax(0,1fr) minmax(0,.8fr) minmax(0,.8fr) auto auto; gap: 6px; align-items: end; padding-bottom: 10px; border-bottom: 1px dashed var(--line); }
.mrow:last-of-type { border-bottom: 0; }
.mrow label.f { font-size: 12.5px; }
.mrow input, .mrow select { padding: 8px 9px; font-size: 16px; }
@media (max-width: 560px) { .mrow { grid-template-columns: minmax(0,1fr) minmax(0,1fr) auto auto; } .mrow .wide { grid-column: span 3; } .mrow .chipst { min-width: 0; } .mrow > button { min-height: 40px; padding: 4px 10px; } }
.chipst { font-family: var(--font-label); font-size: 13px; font-weight: 700; border-radius: 999px; padding: 4px 9px; white-space: nowrap; align-self: center; font-variant-numeric: tabular-nums; border: 1px solid currentColor; }
.chipst.ok { color: var(--ok); } .chipst.bad { color: var(--danger); } .chipst.na { color: var(--muted); }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 460px) { .kv { grid-template-columns: 1fr; } }
.calc { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.req { color: var(--danger); }
.mrow .full { grid-column: 1 / -1; }
.blk { min-width: 0; }
.mt-row .small { min-height: 44px; }
/* Linjasäätö rows */
.grouprow input { font-family: var(--font-label); font-weight: 700; font-size: 18px; background: var(--chip); border-color: transparent; }
.vrow { display: grid; gap: 6px 8px; align-items: end; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
  grid-template-columns: minmax(0,1.3fr) minmax(0,1fr) minmax(0,.9fr) minmax(0,1fr) minmax(0,1fr) auto;
  grid-template-areas: "kohta malli koko suunn virt chip" "paine es as as as del"; }
.vrow input, .vrow select { background: var(--surface); padding: 8px 9px; font-size: 16px; }
.vrow label.f { font-size: 12.5px; }
.c-kohta { grid-area: kohta; } .c-malli { grid-area: malli; } .c-koko { grid-area: koko; } .c-suunn { grid-area: suunn; } .c-virt { grid-area: virt; }
.c-chip { grid-area: chip; align-self: center; } .c-paine { grid-area: paine; } .c-es { grid-area: es; } .c-as { grid-area: as; } .c-del { grid-area: del; justify-self: end; }
.vrow .kohta { font-weight: 700; }
@media (max-width: 560px) {
  .vrow { grid-template-columns: minmax(0,1fr) minmax(0,1fr) minmax(0,1fr);
    grid-template-areas: "kohta kohta koko" "malli suunn virt" "paine es as" "chip chip del"; }
  .vrow .c-koko select { padding-right: 4px; }
}
