:root {
  color-scheme: light dark;
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c1d21;
  --muted: #6b7280;
  --border: #d8dbe0;
  --accent: #1e88e5;
  --danger: #e53935;
  --ok: #43a047;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a;
    --card: #212327;
    --text: #f2f3f5;
    --muted: #9aa0a6;
    --border: #33363c;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  /* per-building accent, set by JS via data-building */
  --building: #607d8b;
}
body[data-building="hybernska"] { --building: #3949AB; }
body[data-building="rehorova"]  { --building: #00897B; }
button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 14px;
  padding: 14px 18px;
  min-height: 56px;
  user-select: none;
}
button:active { transform: translateY(1px); }
button.primary { background: var(--accent); color: #fff; border-color: transparent; font-weight: 600; }
button.danger { background: var(--danger); color: #fff; border-color: transparent; }
button.ghost { background: transparent; }
input, select {
  font: inherit;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  width: 100%;
}

.wrap { max-width: 960px; margin: 0 auto; padding: 16px; }
.hidden { display: none !important; }

/* header — tinted with the building accent so the two tablets look different */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--building);
  color: #fff;
  position: sticky; top: 0; z-index: 5;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}
.tb-spacer { flex: 1; }

.tb-building {
  position: relative; display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.16); border-radius: 12px; padding: 10px 14px;
  font-weight: 800; font-size: 1.15rem; min-height: 52px;
}
.tb-building-icon { font-size: 1.2rem; }
.tb-building-caret { opacity: 0.8; font-size: 0.9rem; }
.tb-building-select {
  position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%;
  border: 0; margin: 0; padding: 0; cursor: pointer; color: #000;
}

.tb-clock {
  display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1;
  background: rgba(255,255,255,0.16); border-radius: 12px; padding: 8px 14px; min-height: 52px;
  justify-content: center;
}
.tb-time { font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.tb-date { font-size: 0.8rem; opacity: 0.9; }

.tb-owner {
  text-decoration: none; font-size: 1.4rem; line-height: 1;
  background: rgba(255,255,255,0.16); border-radius: 12px;
  width: 52px; height: 52px; display: flex; align-items: center; justify-content: center;
}

.lang-switch { display: flex; gap: 6px; }
.lang-switch button {
  padding: 10px 14px; min-height: 48px; font-size: 1.1rem; border-radius: 10px;
  display: flex; align-items: center; gap: 6px;
}
.lang-switch button[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: transparent; }
.lang-switch .flag { font-size: 1.4rem; line-height: 1; }

/* top-bar variant: white-on-accent, icon only */
.topbar .lang-switch button {
  background: rgba(255,255,255,0.16); color: #fff; border: 2px solid transparent; min-height: 44px; padding: 6px 10px;
}
.topbar .lang-switch button[aria-pressed="true"] { background: #fff; color: var(--building); border-color: #fff; }
.topbar .lang-switch .lbl { display: none; }

@media (max-width: 720px) {
  .tb-clock, .tb-building-icon { display: none; }
}

/* building picker */
.picker { display: grid; gap: 18px; margin-top: 8vh; }
.picker button { font-size: 1.8rem; padding: 48px; font-weight: 800; border-radius: 20px; min-height: 120px; }

/* employee grid — big touch targets */
.section-title { margin: 22px 4px 10px; font-size: 0.95rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.emp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.emp-btn {
  position: relative;
  border: none; border-radius: 18px; padding: 16px 14px 14px; min-height: 148px;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 4px;
  text-align: left; box-shadow: var(--shadow); color: #fff; /* JS overrides per background */
  overflow: hidden;
}
/* subtle diagonal texture so two same-colour buttons still read differently */
.emp-btn::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(135deg, rgba(255,255,255,0.14) 0 22%, transparent 22% 50%, rgba(0,0,0,0.10) 50% 72%, transparent 72%);
  background-size: 46px 46px;
}
.emp-btn .emoji {
  position: absolute; top: 8px; right: 10px; font-size: 2.6rem; line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.35));
}
.emp-btn .name { font-size: 1.3rem; font-weight: 800; line-height: 1.1; z-index: 1; }
.emp-btn .code { font-size: 0.9rem; opacity: 0.92; font-variant-numeric: tabular-nums; z-index: 1; }
.emp-btn .state { font-size: 0.82rem; margin-top: 6px; background: rgba(0,0,0,0.45); color: #fff; border-radius: 7px; padding: 3px 8px; align-self: flex-start; z-index: 1; }
.emp-btn .last { font-size: 0.72rem; opacity: 0.8; margin-top: 3px; z-index: 1; }
.emp-btn.running { outline: 4px solid #fff; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { outline-color: rgba(255,255,255,0.95); } 50% { outline-color: rgba(255,255,255,0.3); } }
.emp-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.emp-actions button { flex: 1 1 45%; min-height: 60px; font-size: 1.05rem; }

/* today list */
.today { margin-top: 24px; }
.entry {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px; margin-bottom: 8px;
}
.entry .dot { width: 16px; height: 16px; border-radius: 50%; flex: none; }
.entry .row-emoji {
  flex: none; width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
}
.entry .who { font-weight: 600; }
.entry .meta { color: var(--muted); font-size: 0.9rem; }
.entry .grow { flex: 1; min-width: 0; }
.entry .apts { font-size: 0.8rem; color: var(--muted); }
.entry .running-tag { color: var(--ok); font-weight: 600; font-size: 0.85rem; }
.entry-actions { display: flex; gap: 6px; }
.entry-actions button { min-height: 40px; padding: 8px 12px; }

/* overlay / sheet */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: flex-end; justify-content: center; z-index: 20;
}
.sheet {
  background: var(--card); width: 100%; max-width: 560px;
  border-radius: 18px 18px 0 0; padding: 20px; max-height: 90vh; overflow-y: auto;
}
@media (min-width: 600px) { .overlay { align-items: center; } .sheet { border-radius: 18px; } }
.sheet h2 { margin: 0 0 16px; font-size: 1.35rem; }
.sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.sheet-head h2 { margin: 0; flex: 1; font-size: 1.25rem; }
.sheet-edit {
  flex: none; width: 48px; height: 48px; min-height: 48px; padding: 0;
  font-size: 1.3rem; border-radius: 12px;
}
.action-pair { display: flex; gap: 12px; }
.action-pair .act { flex: 1; min-height: 88px; font-size: 1.2rem; font-weight: 700; }
.sheet-cancel-row { display: flex; justify-content: flex-end; margin-top: 16px; }
.btn-cancel {
  min-height: 44px; padding: 8px 20px; font-size: 0.95rem; border-radius: 10px;
  background: transparent; color: var(--danger); border: 1px solid var(--danger);
}
.sheet .row { display: flex; gap: 12px; margin-bottom: 14px; }
.sheet .row > * { flex: 1; }
.sheet input, .sheet select { min-height: 54px; font-size: 1.15rem; }
.sheet-btn-list button { width: 100%; min-height: 64px; font-size: 1.15rem; font-weight: 700; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.9rem; color: var(--muted); margin-bottom: 6px; }
.calc { font-size: 1rem; color: var(--muted); margin: 4px 0 14px; min-height: 1.2em; }
.disclosure { align-self: flex-start; padding: 8px 14px; min-height: 44px; margin-bottom: 10px; font-size: 0.95rem; }
.apt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 8px; margin-bottom: 12px; }
.apt-chip { padding: 14px 6px; text-align: center; font-size: 1rem; border-radius: 10px; min-height: 52px; }
.apt-chip[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: transparent; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 10px; margin-bottom: 12px; }
.swatch { height: 52px; border-radius: 12px; border: 3px solid transparent; }
.swatch[aria-pressed="true"] { border-color: var(--text); }
.emp-preview {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px; font-size: 1.5rem; vertical-align: middle;
}
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; margin-bottom: 12px; }
.emoji-pick { height: 52px; font-size: 1.7rem; border-radius: 12px; border: 3px solid transparent; padding: 0; }
.emoji-pick[aria-pressed="true"] { border-color: var(--text); background: var(--bg); }
.sheet-actions { display: flex; gap: 12px; margin-top: 10px; }
.sheet-actions button { flex: 1; min-height: 60px; font-size: 1.1rem; }
.err { color: var(--danger); font-size: 0.9rem; margin: 8px 0; min-height: 1.1em; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 10px;
  z-index: 40; max-width: 90vw; text-align: center; box-shadow: var(--shadow);
}
