/*
 * KP Asistent – vzhled.
 * Barvy a písmo jsou v proměnných níže – pro sladění s aplikací DOXA stačí přepsat tento blok.
 */
:root {
  --brand: #152943;        /* horní lišta */
  --brand-text: #e8eef6;
  --accent: #2362ad;       /* tlačítka, odkazy */
  --accent-text: #ffffff;
  --bg: #f3f6fa;
  --card: #ffffff;
  --line: #dce4ef;
  --text: #152943;
  --muted: #6a7a91;
  --ok: #148374;
  --warn: #b26a00;
  --bad: #c0392b;
  --radius: 10px;
  --font: system-ui, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
a { color: var(--accent); }
code { background: #eef2f7; padding: 1px 5px; border-radius: 4px; font-size: .9em; word-break: break-all; }
h1, h2, h3 { line-height: 1.25; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 18px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); font-size: .9em; }

/* horní lišta */
.top { background: var(--brand); color: var(--brand-text); display: flex; align-items: center; gap: 18px; padding: 0 20px; position: sticky; top: 0; z-index: 5; }
.brand { color: #fff; font-weight: 800; font-size: 19px; text-decoration: none; padding: 14px 0; white-space: nowrap; }
.brand span { font-weight: 400; opacity: .7; }
.top nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; }
.top nav a { color: var(--brand-text); text-decoration: none; padding: 9px 12px; border-radius: 8px; white-space: nowrap; }
.top nav a:hover, .top nav a.on { background: rgba(255,255,255,.12); }
.top nav a.out { margin-left: auto; opacity: .7; }
.badge { background: var(--bad); color: #fff; border-radius: 9px; padding: 0 7px; font-size: 12px; margin-left: 3px; }

main { max-width: 1400px; margin: 0 auto; padding: 22px clamp(12px, 3vw, 32px); }
footer { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: 0 1px 4px rgba(21,41,67,.06); min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.grid2.wide { grid-template-columns: 3fr 2fr; }
.narrow { max-width: 720px; }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: var(--muted); }
.tile b { display: block; font-size: 28px; color: var(--text); }
.tile.bad b { color: var(--bad); }

/* seznam zpráv */
.row { display: flex; gap: 12px; padding: 12px 6px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.row:hover { background: #f7f9fc; }
.row:last-child { border-bottom: 0; }
.row-main { flex: 1; min-width: 0; }
.row-date { color: var(--muted); font-size: 13px; white-space: nowrap; }
.subj { font-weight: 600; overflow-wrap: anywhere; }
.sum { color: var(--muted); font-size: 14px; }
.tags { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 5px; }
.tag { display: inline-block; background: #edf3fa; color: #244f7c; border-radius: 20px; padding: 1px 9px; font-size: 12px; }
.tag.ok { background: #e3f4f1; color: var(--ok); }
.tag.warn { background: #fff3e0; color: var(--warn); }
.tag.muted { background: transparent; }
.prio { font-size: 11px; border-radius: 4px; padding: 0 5px; margin-left: 4px; }
.prio.p1 { background: #fde8e6; color: var(--bad); }
.prio.p2 { display: none; }
.prio.p3 { background: #f0f2f5; color: var(--muted); }

/* detail */
.subject { font-size: 21px; margin: 0 0 6px; overflow-wrap: anywhere; }
.meta { color: var(--muted); font-size: 13px; }
.summary { background: #f0f6fd; border-left: 3px solid var(--accent); padding: 8px 12px; margin: 12px 0; border-radius: 4px; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; font: 14px/1.55 var(--font); margin: 0; }
pre.body { background: #f8fafc; border-radius: 8px; padding: 14px; margin-top: 12px; max-height: 70vh; overflow: auto; }
.atts { padding-left: 0; list-style: none; }
.thr { border-left: 3px solid var(--line); padding: 6px 12px; margin: 10px 0; }
.thr.ours { border-color: var(--ok); background: #f5fbfa; }
details { margin: 12px 0; }
summary { cursor: pointer; color: var(--accent); }

/* formuláře */
label { display: block; font-size: 13px; font-weight: 600; margin: 10px 0; }
input, select, textarea { width: 100%; font: inherit; font-weight: 400; color: var(--text); border: 1px solid #cbd5e1; border-radius: 8px; padding: 9px 11px; background: #fff; margin-top: 4px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label.chk { font-weight: 400; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
label.chk input[type=checkbox] { width: auto; margin: 0; }
label.chk input[type=date] { width: auto; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.inline input, .inline select { flex: 1; min-width: 160px; width: auto; margin: 0; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.btns form { margin: 0; }

.btn { display: inline-flex; align-items: center; gap: 8px; font: inherit; font-weight: 600; border: 1px solid var(--line); background: #e8eef5; color: #253c59; border-radius: 8px; padding: 9px 14px; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .6; cursor: wait; }
button.link { background: none; border: 0; color: var(--bad); cursor: pointer; font: inherit; padding: 0; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; background: #e3f4f1; color: #0d5c51; }
.flash.err { background: #fde8e6; color: #8f2318; }
.flash.warn { background: #fff3e0; color: #7a4a00; }

.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.bar form { margin: 0; }
.tabs { display: flex; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.tabs a { padding: 6px 12px; border-radius: 7px; text-decoration: none; color: var(--text); }
.tabs a.on { background: var(--accent); color: var(--accent-text); }
.filter { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.filter input, .filter select { width: auto; flex: 1; min-width: 140px; margin: 0; }

/* kalendář a úkoly */
.ev { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.ev .time { color: var(--accent); font-variant-numeric: tabular-nums; min-width: 92px; font-size: 14px; }
.ev form.x { margin-left: auto; }
.ev form.x button, form.done button { border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; width: 28px; height: 28px; color: var(--muted); }
form.done button:hover { background: var(--ok); color: #fff; }
.task { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.task.late { color: var(--bad); }
.task form { margin: 0; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
td, th { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.log tr.error td { color: var(--bad); }
.log tr.warn td { color: var(--warn); }
.secret { display: block; margin-top: 8px; padding: 10px; }

.login { max-width: 400px; margin: 12vh auto; }
.login h1 { font-size: 24px; }
.login h1 span { font-weight: 400; color: var(--muted); }
.btn.google { width: 100%; justify-content: center; background: #fff; color: #1f1f1f; border-color: #c7cdd6; padding: 11px; }

nav.bottom { display: none; }

/* seznam + otevřená zpráva */
.wideonly { display: none; }
.row.active { background: #e8f0fb; box-shadow: inset 3px 0 0 var(--accent); }
.list-count { padding: 0 6px 6px; border-bottom: 1px solid var(--line); }
.placeholder { text-align: center; color: var(--muted); padding: 80px 20px; }
.placeholder svg { opacity: .5; }

/* Notebook / velký displej: menu v boční liště, pošta ve dvou sloupcích jako poštovní program */
@media (min-width: 1200px) {
  :root { --side: 232px; }
  .top {
    position: fixed; top: 0; left: 0; bottom: 0; width: var(--side);
    flex-direction: column; align-items: stretch; gap: 0; padding: 22px 14px;
  }
  .brand { padding: 0 10px 26px; font-size: 21px; }
  .top nav { flex-direction: column; overflow: visible; gap: 3px; }
  .top nav a { padding: 11px 12px; border-radius: 9px; display: flex; align-items: center; justify-content: space-between; }
  .top nav a.out { margin: auto 0 0; }
  main { margin-left: var(--side); max-width: none; padding: 26px 32px; }
  footer { margin-left: var(--side); }

  .wideonly { display: block; }
  .narrowonly { display: none; }
  .split { display: grid; grid-template-columns: minmax(360px, 32%) minmax(0, 1fr); gap: 22px; align-items: start; }
  .list-col { position: sticky; top: 26px; max-height: calc(100vh - 52px); display: flex; flex-direction: column; min-width: 0; }
  .list-col > *, .list-col .bar > *, .pane-col { min-width: 0; }
  .list-col .filter .btn { flex: none; padding: 9px 12px; }
  .list-col .bar { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 8px; margin-bottom: 10px; }
  .list-col .bar > form:last-child .btn { width: 100%; justify-content: center; padding: 7px 12px; }
  .list-col .filter { flex-wrap: nowrap; }
  .list-col .filter select { flex: 0 1 40%; min-width: 0; }
  .list-col .filter input { min-width: 0; }
  .list-col .tabs a { flex: 1; text-align: center; white-space: nowrap; padding: 6px 4px; font-size: 14px; }
  .list-col .card.list { overflow-y: auto; margin: 0; padding: 12px; flex: 1; min-height: 0; }
  .list-col .row { padding: 10px 8px; border-radius: 6px; }
  .list-col .sum { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .pane-col .grid2.detail { grid-template-columns: 1fr; }
  .pane-col .card { margin-bottom: 18px; }
  pre.body { max-height: none; }
}
@media (min-width: 1700px) {
  .pane-col .grid2.detail { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
  .split { grid-template-columns: 460px minmax(0, 1fr); }
}

/* Telefon – zásady DOXA: jedna ruka, hlavní akce dole na dosah palce, velká tlačítka, světlý vzhled čitelný venku */
@media (max-width: 900px) {
  body { font-size: 16px; padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .grid2, .grid2.wide { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .top { padding: 0 12px; }
  .top nav a { display: none; }
  .top nav a[href="?p=rules"], .top nav a[href="?p=settings"], .top nav a.out { display: inline-block; font-size: 14px; padding: 8px; }
  .top nav { justify-content: flex-end; }
  .brand { font-size: 17px; }
  main { padding: 14px 10px; }
  .card { padding: 15px; border-radius: 12px; }
  .btn { min-height: 48px; padding: 12px 16px; font-size: 16px; }
  input, select, textarea { font-size: 16px; padding: 12px; } /* bez zoomu na iOS */
  .row { padding: 14px 4px; }
  .tabs { width: 100%; overflow-x: auto; }
  .tabs a { flex: 1; text-align: center; padding: 10px 8px; white-space: nowrap; }
  .ev form.x button, form.done button { width: 40px; height: 40px; font-size: 18px; }

  nav.bottom {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    background: var(--card); border-top: 1px solid var(--line);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 10px rgba(21,41,67,.08);
  }
  nav.bottom a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; font-size: 11px; color: var(--muted); text-decoration: none; position: relative; border-radius: 10px; }
  nav.bottom a.on { color: var(--accent); background: #edf3fa; }
  nav.bottom .badge { position: absolute; top: 2px; left: 55%; font-size: 11px; }

  /* tlačítko Schválit a odeslat zůstává dole nad lištou */
  .draft .btns { position: sticky; bottom: calc(66px + env(safe-area-inset-bottom)); background: var(--card); padding: 10px 0; margin: 0; border-top: 1px solid var(--line); z-index: 4; }
  .draft .btns .btn.primary { flex: 1 1 100%; }
}
