:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1f2733;
  --muted: #7b8794;
  --line: #e3e8f0;
  --primary: #2563eb;
  --danger: #e11d48;
  --ok: #16a34a;
  --warn: #d97706;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; }

/* topbar */
.topbar {
  display: flex; align-items: center; gap: 18px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 10px 20px; position: sticky; top: 0; z-index: 50;
}
.brand a { font-weight: 700; color: var(--ink); font-size: 17px; }
.nav { display: flex; gap: 14px; flex: 1; }
.nav a { color: var(--ink); padding: 6px 4px; }
.userbox { display: flex; align-items: center; gap: 10px; }
.who { color: var(--muted); font-size: 14px; }
.inline { display: inline; margin: 0; }
.link { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 14px; }

.content { padding: 20px; max-width: 1180px; margin: 0 auto; }

/* messages */
.messages { list-style: none; padding: 0; margin: 12px 20px; max-width: 1180px; }
.msg { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 8px; }
.msg.success { background: #dcfce7; color: #166534; }
.msg.error { background: #fee2e2; color: #991b1b; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 7px 13px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); cursor: pointer; font-size: 14px;
  text-decoration: none;
}
.btn:hover { text-decoration: none; border-color: #c7d0dd; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn.danger { color: var(--danger); border-color: #f3c2cc; }
.btn.danger:hover { background: #fff1f3; }
.btn.ok { color: #fff; background: var(--ok); border-color: var(--ok); }
.btn.warn { color: #fff; background: var(--warn); border-color: var(--warn); }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.card.narrow { max-width: 360px; margin: 60px auto; }
.cols { display: flex; gap: 16px; align-items: flex-start; }
.cols .grow { flex: 1; }
.card .grow { flex: 1; }

/* day bar / filters */
.daybar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.daynav { display: flex; align-items: center; gap: 10px; }
.filters { display: flex; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.filters label, .vform label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.filters select, .vform input, .vform select, .vform textarea, .searchbar input {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; color: var(--ink); background: #fff;
}
.notice { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; padding: 12px 16px; border-radius: var(--radius); margin-bottom: 14px; }

/* vertical form */
.vform { display: flex; flex-direction: column; gap: 12px; max-width: 480px; }
.formrow { display: flex; gap: 10px; margin-top: 6px; }
.error { color: var(--danger); font-size: 13px; }
.muted { color: var(--muted); }
.section { margin: 22px 0 10px; }

/* timeline */
.timeline-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 10px 10px 0; overflow-x: auto; margin-bottom: 18px; }
.timeline { position: relative; min-width: 520px; }
.gutter { position: absolute; left: 0; top: 0; width: 56px; height: 100%; }
.hour { position: absolute; left: 0; transform: translateY(-50%); font-size: 12px; color: var(--muted); width: 50px; text-align: right; }
.lane { position: absolute; left: 64px; right: 8px; top: 0; height: 100%; border-left: 1px solid var(--line); }
.hline { position: absolute; left: 0; right: 0; border-top: 1px dashed #eef1f6; }
.shift-band { position: absolute; left: 0; right: 0; background: color-mix(in srgb, var(--c) 12%, #fff); border-left: 3px solid var(--c); border-radius: 4px; }
.shift-band span { font-size: 11px; color: var(--muted); padding: 2px 6px; display: block; }
.free-cell { position: absolute; left: 2px; right: 2px; font-size: 11px; color: transparent; border-radius: 4px; display: flex; align-items: center; padding-left: 8px; }
.free-cell:hover { background: #eaf2ff; color: var(--primary); text-decoration: none; outline: 1px dashed var(--primary); }
.appt {
  position: absolute; left: 6px; right: 6px; background: color-mix(in srgb, var(--c) 22%, #fff);
  border-left: 4px solid var(--c); border-radius: 6px; padding: 3px 8px; overflow: hidden;
  color: var(--ink); font-size: 12px; line-height: 1.25;
}
.appt:hover { text-decoration: none; box-shadow: 0 2px 8px rgba(0,0,0,.12); z-index: 5; }
.appt b { display: block; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.appt span { color: var(--muted); }
.appt.status-completed { opacity: .75; }

/* table */
table.grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.grid th, table.grid td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
table.grid th { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: 13px; }
table.grid tr:last-child td { border-bottom: none; }
.actions { display: flex; gap: 6px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* status badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: #eef2f7; color: #475569; }
.badge.status-booked { background: #e0edff; color: #1e40af; }
.badge.status-confirmed { background: #ddebff; color: #1e3a8a; }
.badge.status-arrived { background: #fef9c3; color: #854d0e; }
.badge.status-completed { background: #dcfce7; color: #166534; }
.badge.status-cancelled { background: #f1f5f9; color: #94a3b8; }
.badge.status-no_show { background: #fee2e2; color: #991b1b; }

/* doctor day cards */
.cards-list { display: flex; flex-direction: column; gap: 10px; }
.appt-card { display: flex; gap: 16px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--primary); border-radius: var(--radius); padding: 12px 16px; }
.appt-card.status-completed { opacity: .7; }
.appt-card.status-no_show { border-left-color: var(--danger); }
.appt-time { font-weight: 700; font-size: 16px; min-width: 110px; }
.appt-main { flex: 1; }
.appt-patient { font-weight: 600; }
.appt-meta { display: flex; gap: 10px; align-items: center; margin-top: 4px; }
.appt-comment { margin-top: 6px; color: #475569; }
.appt-note { margin-top: 6px; color: #92400e; background: #fffbeb; border: 1px solid #fde68a; border-radius: 6px; padding: 4px 8px; display: inline-block; }
.appt-actions form { display: flex; gap: 6px; }

.searchbar { display: flex; gap: 8px; margin-bottom: 16px; max-width: 480px; }
.searchbar input { flex: 1; }

/* week report (шахматка) */
.week-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; margin-bottom: 14px; }
.week-head { display: flex; border-bottom: 2px solid var(--line); min-width: 760px; }
.week-head .corner { width: 56px; flex: none; }
.week-head .dh { flex: 1; min-width: 100px; text-align: center; padding: 8px 4px; border-left: 1px solid var(--line); color: var(--ink); display: flex; flex-direction: column; gap: 2px; }
.week-head .dh:hover { text-decoration: none; background: #f8fafc; }
.week-head .dh.today { background: #eff6ff; }
.week-head .wd { font-weight: 700; }
.week-head .dn { font-size: 13px; color: var(--muted); }
.week-head .cnt { font-size: 11px; color: var(--muted); }
.week-body { display: flex; position: relative; min-width: 760px; }
.week-body .gutter2 { width: 56px; flex: none; position: relative; }
.week-col { flex: 1; min-width: 100px; position: relative; border-left: 1px solid var(--line); }
.week-col.today { background: #f7fbff; }
.wk-appt {
  position: absolute; left: 2px; right: 2px; background: color-mix(in srgb, var(--c) 22%, #fff);
  border-left: 3px solid var(--c); border-radius: 5px; padding: 1px 5px; overflow: hidden;
  font-size: 11px; line-height: 1.2; color: var(--ink); white-space: nowrap; text-overflow: ellipsis;
}
.wk-appt:hover { text-decoration: none; box-shadow: 0 2px 8px rgba(0,0,0,.12); z-index: 5; overflow: visible; }
.wk-appt b { color: var(--ink); }
