/* «Резерв»: плотный табличный вид как в Vetmanager. Без внешних шрифтов и CDN. */
:root {
  --bg: #eef1f4; --card: #fff; --text: #1f2933; --muted: #6b7680;
  --accent: #2f6f8f; --accent-dark: #245a74; --accent-text: #fff; --border: #cfd6dd;
  --head: #e4e9ee; --row-hover: #eaf3f8; --row-alt: #f7f9fa;
  --warn-bg: #fff4d6; --error: #b42318; --new: #1d4ed8; --ok: #2e7d32;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--accent); }
main { margin: 0 auto; padding: 10px 12px; max-width: 1400px; }

/* Верхняя панель */
.top { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center;
  background: var(--accent); color: var(--accent-text); padding: 6px 12px; }
.top a, .top .link { color: var(--accent-text); text-decoration: none; }
.top a:hover, .top .link:hover { text-decoration: underline; }
.top nav { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.top nav.right { margin-left: auto; }
.brand { font-weight: 700; font-size: 15px; }
.quick { display: flex; gap: 4px; }
.quick input { width: 240px; min-height: 28px; padding: 3px 8px; border: 0; }
.quick button { min-height: 28px; padding: 3px 10px; }
.banner { background: var(--warn-bg); padding: 3px 12px; font-size: 13px; text-align: center; }

/* Блоки */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 3px;
  padding: 10px 12px; margin: 0 0 10px; }
.narrow { max-width: 480px; }
h1 { font-size: 18px; margin: 0 0 8px; } h2 { font-size: 15px; margin: 0 0 6px; }
h3 { font-size: 14px; margin: 10px 0 4px; }
.muted { color: var(--muted); }
.error { background: #fde8e7; color: var(--error); border-radius: 3px; padding: 6px 10px; }
.notice { background: var(--warn-bg); }
.hint { background: var(--row-alt); border: 1px dashed var(--border); padding: 4px 8px; }
.hidden { display: none !important; }
.tag { display: inline-block; font-size: 12px; padding: 0 6px; border-radius: 8px;
  background: #e5e7eb; color: var(--text); vertical-align: middle; }
.tag.new { background: #dbeafe; color: var(--new); }
.tag.warn { background: #fde8e7; color: var(--error); }

/* Поля и кнопки */
input, select, textarea, button, .button { font: inherit; }
input, select, textarea { width: 100%; padding: 4px 6px; border: 1px solid var(--border);
  border-radius: 2px; background: #fff; min-height: 28px; }
textarea { resize: vertical; }
button, .button { display: inline-block; padding: 4px 12px; min-height: 28px;
  border: 1px solid var(--border); border-radius: 2px; background: #f8fafb; color: var(--text);
  cursor: pointer; text-decoration: none; white-space: nowrap; }
button:hover, .button:hover { background: var(--row-hover); }
.primary, .button.primary { background: var(--accent); border-color: var(--accent-dark);
  color: var(--accent-text); }
.primary:hover, .button.primary:hover { background: var(--accent-dark); }
button.link { background: none; border: 0; padding: 0; min-height: 0; text-decoration: underline; }
form.inline { display: inline; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.stack label, .grid label { display: flex; flex-direction: column; gap: 2px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px;
  margin: 8px 0; }
label.check { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; }
label.check input { width: auto; min-height: 0; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.actions, .toolbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 0 0 8px; }
.toolbar .spacer { flex: 1; }
.search { display: flex; gap: 6px; margin-bottom: 10px; }

/* Таблицы данных */
table.data, table.items { width: 100%; border-collapse: collapse; background: #fff; }
table.data th, table.items th { background: var(--head); font-weight: 600; text-align: left;
  border: 1px solid var(--border); padding: 4px 6px; white-space: nowrap; }
table.data td, table.items td { border: 1px solid var(--border); padding: 3px 6px;
  vertical-align: top; }
table.data tbody tr:nth-child(even) { background: var(--row-alt); }
table.data tr.link-row { cursor: pointer; }
table.data tr.link-row:hover { background: var(--row-hover); }
table.data tr.dead, table.data tr.deleted { color: var(--muted); }
table.data tfoot td { font-weight: 600; background: var(--head); }
table.items td input, table.items td select { min-height: 24px; padding: 2px 4px; }
.num { text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* Список клиентов: фильтр слева, таблица справа */
.layout { display: grid; grid-template-columns: 230px 1fr; gap: 10px; align-items: start; }
.filter { display: flex; flex-direction: column; gap: 6px; }
.filter label { display: flex; flex-direction: column; gap: 2px; }
.filter label.check { flex-direction: row; }
.pager { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 8px 0 0; }

/* Профиль клиента */
.profile { display: grid; grid-template-columns: minmax(280px, 1fr) 1.4fr; gap: 10px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; margin: 0; }
.facts dt { color: var(--muted); } .facts dd { margin: 0; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 0 0 8px; }
.tabs button { border-bottom: 0; border-radius: 3px 3px 0 0; background: var(--head); }
.tabs button[aria-selected="true"] { background: #fff; font-weight: 600;
  position: relative; top: 1px; }
.sums { display: flex; gap: 18px; margin: 0 0 6px; }

/* Создание счёта: прайс слева, счёт справа */
.invoice-layout { display: grid; grid-template-columns: minmax(320px, 1fr) 1.5fr; gap: 10px;
  align-items: start; }
.price-list { max-height: 360px; overflow: auto; border: 1px solid var(--border); }
.price-list table.data td { border-width: 0 0 1px; }
.price-list tr { cursor: pointer; }
.price-list .grp { color: var(--muted); font-size: 12px; }
.medcard-box { margin-top: 10px; }
.medcard-box .entry { border: 1px solid var(--border); padding: 6px 8px; background: var(--row-alt); }
.medcard-box .entry .text { max-height: 160px; overflow: auto; }
.inv-head { display: grid; grid-template-columns: max-content 1fr; gap: 4px 10px; align-items: center; }
.inv-head select { max-width: 360px; }
.inv-sums { display: flex; gap: 6px 16px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.inv-sums .due { font-size: 16px; font-weight: 700; }
.pct { display: inline-flex; gap: 4px; align-items: center; }
.pct input { width: 70px; }
td.del button { padding: 0 6px; min-height: 22px; }

/* Результаты быстрого поиска */
.pets { list-style: none; padding: 0; margin: 4px 0 0; display: flex; flex-direction: column; gap: 2px; }
.pet { display: flex; flex-wrap: wrap; gap: 2px 14px; padding: 3px 6px; background: #eef5f1;
  text-decoration: none; color: var(--text); }
.pet.dead { background: #f1f1f1; color: var(--muted); }
.phones { margin: 0; color: var(--muted); }

/* История приёмов */
details.visit { border-top: 1px solid var(--border); padding: 4px 0; }
details.visit.new { background: #f5f9ff; }
details.visit summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 2px 14px;
  align-items: center; }
details.visit .date { font-weight: 600; min-width: 120px; }
details.visit .pet { font-weight: 600; min-width: 80px; }
details.visit .doctor { color: var(--muted); min-width: 160px; }
details.visit .body { padding: 4px 4px 4px 14px; }
.text { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Итоги счёта, отчёты, прочее */
.totals { display: grid; grid-template-columns: 1fr max-content; gap: 2px 16px; max-width: 360px;
  margin: 8px 0 10px auto; }
.totals dd { margin: 0; text-align: right; }
.totals .due { font-size: 16px; font-weight: 700; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 10px; }
.period { display: flex; gap: 6px; flex-wrap: wrap; align-items: end; }
.period label { display: flex; flex-direction: column; gap: 2px; }
.period input { width: 150px; }
.big { font-size: 16px; font-weight: 700; }
tr.done { color: var(--muted); }
form.transfer { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
form.transfer input[name=vm_id] { width: 140px; }
.row-actions form { margin: 2px; }
code.secret { font-size: 20px; background: #fff; padding: 2px 8px; border-radius: 3px; user-select: all; }

/* Форма клиента как в Vetmanager: блоки с рамкой и заголовком */
fieldset.block, section.block { border: 1px solid var(--border); border-radius: 3px;
  background: var(--card); padding: 6px 10px 10px; margin: 0; min-width: 0; }
fieldset.block legend { font-weight: 600; padding: 0 4px; }
section.block h2 { margin: 2px 0 6px; }
.client-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px;
  margin: 0 0 10px; }
.client-form fieldset.block { display: flex; flex-direction: column; gap: 6px; }
.client-form label, .block-grid label, .pet-form label { display: flex; flex-direction: column; gap: 2px; }
.client-form .wide { grid-column: 1 / -1; }
.block-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 4px 0; }
.client-form label.check, .pet-form label.check { flex-direction: row; }
label.danger { color: var(--error); font-weight: 600; }
.phone-group { display: flex; align-items: stretch; }
.phone-group .prefix { display: inline-flex; align-items: center; padding: 0 8px; background: var(--head);
  border: 1px solid var(--border); border-right: 0; border-radius: 2px 0 0 2px; }
.matches { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.match-items li { padding: 3px 6px; background: var(--warn-bg); }
.icon-save { display: inline-block; width: 14px; height: 14px; vertical-align: -2px;
  background: no-repeat center/14px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='1.6'%3E%3Cpath d='M2 2h9.5L14 4.5V14H2z'/%3E%3Cpath d='M5 2v4h5V2M5 14V9.5h6V14'/%3E%3C/svg%3E"); }

/* Добавление питомца: окно и страница */
dialog.modal { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
  border: 1px solid var(--border); border-radius: 4px; padding: 12px 14px; }
dialog.modal::backdrop { background: rgba(15, 23, 42, 0.45); }
.pet-page { max-width: 600px; }
.pet-form { display: flex; flex-direction: column; gap: 6px; }
.pet-form .row-label { display: grid; grid-template-columns: 130px 1fr; align-items: center; gap: 8px; }
.pet-form .row-label textarea { min-height: 48px; }
.with-plus { display: flex; gap: 4px; }
.with-plus button { padding: 0 10px; }
.age-block { margin: 4px 0; }
.age-grid { display: grid; grid-template-columns: repeat(4, 1fr) 1.6fr; gap: 6px; align-items: end; }
.form-buttons { justify-content: flex-end; margin: 6px 0 0; }
.note-cell { max-width: 240px; overflow-wrap: anywhere; }
table.data tr:target { background: #fff4d6; outline: 2px solid #f0c36d; }

/* Печатные формы */
.print-page main { max-width: 820px; }
.sheet { background: #fff; padding: 20px; }
.sheet h1 { font-size: 18px; text-align: center; } .sheet h2 { font-size: 16px; text-align: center; }
table.head { border-collapse: collapse; width: 100%; margin: 8px 0; }
table.head th { text-align: left; font-weight: 600; width: 45%; padding: 2px 8px 2px 0; vertical-align: top; }
table.head td { padding: 2px 0; }
.sign { margin-top: 36px; }
.sign .line { display: inline-block; width: 200px; border-bottom: 1px solid #000; margin-left: 12px; }

@media (max-width: 900px) {
  .layout, .profile, .invoice-layout, .client-form, .matches { grid-template-columns: 1fr; }
  .pet-form .row-label { grid-template-columns: 1fr; }
  .age-grid { grid-template-columns: repeat(2, 1fr); }
  .quick input { width: 160px; }
}
@media print {
  body { background: #fff; font-size: 11pt; }
  .no-print, .top, .banner { display: none !important; }
  main { padding: 0; max-width: none; }
  .sheet { padding: 0; }
  a { color: inherit; text-decoration: none; }
}
