/* ===== Транспорт на възрастните — стил в духа на Apple, лесен за възрастни ===== */
:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #1c1c1e;
  --text-2: #6b6b70;
  --text-3: #9a9aa0;
  --blue: #007aff;
  --blue-dark: #0062cc;
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;
  --separator: #e5e5ea;
  --radius: 20px;
  --radius-sm: 14px;
  --tap: 60px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 8px 24px rgba(0,0,0,0.05);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 19px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ===== Вход ===== */
.login {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #eaf3ff 0%, var(--bg) 60%);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--card); border-radius: 28px;
  padding: 36px 28px; text-align: center;
  box-shadow: var(--shadow);
}
.login-icon { font-size: 56px; margin-bottom: 8px; }
.login-card h1 { font-size: 30px; font-weight: 700; margin: 6px 0 4px; letter-spacing: -0.02em; }
.login-sub { color: var(--text-2); margin: 0 0 24px; font-size: 18px; }
.login-input {
  width: 100%; height: var(--tap); border: none; background: #f2f2f7;
  border-radius: var(--radius-sm); padding: 0 18px; font-size: 20px;
  text-align: center; margin-bottom: 16px; color: var(--text);
}
.login-input:focus { outline: 3px solid rgba(0,122,255,0.25); }
.login-error { color: var(--red); margin-top: 14px; font-size: 17px; }

/* ===== Главна структура ===== */
.app { min-height: 100vh; padding-bottom: calc(86px + var(--safe-bottom)); }

.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(242,242,247,0.86);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--separator);
  padding-top: var(--safe-top);
}
.topbar-inner {
  height: 60px; display: flex; align-items: center; justify-content: center;
  position: relative; padding: 0 16px;
}
.topbar-title { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -0.02em; }
.topbar-action {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px; border: none; background: transparent;
  color: var(--blue); font-size: 34px; font-weight: 300; line-height: 1;
  border-radius: 50%;
}
.topbar-action:active { background: rgba(0,0,0,0.06); }

.view { padding: 16px 16px 24px; max-width: 720px; margin: 0 auto; }

/* ===== Tab bar ===== */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; justify-content: space-around;
  background: rgba(255,255,255,0.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--separator);
  padding-bottom: var(--safe-bottom);
}
.tab {
  flex: 1; border: none; background: transparent;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 0 10px; color: var(--text-3); font-size: 12px;
}
.tab-icon { font-size: 26px; filter: grayscale(1) opacity(0.55); transition: filter .15s; }
.tab-label { font-size: 12.5px; font-weight: 600; }
.tab.active { color: var(--blue); }
.tab.active .tab-icon { filter: none; }

/* ===== Карти / списъци ===== */
.section-title {
  font-size: 14px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-3);
  margin: 22px 4px 10px;
}
.section-title:first-child { margin-top: 4px; }

.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; margin-bottom: 14px;
}

/* Карта за дата от графика */
.day-card { display: flex; align-items: stretch; }
.day-date {
  flex: 0 0 78px; background: #f7f7fb;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 14px 6px; border-right: 0.5px solid var(--separator);
}
.day-date .dow { font-size: 13px; font-weight: 700; color: var(--blue); text-transform: uppercase; letter-spacing: .02em; }
.day-date .dnum { font-size: 30px; font-weight: 700; line-height: 1.05; }
.day-date .dmon { font-size: 13px; color: var(--text-2); }
.day-date.is-past .dow { color: var(--text-3); }
.day-main { flex: 1; padding: 14px 16px; display: flex; align-items: center; gap: 12px; min-width: 0; }
.day-info { flex: 1; min-width: 0; }
.day-info .label { font-size: 13px; color: var(--text-3); margin-bottom: 2px; }
.day-driver { font-size: 21px; font-weight: 600; letter-spacing: -0.01em; }
.day-driver.none { color: var(--orange); font-weight: 600; }
.day-special {
  display: inline-block; margin-top: 4px; font-size: 12.5px; font-weight: 700;
  color: var(--orange); background: #fff4e5; padding: 2px 8px; border-radius: 8px;
}
.chev { color: var(--text-3); font-size: 22px; flex: 0 0 auto; }
.day-card.is-today { outline: 2.5px solid var(--blue); }
.day-card.is-past { opacity: 0.62; }

/* Редове (шофьори/сестри) */
.row {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; min-height: var(--tap);
  border-bottom: 0.5px solid var(--separator);
  background: var(--card);
}
.row:last-child { border-bottom: none; }
.row:active { background: #f7f7f9; }
.avatar {
  flex: 0 0 auto; width: 50px; height: 50px; border-radius: 50%;
  background: linear-gradient(135deg, #5ac8fa, #007aff); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700;
}
.avatar.warm { background: linear-gradient(135deg, #ffd36e, #ff9f0a); }
.row-main { flex: 1; min-width: 0; }
.row-name { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.row-sub { font-size: 15px; color: var(--text-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub.addr { white-space: normal; }
.call-btn {
  flex: 0 0 auto; width: 50px; height: 50px; border-radius: 50%;
  border: none; background: var(--green); color: #fff; font-size: 24px;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
}
.call-btn:active { background: #28a745; }
.chev-row { color: var(--text-3); font-size: 22px; flex: 0 0 auto; }

/* Бутони */
.btn {
  border: none; border-radius: var(--radius-sm); font-size: 19px; font-weight: 600;
  height: var(--tap); padding: 0 22px; background: #e9e9ee; color: var(--text);
}
.btn:active { opacity: .85; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:active { background: var(--blue-dark); }
.btn-danger { background: #fff; color: var(--red); }
.btn-block { width: 100%; display: block; }
.btn-lg { height: 64px; font-size: 20px; }

/* Голям превключвател за свободен/зает (за шофьорите) */
.avail-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-bottom: 0.5px solid var(--separator);
  background: var(--card);
}
.avail-row:last-child { border-bottom: none; }
.avail-date { flex: 1; }
.avail-date .d1 { font-size: 19px; font-weight: 600; }
.avail-date .d2 { font-size: 14px; color: var(--text-2); }
.avail-date .assigned-tag { font-size: 12.5px; color: var(--blue); font-weight: 700; margin-top: 2px; }
.pill {
  border: none; border-radius: 999px; height: 46px; min-width: 132px; padding: 0 18px;
  font-size: 16px; font-weight: 700; display: inline-flex; align-items: center; gap: 7px;
  justify-content: center;
}
.pill.free { background: #e7f8ec; color: #1f9d3a; }
.pill.busy { background: #ffe9e7; color: var(--red); }

/* Профил / форма */
.profile-head { text-align: center; padding: 8px 0 18px; }
.profile-head .avatar { width: 84px; height: 84px; font-size: 32px; margin: 0 auto 12px; }
.profile-head .pname { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.profile-head .pphone { color: var(--text-2); font-size: 18px; margin-top: 2px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 14px; font-weight: 600; color: var(--text-2); margin: 0 4px 6px; }
.field input, .field textarea {
  width: 100%; min-height: 54px; border: none; background: var(--card);
  border-radius: var(--radius-sm); padding: 14px 16px; font-size: 19px; color: var(--text);
  box-shadow: var(--shadow);
}
.field textarea { min-height: 86px; resize: vertical; }
.field input:focus, .field textarea:focus { outline: 3px solid rgba(0,122,255,0.22); }

.hint { color: var(--text-2); font-size: 15px; margin: 4px 6px 16px; }
.empty {
  text-align: center; color: var(--text-2); padding: 50px 24px;
}
.empty .em-icon { font-size: 48px; margin-bottom: 10px; }

/* Избор на шофьор в листа */
.choice-row {
  display: flex; align-items: center; gap: 14px; padding: 15px 18px;
  border-bottom: 0.5px solid var(--separator); background: var(--card);
}
.choice-row:active { background: #f3f3f6; }
.choice-row.is-busy { opacity: 0.55; }
.choice-name { flex: 1; font-size: 19px; font-weight: 600; }
.choice-tag { font-size: 13px; font-weight: 700; color: var(--red); }
.choice-check { color: var(--blue); font-size: 24px; }

/* ===== Sheet (долен лист) ===== */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,0.35);
  display: flex; align-items: flex-end; animation: fade .2s ease;
}
.sheet {
  width: 100%; max-width: 720px; margin: 0 auto;
  background: var(--bg); border-radius: 22px 22px 0 0;
  max-height: 90vh; display: flex; flex-direction: column;
  padding-bottom: var(--safe-bottom); animation: slideup .28s cubic-bezier(.2,.8,.2,1);
}
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: #d0d0d6; margin: 8px auto 4px; }
.sheet-header {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px 10px;
  border-bottom: 0.5px solid var(--separator);
}
.sheet-title { flex: 1; text-align: center; font-size: 18px; font-weight: 700; margin: 0; }
.sheet-btn { border: none; background: transparent; color: var(--blue); font-size: 18px; padding: 8px; min-width: 64px; }
.sheet-btn-strong { font-weight: 700; }
.sheet-spacer { min-width: 64px; }
.sheet-body { overflow-y: auto; padding: 16px; -webkit-overflow-scrolling: touch; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideup { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-bottom)); transform: translateX(-50%);
  background: rgba(28,28,30,0.95); color: #fff; padding: 13px 22px; border-radius: 16px;
  font-size: 17px; z-index: 200; box-shadow: var(--shadow); max-width: 90%; text-align: center;
}

@media (min-width: 600px) {
  body { font-size: 20px; }
}

/* ===== График по групи ===== */
.day-groups { flex: 1; display: flex; flex-direction: column; }
.day-special-row { padding: 10px 16px 0; }
.group-line {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px 12px 16px;
  border-bottom: 0.5px solid var(--separator); cursor: pointer;
}
.group-line:last-child { border-bottom: none; }
.group-line:active { background: #f7f7f9; }
.group-left { flex: 1; min-width: 0; }
.g-name { font-size: 12.5px; font-weight: 700; color: var(--blue); text-transform: uppercase; letter-spacing: .02em; }
.g-driver { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.g-driver.none { color: var(--orange); }
.g-phone { font-size: 14px; color: var(--text-2); }
.group-right { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.conf-badge { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 8px; white-space: nowrap; }
.conf-badge.pending { background: #fff4e5; color: var(--orange); }
.conf-badge.ok { background: #e7f8ec; color: #1f9d3a; }
.call-btn.sm { width: 42px; height: 42px; font-size: 20px; }
.row-name.none { color: var(--orange); }

/* ===== Потвърждения (малки бутони в листа) ===== */
.conf-toggle { display: flex; gap: 6px; flex: 0 0 auto; }
.conf-btn { border: none; border-radius: 10px; height: 42px; padding: 0 12px; font-size: 15px; font-weight: 700; background: #eee; color: var(--text-2); }
.conf-btn.yes.on { background: var(--green); color: #fff; }
.conf-btn.no.on { background: var(--red); color: #fff; }

/* ===== Голямо потвърждение (за сестрите) ===== */
.bigconf { padding: 14px 16px; border-bottom: 0.5px solid var(--separator); }
.bigconf:last-child { border-bottom: none; }
.bigconf-date .d1 { font-size: 19px; font-weight: 700; }
.bigconf-date .d2 { font-size: 14px; color: var(--text-2); margin-bottom: 10px; }
.bigconf-btns { display: flex; gap: 10px; }
.bigbtn { flex: 1; border: none; border-radius: 14px; height: 56px; font-size: 18px; font-weight: 700; background: #eef0f3; color: var(--text-2); }
.bigbtn.yes.on { background: var(--green); color: #fff; }
.bigbtn.no.on { background: var(--red); color: #fff; }
.bigbtn:active { transform: scale(0.98); }

/* ===== Превключвател (switch) ===== */
.switch { width: 56px; height: 32px; border-radius: 999px; border: none; background: #d6d6db; position: relative; flex: 0 0 auto; transition: background .2s; }
.switch.on { background: var(--green); }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3); transition: left .2s; }
.switch.on .knob { left: 27px; }

/* Етикет за посока (само връщане / само отиване) */
.dir-tag { font-size: 12px; font-weight: 700; color: var(--orange); background: #fff4e5; padding: 1px 7px; border-radius: 7px; vertical-align: middle; }

/* Избор на дни в формата */
.day-pick { display: flex; gap: 10px; }
.day-chip { flex: 1; border: 2px solid var(--separator); background: var(--card); border-radius: var(--radius-sm); height: 54px; font-size: 17px; font-weight: 600; color: var(--text-2); }
.day-chip.on { border-color: var(--blue); background: #eaf3ff; color: var(--blue); }

/* select като полетата */
.field select { width: 100%; min-height: 54px; border: none; background: var(--card); border-radius: var(--radius-sm); padding: 14px 16px; font-size: 19px; color: var(--text); box-shadow: var(--shadow); -webkit-appearance: none; appearance: none; }

/* ===== Изглед „Аз“ ===== */
.welcome { text-align: center; padding: 24px 16px 8px; }
.welcome-icon { font-size: 52px; }
.welcome-q { font-size: 28px; font-weight: 700; margin-top: 8px; letter-spacing: -0.02em; }
.welcome-sub { color: var(--text-2); font-size: 17px; margin: 10px auto 18px; max-width: 420px; }
.big-pick {
  display: block; width: 100%; height: 84px; border: none; border-radius: 22px;
  font-size: 23px; font-weight: 700; color: #fff; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.big-pick.driver { background: linear-gradient(135deg, #5ac8fa, #007aff); }
.big-pick.sister { background: linear-gradient(135deg, #ffd36e, #ff9f0a); }
.big-pick:active { transform: scale(0.98); }

.greet { padding: 6px 4px 4px; }
.greet-hi { font-size: 27px; font-weight: 700; letter-spacing: -0.02em; }

.device-foot {
  margin-top: 22px; text-align: center; color: var(--text-2); font-size: 15px;
  padding: 14px; border-top: 0.5px solid var(--separator);
}
.btn-link { border: none; background: transparent; color: var(--blue); font-size: 15px; font-weight: 700; padding: 4px 6px; }

/* ===== Бутон „Добави в Google Календар“ ===== */
.gcal-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 60px; border-radius: var(--radius-sm);
  background: var(--blue); color: #fff; font-size: 18px; font-weight: 700;
  text-decoration: none; margin-top: 14px;
}
.gcal-btn:active { background: var(--blue-dark); }
.gcal-btn.gcal-compact {
  height: 50px; font-size: 16px; margin-top: 8px; margin-bottom: 18px;
  background: #eaf3ff; color: var(--blue);
}

/* ===== Печат (екранно скрит) ===== */
#print-root { display: none; }

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 11pt; }
  .app, .login, .topbar, .tabbar, .sheet-overlay, .toast { display: none !important; }
  #print-root { display: block; }
  .print-doc { color: #000; }
  .print-head h1 { font-size: 22pt; margin: 0 0 2px; }
  .print-sub { font-size: 10pt; color: #333; margin-bottom: 6px; }
  .print-month { font-size: 13pt; margin: 14px 0 6px; border-bottom: 2px solid #000; padding-bottom: 3px; }
  .print-table { width: 100%; border-collapse: collapse; }
  .print-table th, .print-table td { border: 1px solid #999; padding: 6px 8px; text-align: left; vertical-align: top; font-size: 10.5pt; }
  .print-table th { background: #f0f0f0; font-size: 9.5pt; text-transform: uppercase; }
  .print-table .pd { white-space: nowrap; }
  .print-table .pph { color: #444; font-size: 9.5pt; }
  .print-table .pempty { color: #aaa; text-align: center; }
  .psp { color: #b35a00; font-weight: 700; font-size: 9pt; }
  .print-contacts { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; }
  .pc { font-size: 10.5pt; break-inside: avoid; }
  .paddr { color: #555; font-size: 9.5pt; }
  .print-foot { margin-top: 14px; font-size: 9.5pt; color: #333; border-top: 1px solid #ccc; padding-top: 6px; }
  tr, .pc { page-break-inside: avoid; }
}
