:root {
  --bg: #f4f6fa; --card: #fff; --text: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --brand: #1d4ed8; --brand-2: #1e40af; --brand-soft: #e0e7ff;
  --ok: #15803d; --ok-soft: #dcfce7; --warn: #b45309; --warn-soft: #fef3c7;
  --bad: #b91c1c; --bad-soft: #fee2e2; --info: #0369a1; --info-soft: #e0f2fe;
  --grey-soft: #f1f5f9; --radius: 10px; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.08);
  --side: 232px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  font-size: 15px; color: var(--text); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; -webkit-tap-highlight-color: transparent; }
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 1.45rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 0 0 .5rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: .85rem; } .nowrap { white-space: nowrap; }
.right { text-align: right; } .grow { flex: 1; } .hidden { display: none !important; }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }
.side { width: var(--side); background: #0f172a; color: #cbd5e1; position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; padding: 1rem .75rem; z-index: 20; }
.side .logo { color: #fff; font-weight: 700; font-size: 1.2rem; padding: .25rem .6rem 1rem; display: flex; gap: .5rem; align-items: center; }
.side .logo small { display: block; font-weight: 400; font-size: .75rem; color: #94a3b8; }
.side nav a { display: flex; align-items: center; gap: .6rem; color: #cbd5e1; padding: .6rem .7rem; border-radius: 8px; margin-bottom: 2px; }
.side nav a:hover { background: #1e293b; color: #fff; }
.side nav a.active { background: var(--brand); color: #fff; }
.side .foot { margin-top: auto; font-size: .85rem; padding: .5rem .6rem; border-top: 1px solid #1e293b; }
.side .foot button { margin-top: .5rem; }
.main { flex: 1; margin-left: var(--side); padding: 1.5rem 2rem 3rem; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.topbar .actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }
.bottomnav { display: none; }
.ico { width: 20px; height: 20px; flex: none; }

/* ---------- Cards / grids ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem 1rem; display: block; color: var(--text); }
.stat b { display: block; font-size: 1.75rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat.alert b { color: var(--bad); }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; white-space: pre-wrap; word-break: break-word; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
td .badge { white-space: normal; }
tbody tr.click { cursor: pointer; } tbody tr.click:hover { background: #f8fafc; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.st-open { background: var(--grey-soft); color: #334155; }
.st-scheduled { background: var(--info-soft); color: var(--info); }
.st-in_progress { background: var(--warn-soft); color: var(--warn); }
.st-completed { background: var(--ok-soft); color: var(--ok); }
.st-cancelled { background: var(--bad-soft); color: var(--bad); }
.pr-high { background: #ffedd5; color: #c2410c; } .pr-urgent { background: var(--bad); color: #fff; }
.pr-low { background: var(--grey-soft); color: var(--muted); }

/* ---------- Forms ---------- */
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .25rem; font-weight: 500; }
input, select, textarea { width: 100%; font: inherit; padding: .6rem .7rem; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
textarea { min-height: 90px; resize: vertical; }
.field { margin-bottom: .85rem; }
.row { display: flex; gap: .75rem; } .row > * { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: .5rem; padding: .35rem 0; color: var(--text); font-size: .95rem; }
.check input { width: auto; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { border: 1px solid #cbd5e1; padding: .35rem .7rem; border-radius: 999px; cursor: pointer; user-select: none; background: #fff; font-size: .9rem; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters > * { width: auto; }
.filters input[type=search] { min-width: 240px; flex: 1; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600; padding: .6rem 1rem; border-radius: 8px; border: 1px solid transparent; cursor: pointer; background: var(--brand); color: #fff; white-space: nowrap; }
.btn:hover { background: var(--brand-2); }
.btn.sec { background: #fff; color: var(--text); border-color: #cbd5e1; } .btn.sec:hover { background: #f8fafc; }
.btn.ok { background: var(--ok); } .btn.danger { background: #fff; color: var(--bad); border-color: #fecaca; }
.btn.warn { background: var(--warn); }
.btn.sm { padding: .35rem .65rem; font-size: .85rem; }
.btn.lg { padding: .9rem 1.2rem; font-size: 1.05rem; width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.linkbtn { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; padding: 0; }

/* ---------- Modal / toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; z-index: 100; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 640px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal header { padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal header h2 { margin: 0; flex: 1; }
.modal .body { padding: 1.1rem 1.2rem; }
.modal footer { padding: .9rem 1.2rem; border-top: 1px solid var(--line); display: flex; gap: .5rem; justify-content: flex-end; }
.x { background: none; border: 0; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); }
#toast { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%) translateY(200%); visibility: hidden; background: #0f172a; color: #fff; padding: .75rem 1.1rem; border-radius: 10px; transition: transform .25s; z-index: 200; max-width: 90vw; }
#toast.show { transform: translateX(-50%) translateY(0); visibility: visible; }
#toast.err { background: var(--bad); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: linear-gradient(135deg, #1e3a8a, #1d4ed8 60%, #3b82f6); }
.login .card { width: 100%; max-width: 380px; padding: 2rem; }
.login .logo { font-size: 1.6rem; font-weight: 800; color: var(--brand); margin-bottom: .25rem; }

/* ---------- Calendar ---------- */
.cal { display: grid; grid-template-columns: 150px repeat(7, minmax(120px, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; min-width: 1000px; }
.cal > div { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: .4rem; min-height: 86px; }
.cal .h { background: #f8fafc; font-weight: 600; font-size: .85rem; min-height: auto; text-align: center; }
.cal .h.today { background: var(--brand-soft); color: var(--brand); }
.cal .who { background: #f8fafc; font-weight: 600; font-size: .9rem; }
.cal .cell.over { background: var(--brand-soft); }
.cal .cell.today { background: #f8faff; }
.jc { display: block; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--info); border-radius: 6px; padding: .3rem .4rem; margin-bottom: .3rem; font-size: .8rem; color: var(--text); cursor: grab; }
.jc b { display: block; font-size: .78rem; } .jc span { color: var(--muted); }
.jc.s-in_progress { border-left-color: var(--warn); } .jc.s-completed { border-left-color: var(--ok); opacity: .75; }
.jc.s-open { border-left-color: #94a3b8; } .jc.s-cancelled { border-left-color: var(--bad); opacity: .5; text-decoration: line-through; }
.pool { min-height: 120px; }

/* ---------- Photos / signature ---------- */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .6rem; }
.photo { position: relative; border-radius: 8px; overflow: hidden; background: var(--grey-soft); aspect-ratio: 1; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.photo .cap { position: absolute; inset: auto 0 0 0; background: rgba(0,0,0,.55); color: #fff; font-size: .72rem; padding: .2rem .35rem; }
.photo .del { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 50%; width: 26px; height: 26px; cursor: pointer; }
.doclink { display: flex; align-items: center; gap: .5rem; padding: .45rem 0; }
.sigpad { border: 2px dashed #cbd5e1; border-radius: 8px; width: 100%; height: 200px; touch-action: none; background: #fff; display: block; }
.sigimg { max-width: 280px; max-height: 120px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); display: grid; place-items: center; z-index: 300; }
.lightbox img { max-width: 95vw; max-height: 90vh; }

/* ---------- Engineer (mobile) ---------- */
.mjob { display: block; background: #fff; border-radius: 12px; box-shadow: var(--shadow); padding: .9rem 1rem; margin-bottom: .7rem; color: var(--text); border-left: 5px solid var(--info); }
.mjob.s-in_progress { border-left-color: var(--warn); } .mjob.s-completed { border-left-color: var(--ok); } .mjob.s-open { border-left-color: #94a3b8; }
.mjob .t { font-weight: 700; font-size: 1.02rem; margin: .15rem 0; }
.mjob .meta { display: flex; justify-content: space-between; gap: .5rem; font-size: .85rem; color: var(--muted); }
.daytitle { font-weight: 700; margin: 1.1rem 0 .5rem; color: var(--muted); font-size: .85rem; text-transform: uppercase; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: .75rem 0; }
.quick a, .quick button { display: flex; flex-direction: column; align-items: center; gap: .25rem; background: var(--brand-soft); color: var(--brand); border-radius: 10px; padding: .7rem .3rem; font-weight: 600; font-size: .85rem; border: 0; font-family: inherit; cursor: pointer; }
.timer { font-variant-numeric: tabular-nums; font-size: 1.6rem; font-weight: 700; text-align: center; margin: .25rem 0 .5rem; }
.livebar { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: .6rem .9rem; margin-bottom: .75rem; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.tabs { display: flex; gap: .4rem; margin-bottom: .8rem; }
.tabs button { flex: 1; border: 1px solid #cbd5e1; background: #fff; border-radius: 999px; padding: .5rem; font: inherit; font-weight: 600; cursor: pointer; }
.tabs button.on { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- Print / job sheet ---------- */
.sheet { background: #fff; max-width: 820px; margin: 0 auto; padding: 2rem; box-shadow: var(--shadow); }
.sheet header { display: flex; justify-content: space-between; border-bottom: 3px solid var(--brand); padding-bottom: .8rem; margin-bottom: 1rem; }
.sheet h1 { color: var(--brand); }
.sheet section { margin-bottom: 1rem; break-inside: avoid; }
.sheet section h3 { border-bottom: 1px solid var(--line); padding-bottom: .2rem; }
.sheet .photos { grid-template-columns: repeat(4, 1fr); }
.noprint { }
@media print {
  body { background: #fff; } .noprint, .side, .bottomnav, .topbar { display: none !important; }
  .main { margin: 0; padding: 0; } .sheet { box-shadow: none; padding: 0; max-width: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .side { display: none; }
  .main { margin-left: 0; padding: 1rem 1rem calc(80px + env(safe-area-inset-bottom)); }
  .bottomnav { display: flex; position: fixed; inset: auto 0 0 0; background: #fff; border-top: 1px solid var(--line); z-index: 50; padding-bottom: env(safe-area-inset-bottom); }
  .bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .5rem 0 .45rem; font-size: .72rem; color: var(--muted); }
  .bottomnav a.active { color: var(--brand); }
  .g2, .g3, .g-main { grid-template-columns: 1fr; }
  .row { flex-direction: column; gap: 0; }
  h1 { font-size: 1.25rem; }
  .filters input[type=search] { min-width: 0; width: 100%; }
  .hide-sm { display: none; }
  .overlay { padding: 0; align-items: stretch; }
  .modal { border-radius: 0; min-height: 100%; display: flex; flex-direction: column; }
  .modal .body { flex: 1; }
  .modal footer { position: sticky; bottom: 0; background: #fff; padding-bottom: calc(.9rem + env(safe-area-inset-bottom)); }
  input, select, textarea { font-size: 16px; } /* χωρίς zoom στο iPhone */
}
