/* The hidden attribute must always win over component display rules. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 17px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #1c2430; background: #eef1f5; }
main { padding: 12px 12px 96px; max-width: 1400px; margin: 0 auto; }
h1 { font-size: 22px; margin: 4px 0 12px; }
a { color: #1f3a5f; }
.muted { color: #5f6c7a; font-size: 15px; }
.error { color: #b3261e; font-weight: 600; }

.top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: space-between; padding: 8px 12px;
  background: #ffffff; color: #1c2430; border-bottom: 1px solid #dde3ea; box-shadow: 0 1px 3px rgba(15, 26, 40, .08); }
.top .brand { display: inline-flex; align-items: center; text-decoration: none; }
.top .brand img { display: block; height: 36px; width: auto; }
.top form { display: flex; align-items: center; gap: 10px; margin: 0; }
.top .who { font-size: 15px; color: #5f6c7a; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 16px; font: inherit; font-weight: 600;
  color: #1f3a5f; background: #fff; border: 2px solid #1f3a5f; border-radius: 8px; text-decoration: none; cursor: pointer; }
.btn.primary { color: #fff; background: #1f3a5f; }
.btn.small { min-height: 40px; padding: 0 12px; }
.top .btn { color: #1e3a5f; background: transparent; border-color: #1e3a5f; }
.top .btn:hover { background: #eef1f5; }

.card { background: #fff; border: 1px solid #c5ccd6; border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.project { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.project-main { display: flex; flex-direction: column; gap: 2px; flex: 1 1 220px; min-height: 48px; text-decoration: none; color: inherit; }
.project-main strong { font-size: 19px; color: #1f3a5f; }
.today-list { margin: 0; padding-left: 20px; }
.today-list li { margin: 4px 0; }

.login { max-width: 380px; margin: 24px auto; }
.login-logo { margin: 0 0 8px; text-align: center; }
.login-logo img { max-width: 300px; width: 100%; height: auto; }
label { display: block; font-weight: 600; font-size: 15px; margin: 8px 0 4px; }
input[type=text], input[type=password], input[type=date], textarea, select {
  width: 100%; min-height: 48px; padding: 8px 10px; font: inherit; color: inherit; background: #fff; border: 1px solid #8793a3; border-radius: 6px; }
textarea { resize: vertical; }
.login .btn { width: 100%; margin-top: 16px; }

.mhead { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.meta { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.meta .wide { grid-column: 1 / -1; }
.meta .check { align-self: end; }
.meta .check label { display: flex; align-items: center; gap: 10px; min-height: 48px; margin: 0; }
input[type=checkbox] { width: 28px; height: 28px; flex: none; accent-color: #1f3a5f; }

/* Excel-like sheet: visible cells, horizontal scroll, A/A column stays in view */
.sheet-wrap { overflow: auto; max-height: 70vh; border: 2px solid #1f3a5f; border-radius: 6px; background: #fff; -webkit-overflow-scrolling: touch; }
#sheet { border-collapse: collapse; width: max-content; min-width: 100%; }
#sheet th, #sheet td { border: 1px solid #8793a3; padding: 0; vertical-align: top; background: #fff; }
#sheet thead th { position: sticky; top: 0; z-index: 2; background: #dde4ee; padding: 8px; font-size: 14px; text-align: left; white-space: nowrap; }
#sheet .pos { position: sticky; left: 0; z-index: 1; min-width: 48px; text-align: center; background: #dde4ee; font-weight: 700; padding: 12px 6px; }
#sheet thead .pos { z-index: 3; }
#sheet td input[type=text], #sheet td select, #sheet td textarea { border: 0; border-radius: 0; min-height: 56px; min-width: 140px; background: transparent; }
#sheet td textarea { min-width: 220px; }
#sheet td input.mm { min-width: 100px; font-size: 19px; font-variant-numeric: tabular-nums; }
#sheet td input:focus, #sheet td select:focus, #sheet td textarea:focus { outline: 3px solid #e08a00; outline-offset: -3px; background: #fff8e8; }
#sheet td.bad input { background: #fde3e1; }
#sheet td.sill div { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; padding: 4px 8px; min-width: 190px; }
#sheet td.sill label { display: flex; align-items: center; gap: 6px; margin: 0; min-height: 40px; font-weight: 400; }

/* Voice dictation */
.mic-wrap { display: flex; gap: 6px; align-items: stretch; }
.mic-wrap textarea { flex: 1 1 auto; }
.mic { flex: none; min-height: 44px; padding: 0 12px; font: inherit; font-size: 20px; color: #1f3a5f;
  background: #fff; border: 1px solid #8793a3; border-radius: 6px; cursor: pointer; }
.mic.listening { background: #e08a00; border-color: #e08a00; }

/* Dimension sanity warnings (never block saving) */
.dim-warn { margin: 4px 0 0; padding: 4px 8px; font-size: 14px; font-weight: 600; color: #7a5b00;
  background: #fff3c2; border: 1px solid #e0a800; border-radius: 6px; }
th.pos .dim-warn { margin: 4px 0 0; max-width: 220px; white-space: normal; }

.msg { margin: 10px 0; padding: 10px 12px; background: #fde3e1; border: 1px solid #b3261e; border-radius: 6px; color: #7a1712; font-weight: 600; }

/* Previous measurements on the measure page */
.prev h2 { margin: 0 0 6px; }
.prev details { border-bottom: 1px solid #c5ccd6; }
.prev details:last-child { border-bottom: 0; }
.prev summary { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; min-height: 44px; padding: 6px 0; cursor: pointer; }
.prev summary strong { color: #1f3a5f; }
.prev-lines { margin: 0 0 10px; padding: 0 0 0 20px; color: #33404e; }
.prev-lines li { margin: 4px 0; }
#new-measurement { margin-bottom: 12px; }

/* Mobile measurement sheet: one vertical card per opening, labels above the fields */
@media (max-width: 699px) {
  .meta { grid-template-columns: 1fr; }
  .sheet-wrap { max-height: none; border: 0; background: transparent; }
  #sheet { width: 100%; min-width: 0; }
  #sheet thead { display: none; }
  #sheet tbody { display: block; }
  #sheet tbody tr { display: block; margin: 0 0 12px; background: #fff; border: 2px solid #1f3a5f; border-radius: 8px; overflow: hidden; }
  #sheet tr .pos { display: block; position: static; min-width: 0; text-align: left; font-size: 0; padding: 10px 12px 4px; background: #dde4ee; }
  #sheet tr .pos::before { content: attr(data-title); font-size: 17px; }
  #sheet tr .pos .dim-warn { font-size: 14px; }
  #sheet tr td { display: block; border: 0; border-top: 1px solid #c5ccd6; }
  #sheet tr td::before { content: attr(data-label); display: block; padding: 8px 12px 0; font-size: 14px; font-weight: 600; color: #5f6c7a; }
  #sheet td input[type=text], #sheet td select, #sheet td textarea {
    width: calc(100% - 16px); min-width: 0; min-height: 44px; margin: 4px 8px 8px; padding: 8px 10px;
    font: inherit; color: inherit; background: #fff; border: 1px solid #9aa5b1; border-radius: 8px; }
  #sheet td .mic-wrap { margin: 4px 8px 8px; }
  #sheet td .mic-wrap textarea { margin: 0; width: auto; }
  #sheet td .dim-warn { margin: 0 8px 8px; }
  #sheet td.sill div { min-width: 0; padding: 4px 12px 8px; }
  #sheet td.sill label { min-height: 44px; }
  #sheet td.sill input[type=checkbox] { width: 44px; height: 44px; }
}

/* Photos & sketch per opening */
#sheet td.media .media-btns { display: flex; gap: 6px; align-items: center; padding: 8px; flex-wrap: wrap; }
#sheet td.media .photo-thumbs { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 8px 8px; }
#sheet td.media .photo-thumbs:empty { padding: 0; }
#sheet td.media .photo-thumbs img { width: 72px; height: 72px; object-fit: cover; border: 1px solid #8793a3; border-radius: 6px; }
#sheet td.media .sketch-thumb { display: block; max-width: 150px; max-height: 100px; margin: 0 8px 8px;
  border: 1px solid #8793a3; border-radius: 6px; background: #fff; cursor: pointer; }
#photo-count { font-size: 14px; }

/* Full-screen finger sketch overlay */
.sketch-overlay { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; gap: 8px;
  padding: 10px; background: rgba(12, 18, 26, .94); }
.sketch-overlay[hidden] { display: none; }
.sketch-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: #fff; }
.sketch-top strong { font-size: 17px; }
.sketch-tools { display: flex; gap: 8px; }
.sketch-colour { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; cursor: pointer; padding: 0; }
.sketch-colour.selected { outline: 3px solid #e08a00; outline-offset: 1px; }
#sketch-canvas { flex: 1 1 auto; min-height: 0; max-width: 100%; touch-action: none; background: #fff;
  border-radius: 8px; align-self: center; }

/* Office folder: photos & sketch per measurement line */
.line-media { max-width: 240px; }
.line-media img { border: 1px solid #8793a3; border-radius: 4px; }
.line-media .line-photo { width: 64px; height: 64px; object-fit: cover; margin: 2px; vertical-align: middle; }
.line-media .line-sketch { max-width: 150px; max-height: 100px; margin: 2px; vertical-align: middle; }

.bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; gap: 8px; align-items: center; padding: 8px 12px;
  background: #fff; border-top: 2px solid #1f3a5f; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.bar .badge { flex: 1 1 auto; font-weight: 700; font-size: 15px; }
.badge::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 6px; border-radius: 50%; background: #8793a3; }
.badge.local::before { background: #2f6fd0; }
.badge.synced { color: #1b6e32; }
.badge.synced::before { background: #1b9e3c; }
.badge.pending { color: #9a5b00; }
.badge.pending::before { background: #e08a00; }
@media (max-width: 480px) {
  .bar { flex-wrap: wrap; }
  .bar .badge { flex: 1 1 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bar .btn { padding: 0 10px; font-size: 16px; }
  main { padding-bottom: 176px; }
}

/* Office (desktop) */
.top .nav { display: flex; gap: 4px; margin-right: auto; margin-left: 24px; flex-wrap: wrap; }
.top .nav a { color: #1e3a5f; text-decoration: none; padding: 8px 12px; border-radius: 999px; font-weight: 600; }
.top .nav a:hover, .top .nav a.active { background: #eef1f5; }
@media (max-width: 699px) {
  .top { padding: 6px 8px; }
  .top .nav { order: 3; width: 100%; margin: 2px 0 0; }
}
.msg.ok { background: #e1f4e6; border-color: #1b6e32; color: #14502a; }
h2 { font-size: 18px; margin: 4px 0 10px; }
.push { margin-left: auto; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.filters input[type=text] { flex: 1 1 280px; max-width: 420px; }
.filters select { width: auto; min-width: 180px; }
.grid4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 12px; margin-bottom: 8px; }
.grid4 .wide2 { grid-column: span 2; }
.newproject .btn { margin-top: 8px; }
.card.measurement { margin-bottom: 16px; }
.mhead.noprint h1, .mhead h1 { margin: 0; }
.mhead span { color: #5f6c7a; }
.onlyprint { display: none; }

/* Excel-like read/edit tables: visible cells */
.xl { border-collapse: collapse; width: 100%; background: #fff; }
.xl th, .xl td { border: 1px solid #8793a3; padding: 6px 8px; vertical-align: top; text-align: left; }
.xl thead th { position: sticky; top: 0; background: #dde4ee; white-space: nowrap; font-size: 14px; z-index: 1; }
.xl .num { text-align: right; font-variant-numeric: tabular-nums; }
.xl .cell-input { padding: 0; }
.xl .cell-input select { border: 0; border-radius: 0; min-height: 40px; min-width: 170px; background: transparent; }
.xl .cell-input select:focus { outline: 3px solid #e08a00; outline-offset: -3px; background: #fff8e8; }
.xl tbody tr:hover td { background: #f4f7fb; }
.xl tfoot th, .xl tfoot td { background: #dde4ee; font-weight: 700; border-top: 3px double #1f3a5f; }
.xl.ro td { font-size: 15px; }
.payrow td { background: #fff8e8; }
.payform { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.payform label { margin-top: 0; }
.payform select, .payform input[type=text], .payform input[type=date] { min-width: 150px; }

.details { display: grid; grid-template-columns: 180px 1fr; gap: 4px 12px; margin: 0; }
.details dt { font-weight: 600; color: #5f6c7a; }
.details dd { margin: 0; }

/* Status chips of material orders */
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 14px; font-weight: 700; text-decoration: none; }
.chip.DRAFT { background: #e3e6eb; color: #3c4652; }
.chip.ORDERED { background: #dbe7f6; color: #1f4e8c; }
.chip.PARTIAL { background: #fff0cf; color: #8a5b00; }
.chip.RECEIVED { background: #dcf2e2; color: #14502a; }
.chip.ORDERED:hover, .chip.DRAFT:hover { filter: brightness(.95); }

/* Order line grid (create/edit): Excel-like, visible cells */
.lgrid td.cell-input { padding: 0; }
.lgrid td input[type=text] { width: 100%; min-height: 40px; border: 0; border-radius: 0; background: transparent; padding: 6px 8px; font: inherit; color: inherit; }
.lgrid td input:focus { outline: 3px solid #e08a00; outline-offset: -3px; background: #fff8e8; }
.lgrid td input.qty { text-align: right; font-variant-numeric: tabular-nums; }
.lgrid td input.mm { font-variant-numeric: tabular-nums; }
.lgrid td.rownum { text-align: center; background: #dde4ee; font-weight: 700; }
.lgrid td.chk { text-align: center; vertical-align: middle; }
.lgrid td.chk input[type=checkbox] { width: 22px; height: 22px; }
.lgrid td .btn[data-del-row] { min-height: 32px; padding: 0 10px; }
[data-add-row] { margin: 8px 0 12px; }
.receipthist { margin: 6px 0; }
.receipthist .chip { margin: 0 4px; }
.print-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.print-head img { height: 18mm; width: auto; }
@media print {
  .chip { border: 1px solid #000; }
}
fieldset.crew { border: 1px solid #c5ccd6; border-radius: 6px; margin: 8px 0; }
label.inline { display: inline-flex; align-items: center; gap: 8px; margin: 4px 14px 4px 0; font-weight: 400; }
label.inline input[type=checkbox] { width: 22px; height: 22px; }

.upload { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.upload .grow { flex: 1 1 280px; }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.file { margin: 0; border: 1px solid #8793a3; border-radius: 6px; background: #fff; overflow: hidden; }
.file img, .file .pdf { display: flex; align-items: center; justify-content: center; width: 100%; height: 140px; object-fit: cover; background: #dde4ee; }
.file .pdf { font-weight: 700; font-size: 28px; color: #1f3a5f; }
.file figcaption { padding: 8px; font-size: 14px; }
.flags label.inline { font-size: 14px; display: flex; margin: 2px 0; }

/* Εκκρεμότητες */
.partial-order { border-bottom: 1px solid #c5ccd6; padding: 6px 0; }
.partial-order:last-child { border-bottom: 0; }
.partial-order p { margin: 4px 0; }

/* Πρόγραμμα: μία στήλη ανά μέρα, Δευτέρα έως Σάββατο */
.week { display: grid; grid-template-columns: repeat(6, minmax(190px, 1fr)); gap: 10px; align-items: start; }
.week .day { background: #fff; border: 1px solid #c5ccd6; border-radius: 10px; padding: 8px; min-height: 120px; }
.week .day.today { border: 2px solid #1f3a5f; }
.week .day h2 { display: flex; justify-content: space-between; align-items: baseline; }
.week .task { padding: 8px; margin-bottom: 8px; }
.week .task p { margin: 2px 0; }
.week .task .btn { margin: 4px 4px 0 0; }
.chip.PLANNED { background: #dbe7f6; color: #1f4e8c; }
.chip.DONE { background: #dcf2e2; color: #14502a; }
.chip.POSTPONED { background: #e3e6eb; color: #3c4652; }
@media (max-width: 1099px) { .week { grid-template-columns: repeat(3, minmax(150px, 1fr)); } }
@media (max-width: 699px) { .week { grid-template-columns: 1fr; } }

/* «Ολοκληρώθηκε» μέσα στη λίστα «Σήμερα» */
.inline-done { display: inline-block; margin: 4px 0 0; }

/* Υπογραφή πελάτη στο δελτίο επιμέτρησης (κινητό) */
.signed-info { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 10px; margin-top: 8px;
  background: #e1f4e6; border: 1px solid #1b6e32; border-radius: 6px; }
.signed-info span { font-weight: 700; color: #14502a; }
.sign-panel { color: #fff; }
.sign-panel .consent { margin: 0; font-size: 16px; }
.sign-name { max-width: 420px; }
.sign-name label { color: #fff; }
#sign-canvas { max-height: 60vh; }

/* Δελτίο επιμέτρησης: εκτυπώσιμο A4 */
.print-sketch img { max-width: 110px; max-height: 80px; }
.print-sign { margin-top: 14px; break-inside: avoid; }
.print-sign .consent { font-weight: 600; }
.sign-img { max-height: 90px; max-width: 320px; }
.sign-box { height: 110px; border: 2px dashed #8793a3; border-radius: 6px; display: flex; align-items: flex-end; }
.sign-box span { padding: 6px 10px; font-size: 14px; color: #5f6c7a; }
.sign-caption { margin: 4px 0 0; }

@media print {
  @page { size: A4 portrait; margin: 12mm; }
  .print-table tr, .print-sign, .details { break-inside: avoid; }
  .sign-box { border-color: #000; }
  .print-sheet { break-after: page; }
  .print-sheet:last-of-type { break-after: auto; }
}

@media print {
  body { background: #fff; font-size: 12px; }
  .top, .noprint, .msg, .bar { display: none !important; }
  .onlyprint { display: block; }
  main { padding: 0; max-width: none; }
  .card { border: 0; padding: 0; break-inside: avoid-page; }
  .sheet-wrap { overflow: visible; max-height: none; border: 0; }
  .xl { width: 100%; font-size: 10px; }
  .xl th, .xl td { padding: 3px 4px; border-color: #000; }
  .xl thead th { position: static; background: #eee; }
  body.print-one .measurement:not(.print-me) { display: none; }
  body.print-one section.card:not(.measurement) { display: none; }
  .measurement { break-after: page; }
}
