:root {
  --bg: #f5f6f4; --card: #fff; --text: #1d2420; --muted: #66706a; --line: #dde2dd;
  --accent: #1f7a3a; --accent-text: #fff;
  --open: #b42318; --open-bg: #fde8e6; --prog: #a15c00; --prog-bg: #fff1d6; --done: #1f7a3a; --done-bg: #e3f4e8;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816; --card: #1d2320; --text: #e6ebe7; --muted: #9aa49d; --line: #2e3631;
    --accent: #3fa860; --accent-text: #0d130f;
    --open: #ff8a7f; --open-bg: #3a1916; --prog: #ffc266; --prog-bg: #36290f; --done: #7fd69a; --done-bg: #16301f;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
main { max-width: 1200px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.5rem; margin: 0 0 12px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }

.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.topbar nav { display: flex; gap: 16px; flex: 1; }
.logout { display: flex; align-items: center; gap: 10px; margin: 0; }
.who { color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.narrow { max-width: 380px; margin: 40px auto; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.counts { display: flex; gap: 8px; flex-wrap: wrap; }

label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); margin-bottom: 10px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; width: 100%; }
textarea { resize: vertical; }
button { font: inherit; background: var(--accent); color: var(--accent-text); border: 0; border-radius: 6px; padding: 8px 16px; cursor: pointer; }
button.link { background: none; color: var(--accent); padding: 0; text-decoration: underline; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.filters label { margin: 0; min-width: 140px; }
.filters .grow { flex: 1; min-width: 180px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 16px; }
.grid .full { grid-column: 1 / -1; }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .85rem; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
.nowrap { white-space: nowrap; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .85rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.badge.big { font-size: 1rem; padding: 4px 14px; }
.st-open { color: var(--open); background: var(--open-bg); }
.st-in_progress { color: var(--prog); background: var(--prog-bg); }
.st-resolved { color: var(--done); background: var(--done-bg); }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 12px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
@media (max-width: 560px) { .facts { grid-template-columns: 1fr; } .facts dd { margin-bottom: 6px; } }

.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.raw { background: var(--bg); padding: 10px; border-radius: 6px; overflow-x: auto; font-size: .85rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--open); background: var(--open-bg); padding: 8px 12px; border-radius: 6px; }
.empty { color: var(--muted); padding: 24px 0; }
.pager { display: flex; gap: 16px; justify-content: center; padding: 12px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-left: 3px solid var(--line); padding: 4px 0 12px 14px; margin-left: 4px; }
.timeline .when { margin-bottom: 4px; }

/* Πίνακες σαν φύλλο Excel: μία γραμμή ανά εγγραφή, χωρίς αναδίπλωση, οριζόντια κύλιση */
.sheet-wrap { max-height: 75vh; overflow: auto; }
table.sheet { width: auto; min-width: 100%; font-size: .85rem; }
table.sheet th, table.sheet td { white-space: nowrap; padding: 4px 8px; vertical-align: middle; border-right: 1px solid var(--line); }
table.sheet th { position: sticky; top: 0; z-index: 2; background: var(--card); box-shadow: inset 0 -1px 0 var(--line); }
table.sheet tbody tr:nth-child(even) td { background: var(--bg); }
table.sheet tbody tr:hover td { background: var(--done-bg); }
table.sheet .sticky-col { position: sticky; left: 0; z-index: 1; background: var(--card); }
table.sheet th.sticky-col { z-index: 3; }
table.sheet td.num { text-align: right; }
table.sheet td.clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }

/* 2FA */
.narrow.wide { max-width: 520px; }
a.button { display: inline-block; background: var(--accent); color: var(--accent-text); text-decoration: none; border-radius: 6px; padding: 8px 16px; margin: 6px 0; }
.steps { padding-left: 20px; margin: 0 0 14px; }
.steps li { margin-bottom: 12px; }
.qr svg { display: block; margin-top: 6px; max-width: 220px; height: auto; border-radius: 6px; }
.secret code, .recovery code { font-size: 1rem; letter-spacing: .04em; overflow-wrap: anywhere; user-select: all; }
input.otp { font-size: 1.4rem; letter-spacing: .25em; text-align: center; }
.recovery { columns: 2; padding-left: 24px; }

/* Κινητό */
@media (max-width: 700px) {
  body { font-size: 16px; }
  main { padding: 10px; }
  input, select, textarea { font-size: 16px; padding: 10px; }  /* 16px: το iPhone δεν κάνει ζουμ στο πεδίο */
  button, a.button { padding: 12px 18px; min-height: 44px; }
  .topbar { padding: 8px 10px; gap: 6px 12px; }
  .topbar nav { order: 3; flex-basis: 100%; overflow-x: auto; white-space: nowrap; gap: 4px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .topbar nav a { padding: 8px 10px; border-radius: 6px; background: var(--bg); text-decoration: none; }
  .logout { margin-left: auto; }
  .who { display: none; }
  .narrow { margin: 16px auto; }
  .filters label, .filters .grow { min-width: calc(50% - 5px); flex: 1 1 calc(50% - 5px); }
  .filters button { flex-basis: 100%; }
  .page-head h1 { font-size: 1.3rem; }

  /* Πίνακας → κάρτες (π.χ. λίστα alerts): κάθε γραμμή μια κάρτα, κάθε κελί «ετικέτα: τιμή» */
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { display: flex; flex-direction: column; border-bottom: 1px solid var(--line); padding: 8px 12px; }
  table.cards td.card-title { order: -1; }
  table.cards tbody tr:last-child { border-bottom: 0; }
  table.cards td { border: 0; padding: 2px 0; }
  table.cards td[data-label]::before { content: attr(data-label) " "; color: var(--muted); font-size: .85rem; }
  table.cards td.card-title { font-weight: 600; font-size: 1.05rem; }
  table.cards td.card-title a { text-decoration: none; }
  .recovery { columns: 1; }
}
.only-mobile { display: none; }
@media (max-width: 700px) { .only-mobile { display: inline-block; } table.cards td.only-desktop { display: none; } }
