:root {
  --bg: #f6f3ec;
  --card: #fffdf8;
  --ink: #2a2620;
  --muted: #7a7266;
  --line: #e4ddcf;
  --accent: #2f6b4a;
  --accent-ink: #ffffff;
  --taken: #cfe8d6;
  --taken-ink: #24553a;
  --mine: #2f6b4a;
  --mine-ink: #ffffff;
  --free-hover: #f1ead9;
  --past: #efebe3;
  --danger: #a33a2c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 50, 30, .06), 0 6px 24px rgba(60, 50, 30, .06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; margin: 0; }
h2 { font-size: 1.25rem; margin: 0 0 .75rem; }

.wrap { max-width: 760px; margin: 0 auto; padding: 20px 16px 48px; }
header.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 20px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 34px; height: 34px; }
.brand small { display: block; color: var(--muted); font-size: .85rem; font-family: system-ui, sans-serif; font-weight: 400; }
.who { text-align: right; font-size: .85rem; color: var(--muted); }
.who b { color: var(--ink); font-weight: 600; word-break: break-all; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.narrow { max-width: 420px; margin: 8vh auto 0; }
.narrow p { color: var(--muted); margin: 0 0 16px; }

label { display: block; font-size: .9rem; font-weight: 600; margin: 0 0 6px; }
input[type=password], input[type=email], input[type=text] {
  width: 100%; padding: 12px 14px; font-size: 1.05rem; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--ink);
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
input.code { letter-spacing: .4em; font-variant-numeric: tabular-nums; text-align: center; font-size: 1.4rem; }

button, .btn {
  appearance: none; border: 0; border-radius: 10px; padding: 12px 18px; font: inherit; font-weight: 600;
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
button:hover { filter: brightness(1.07); }
button:disabled { opacity: .55; cursor: default; }
button.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.danger { background: var(--danger); }
button.link { background: none; color: var(--accent); padding: 0; font-weight: 500; text-decoration: underline; }
.row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.row > button { flex: 1 1 auto; }

.msg { margin-top: 12px; font-size: .92rem; min-height: 1.3em; }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--accent); }

/* ---- kalendář */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; }
.tabs button {
  background: transparent; color: var(--ink); border: 1px solid var(--line); padding: 8px 14px;
  font-weight: 500; white-space: nowrap; text-transform: capitalize;
}
.tabs button[aria-selected=true] { background: var(--ink); color: var(--card); border-color: var(--ink); }

.grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.dow { text-align: center; font-size: .78rem; color: var(--muted); font-weight: 600; padding-bottom: 2px; }
.day {
  position: relative; aspect-ratio: 1 / 1; min-width: 0; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); padding: 6px; display: flex; flex-direction: column;
  justify-content: space-between; align-items: flex-start; font-weight: 600; font-size: 1rem; text-align: left;
}
.day .tag { font-size: .68rem; font-weight: 600; line-height: 1.1; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand small a { color: var(--muted); }
button.day:hover { filter: none; background: var(--free-hover); }
.day.taken { background: var(--taken); border-color: var(--taken); color: var(--taken-ink); }
.day.mine { background: var(--mine); border-color: var(--mine); color: var(--mine-ink); }
.day.mine .tag { font-size: 1rem; line-height: 1; }
button.day.mine:hover { background: #285d40; }
.day.past { background: var(--past); border-color: var(--past); color: #aaa194; font-weight: 400; }
.day.past.taken, .day.past.mine { opacity: .55; }
.day.today { box-shadow: inset 0 0 0 2px var(--ink); }
.day.blank { border: 0; background: transparent; }
.day:disabled { opacity: 1; cursor: default; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 16px; font-size: .85rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 16px; height: 16px; border-radius: 5px; display: inline-block; border: 1px solid var(--line); background: #fff; }
.legend i.taken { background: var(--taken); border-color: var(--taken); }
.legend i.mine { background: var(--mine); border-color: var(--mine); }

.mydays { margin-top: 18px; }
.mydays ul { list-style: none; padding: 0; margin: 0; }
.mydays li { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 0; border-top: 1px solid var(--line); }
.mydays li:first-child { border-top: 0; }
.mydays .empty { color: var(--muted); }
.mydays button { padding: 6px 12px; font-size: .9rem; }

.stack > * + * { margin-top: 16px; }

/* ---- dialog */
dialog {
  border: 0; border-radius: var(--radius); padding: 22px; max-width: min(400px, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgba(0,0,0,.25); background: var(--card); color: var(--ink);
}
dialog::backdrop { background: rgba(30, 25, 15, .45); }
dialog h3 { margin: 0 0 6px; font-size: 1.2rem; }
dialog p { margin: 0; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: .92rem; box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}

/* ---- správa */
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px 6px; border-top: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; border-top: 0; }
td.email { word-break: break-all; }
td button { padding: 5px 10px; font-size: .85rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #fbe9e5; color: var(--danger); border-radius: 999px; padding: 3px 10px; font-size: .85rem; }
.muted { color: var(--muted); font-size: .9rem; }
.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; }
.actions button { font-weight: 500; }

[hidden] { display: none !important; }

@media (max-width: 480px) {
  .wrap { padding-top: 14px; }
  .card { padding: 14px; }
  .grid { gap: 4px; }
  .day { aspect-ratio: auto; min-height: 58px; padding: 4px 5px; font-size: .92rem; border-radius: 8px; }
  .day .tag { font-size: .6rem; }
  h1 { font-size: 1.3rem; }
  header.top { flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 14px; }
  .who { text-align: left; }
  .brand img { width: 30px; height: 30px; }
}
