:root {
  --bg: #f6f4f1;
  --panel: #ffffff;
  --ink: #141414;
  --muted: #6f6b68;
  --line: #e2ddd7;
  --accent: #c2262e;
  --hour: 64px; /* height of one hour in the day grid */
  --day-start: 8;
  --day-end: 20;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
button:disabled, input:disabled, textarea:disabled { opacity: 0.5; cursor: default; }
input, select, textarea { font: inherit; color: inherit; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
label input, label select, label textarea {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font-size: 16px; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
}
label input:focus, label select:focus, label textarea:focus { outline: 2px solid var(--ink); outline-offset: -1px; }
.btn { background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 999px; font-weight: 500; }
.btn:hover { background: var(--accent); }
.btn.small { padding: 8px 14px; font-size: 14px; }
.ghost { padding: 11px 16px; color: var(--muted); }
.danger { padding: 11px 16px; color: var(--accent); }
.error { color: var(--accent); font-size: 14px; margin: 4px 0 10px; }
.hint { color: var(--muted); font-size: 13px; margin: -4px 0 12px; }
.hint.warn { color: var(--accent); margin: 0 0 10px; }
.hint.deleted { color: var(--del-ink); margin: 0 0 10px; }
.ghost.restore { color: var(--del-ink); font-weight: 600; }
[hidden] { display: none !important; }

/* Login */
#login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.card { background: var(--panel); border-radius: 18px; padding: 32px 28px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06); }
.login-card { width: 100%; max-width: 360px; }
.login-logo { display: block; width: 220px; margin: 0 auto 28px; }
.login-card .btn { width: 100%; margin-top: 6px; }

/* Bar */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.icon { width: 36px; height: 36px; border-radius: 10px; font-size: 20px; display: grid; place-items: center; }
.icon:hover, .today:hover { background: var(--bg); }
.today { padding: 0 12px; height: 36px; border-radius: 10px; border: 1px solid var(--line); font-size: 14px; }
#date { border: 0; background: none; width: 0; opacity: 0; padding: 0; margin: 0; }
.title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; cursor: pointer; }
.break { display: none; }
.views { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.view { padding: 0 12px; height: 34px; font-size: 14px; }
.view.active { background: var(--ink); color: #fff; }
.mine { height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.mine.active { border-color: var(--ink); color: var(--ink); font-weight: 600; }
.menu {
  position: absolute; right: 10px; top: 54px; z-index: 6;
  display: grid; min-width: 220px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}
.menu[hidden] { display: none; }
.menu button { text-align: left; padding: 11px 14px; border-radius: 10px; }
.menu button:hover { background: var(--bg); }

/* Day view */
.calendar { padding-bottom: 90px; }
.day {
  display: grid; grid-template-columns: 48px 1fr 1fr;
  background: var(--panel);
}
.day .head { position: sticky; top: var(--bar, 52px); z-index: 4; background: var(--panel); border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: center; font-weight: 600; font-size: 14px; }
.day .head.corner { border-right: 1px solid var(--line); }
.day .head .sum { display: block; font-weight: 400; font-size: 11px; color: var(--muted); } /* owner only: the column's takings */
.totals { grid-column: 1 / -1; padding: 12px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); background: var(--panel); }
.totals b { color: var(--ink); font-size: 14px; }
.day .head .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.times { position: relative; border-right: 1px solid var(--line); padding-top: 8px; }
.times .h { height: var(--hour); font-size: 11px; color: var(--muted); text-align: right; padding-right: 6px; transform: translateY(-7px); }
.col { position: relative; border-right: 1px solid var(--line); padding-top: 8px; }
.col:last-child { border-right: 0; }
.slot { height: var(--hour); border-bottom: 1px solid var(--line); background: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--hour) / 2 - 1px), #f1eeea calc(var(--hour) / 2 - 1px), #f1eeea calc(var(--hour) / 2)); }
.slot.closed { background: repeating-linear-gradient(135deg, #f7f5f2 0 6px, #efece8 6px 7px); }
.appt {
  position: absolute; left: 3px; right: 3px; overflow: hidden;
  padding: 4px 7px; border-radius: 8px; color: #fff; font-size: 12px; line-height: 1.25;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15); cursor: pointer;
}
.appt b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt span { display: block; opacity: 0.9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt.short { padding: 1px 7px; font-size: 11px; min-height: 16px; line-height: 14px; }
.appt.short span { display: none; }
.buffer { position: absolute; left: 3px; right: 3px; border-radius: 0 0 6px 6px; opacity: 0.25; background: repeating-linear-gradient(135deg, currentColor 0 3px, transparent 3px 6px); pointer-events: none; }
/* Day view: tight two-line boxes; a box too small for two lines puts the service after the name */
.dv .appt { padding: 2px 6px; line-height: 1.15; }
.dv .appt.short { padding: 0 6px; min-height: 0; font-size: 11px; line-height: 14px; white-space: nowrap; text-overflow: ellipsis; }
.dv .appt.short b, .dv .appt.short span { display: inline; font-size: 11px; }
.dv .appt.short span::before { content: ' · '; }
/* Owner only: a booking the colleague deleted stays visible, faded blue, behind the live blocks.
   When a live booking took the same time, the two share the column side by side. */
:root { --del-bg: #dbe7f5; --del-ink: #4a6a94; --del-line: #9db6d6; }
.appt.deleted { background: var(--del-bg); color: var(--del-ink); border: 1px dashed var(--del-line); box-shadow: none; z-index: 0; }
.appt.deleted b { color: var(--del-ink); }
.appt.deleted.shared { left: 58%; }
.appt.shared:not(.deleted) { right: 44%; }
.now { position: absolute; left: 0; right: 0; height: 2px; background: var(--accent); z-index: 2; pointer-events: none; }
.now::before { content: ''; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

/* "Nem leszek" – away block: grey hatch, no buffer */
.off {
  position: absolute; left: 3px; right: 3px; overflow: hidden; cursor: pointer;
  padding: 4px 7px; border-radius: 8px; font-size: 12px; line-height: 1.25; color: var(--muted);
  background: repeating-linear-gradient(135deg, #e8e4df 0 6px, #dad5cf 6px 7px); border: 1px solid #cfc9c2;
}
.off b { display: block; font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.off span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.off.short { padding: 1px 7px; font-size: 11px; line-height: 14px; }
.off.short span { display: none; }
.wk .off { left: 1px; right: 1px; padding: 2px 4px; font-size: 10px; line-height: 1.2; border-radius: 6px; }
.wk .off b { font-size: 10px; }
.wk .off.short { padding: 0 4px; line-height: 13px; }

/* Week view: same time grid, one column per day split per cosmetician */
.wk .head.wk-head { cursor: pointer; line-height: 1.2; }
.wk .head.wk-head small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
.wk .head.wk-head.is-today { color: var(--accent); }
.wk .times .h { font-size: 10px; padding-right: 4px; }
.wcol { display: grid; }
.wcol.today-col { background: #fffaf2; }
.sub { position: relative; border-right: 1px solid #f1eeea; }
.sub:last-child { border-right: 0; }
.wk .appt { left: 1px; right: 1px; padding: 2px 4px; font-size: 10px; line-height: 1.2; border-radius: 6px; }
.wk .appt b { font-size: 10px; }
.wk .appt.short { padding: 0 4px; min-height: 14px; line-height: 13px; }
.wk .buffer { left: 1px; right: 1px; }

/* Month view */
.mo { display: grid; gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.mo .head { position: sticky; top: var(--bar, 52px); z-index: 4; background: var(--panel); padding: 8px 4px; text-align: center; font-weight: 600; font-size: 13px; }
.mcell { min-height: 104px; padding: 4px; background: var(--panel); cursor: pointer; overflow: hidden; }
.mcell.other { background: var(--bg); }
.mcell.other .mo-num { color: var(--muted); opacity: 0.6; }
.mcell.closed { background: repeating-linear-gradient(135deg, #f7f5f2 0 6px, #efece8 6px 7px); }
.mcell:hover { background: #fffaf2; }
.mo-num { font-size: 13px; font-weight: 600; width: 24px; height: 24px; line-height: 24px; text-align: center; border-radius: 50%; margin-bottom: 2px; }
.mcell.is-today .mo-num { background: var(--accent); color: #fff; }
.mo-appt { display: flex; gap: 4px; align-items: baseline; margin: 2px 0; padding: 2px 5px; border-radius: 5px; color: #fff; font-size: 11px; line-height: 1.3; overflow: hidden; white-space: nowrap; }
.mo-appt b { font-weight: 600; flex: none; }
.mo-appt span { overflow: hidden; text-overflow: ellipsis; opacity: 0.95; }
.mo-off { background: #e8e4df; color: var(--ink); border-left: 3px solid; border-radius: 3px 5px 5px 3px; }
.mo-off b { color: var(--muted); }
.mo-del { background: var(--del-bg); color: var(--del-ink); border: 1px dashed var(--del-line); padding-top: 1px; padding-bottom: 1px; }
.mo-del span { text-decoration: line-through; }

/* FAB */
.fab {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 5;
  width: 58px; height: 58px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 30px;
  box-shadow: 0 8px 24px rgba(194, 38, 46, 0.4);
}

/* Dialogs */
dialog { border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100% - 24px)); max-height: calc(100% - 24px); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
dialog::backdrop { background: rgba(20, 20, 20, 0.45); }
dialog form, .dialog-body { padding: 22px 22px 18px; }
dialog h2 { margin: 0 0 16px; font-size: 20px; font-weight: 600; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.buttons { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.spacer { flex: 1; }
.danger.armed { background: var(--accent); color: #fff; border-radius: 10px; padding: 0 12px; }
.service-row .acts button.armed { width: auto; padding: 0 8px; background: var(--accent); color: #fff; font-size: 12px; }

/* Staff choice: two buttons instead of a dropdown (no picker popup on phones) */
.seg { display: flex; margin-top: 4px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.seg button { flex: 1; padding: 10px 6px; font-size: 16px; color: var(--ink); border-right: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg button:last-child { border-right: 0; }
.seg button .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.seg button.active { background: var(--ink); color: #fff; }

/* Checkbox row ("Egész nap") */
.check { display: flex; align-items: center; gap: 10px; margin: 2px 0 12px; font-size: 15px; color: var(--ink); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; padding: 0; display: inline-block; accent-color: var(--accent); }

/* Service checklist in the appointment form */
.field { margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.field-label small { color: var(--accent); margin-left: 6px; }
.service-pick { margin-top: 4px; max-height: min(360px, 42vh); overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 4px 0; }
.pick-cat { padding: 8px 12px 2px; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.pick { display: flex; align-items: center; gap: 10px; margin: 0; padding: 7px 12px; font-size: 15px; color: var(--ink); cursor: pointer; }
.pick:hover { background: var(--bg); }
.pick input { width: 18px; height: 18px; margin: 0; padding: 0; display: inline-block; accent-color: var(--accent); }
.pick small { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.pick.inactive { color: var(--muted); }

/* Services editor */
.service-cat { margin: 14px 0 6px; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.service-row { display: grid; grid-template-columns: 1.2fr 2fr 64px 90px auto; gap: 6px; align-items: center; margin-bottom: 6px; }
.service-row input { padding: 7px 9px; font-size: 14px; border: 1px solid var(--line); border-radius: 8px; min-width: 0; background: #fff; }
.service-row input:focus { outline: 2px solid var(--ink); outline-offset: -1px; }
.service-row.inactive input { color: var(--muted); background: var(--bg); }
.service-row .acts { display: flex; gap: 2px; }
.service-row .acts button { width: 30px; height: 30px; border-radius: 8px; font-size: 15px; color: var(--muted); }
.service-row .acts button:hover { background: var(--bg); color: var(--ink); }
.service-row.new { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }

/* Search */
.results { max-height: 50vh; overflow: auto; margin-top: 10px; }
.results button { display: block; width: 100%; text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.results button:hover { background: var(--bg); }
.results small { color: var(--muted); display: block; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 20; background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); }
.toast[hidden] { display: none; }

@media (max-width: 560px) {
  /* Phones: two rows. Row 1: ‹ Ma › · Nap Hét Hónap · ☰.  Row 2: Csak én · date · Nem leszek. */
  .bar { flex-wrap: wrap; gap: 4px; padding-left: 8px; padding-right: 8px; }
  .break { display: block; flex-basis: 100%; height: 0; order: 8; } /* after the row-1 controls (order 0), before Csak én (9) */
  .icon { width: 32px; }
  .today { padding: 0 8px; font-size: 13px; }
  .views { margin-left: auto; }
  .view { padding: 0 7px; font-size: 13px; }
  .title { order: 10; text-align: center; font-size: 14px; min-width: 0; }
  .mine { order: 9; height: 30px; padding: 0 8px; font-size: 12px; }
  #away-btn { order: 11; }
  .mcell { min-height: 72px; padding: 3px 2px; }
  .mo-appt { padding: 1px 3px; font-size: 10px; }
  .mo-appt span { display: none; }
  .mo-off b, .mo-off span { display: none; }
  .mo-off::after { content: 'Távol'; } /* "Nem leszek" does not fit a phone-width cell */
  .mo-num { font-size: 12px; width: 20px; height: 20px; line-height: 20px; }
  .row { grid-template-columns: 1fr 1fr; }
  .service-row { grid-template-columns: 1fr 1fr; }
  .service-row input[name="name"] { grid-column: 1 / -1; }
  .service-row .acts { grid-column: 2; justify-content: flex-end; }
  dialog { width: calc(100% - 12px); }
  .day .head { font-size: 13px; }
  :root { --hour: 72px; }
  .calendar:has(.wk) { overflow-x: auto; }
  .calendar:has(.wk) .head { top: 0; }
  .wk { min-width: 700px; }
  .wk .times { position: sticky; left: 0; z-index: 3; background: var(--panel); }
  .wk .head.corner { position: sticky; left: 0; z-index: 5; }
}
