/* ============================================================
   СтадоПро 0.2 — UI в стиле RationPro (premium agri-tech)
   Светлая: warm white / graphite / emerald / amber
   Тёмная: graphite / emerald
   ============================================================ */

:root, [data-theme="light"] {
  --sp-bg: #f5f7f3;
  --sp-card: #ffffff;
  --sp-border: #e5e9e3;
  --sp-border-strong: #cbd5c8;

  --sp-text: #17211b;
  --sp-text-soft: #354239;
  --sp-muted: #718078;
  --sp-faint: #9aa69f;

  --sp-brand: #159957;
  --sp-brand-dark: #0f7a43;
  --sp-brand-light: #55c982;

  --sp-sidebar-bg: linear-gradient(180deg, #14241d 0%, #102019 55%, #0d1914 100%);
  --sp-sidebar-border: rgba(255,255,255,.075);
  --sp-sidebar-active: linear-gradient(135deg, rgba(21,153,87,.95), rgba(10,112,62,.92));
  --sp-sidebar-active-glow: rgba(21,153,87,.28);

  --sp-header-bg: rgba(255,255,255,.82);
  --sp-header-shadow: 0 1px 0 rgba(23,33,27,.05), 0 8px 30px rgba(23,33,27,.035);

  --sp-ok: #159957; --sp-ok-soft: #55c982;
  --sp-warn: #d99018; --sp-warn-deep: #b86f08; --sp-warn-soft: #f3c766;
  --sp-crit: #d94b4b; --sp-crit-soft: #ef7d7d;
  --sp-info: #73817a;
  --sp-teal: #2ca9a1;
  --sp-violet: #8064c7;

  --sp-chart-1: #159957; --sp-chart-2: #3478c8; --sp-chart-3: #d99018;
  --sp-chart-4: #8064c7; --sp-chart-5: #2ca9a1; --sp-chart-6: #d8649a;
  --sp-chart-7: #73a83b; --sp-chart-8: #d86b35; --sp-chart-9: #73817a;
  --sp-chart-10: #299b82;

  --sp-chart-text: #354239;
  --sp-chart-axis: #718078;
  --sp-chart-grid: #edf0ec;
  --sp-chart-tooltip-bg: rgba(255,255,255,.97);
  --sp-chart-tooltip-border: #dfe5df;

  --sp-accent-gradient: linear-gradient(100deg, #159957, #55c982);
  --sp-hero-bg:
    radial-gradient(circle at 80% 15%, rgba(85,201,130,.26), transparent 34%),
    radial-gradient(circle at 95% 95%, rgba(217,144,24,.16), transparent 28%),
    linear-gradient(120deg, #10241a 0%, #163e2a 55%, #0d2118 100%);
  --sp-login-bg: radial-gradient(900px 520px at 10% 0%, rgba(21,153,87,.18), transparent 60%),
    radial-gradient(800px 500px at 100% 100%, rgba(217,144,24,.10), transparent 60%), #f5f7f3;

  --sp-radius: 18px;
  --sp-radius-sm: 11px;
  --sp-font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --sp-shadow: 0 1px 2px rgba(23,33,27,.035), 0 8px 26px rgba(23,33,27,.055);
  --sp-shadow-hover: 0 2px 4px rgba(23,33,27,.05), 0 16px 40px rgba(23,33,27,.10);
}

[data-theme="dark"] {
  --sp-bg: #0d1411;
  --sp-card: #151f1a;
  --sp-border: #29362f;
  --sp-border-strong: #3a4941;
  --sp-text: #edf4ef;
  --sp-text-soft: #c8d4cc;
  --sp-muted: #91a097;
  --sp-faint: #65746b;

  --sp-brand: #39c878;
  --sp-brand-dark: #20a960;
  --sp-brand-light: #70e09c;

  --sp-sidebar-bg: linear-gradient(180deg, #0b120e, #0d1712 55%, #09100c);
  --sp-sidebar-border: rgba(255,255,255,.06);
  --sp-sidebar-active: linear-gradient(135deg, rgba(35,176,101,.9), rgba(18,119,69,.9));
  --sp-sidebar-active-glow: rgba(35,176,101,.22);
  --sp-header-bg: rgba(13,20,17,.82);
  --sp-header-shadow: 0 1px 0 rgba(255,255,255,.035), 0 10px 30px rgba(0,0,0,.22);

  --sp-ok: #39c878; --sp-ok-soft: #70e09c;
  --sp-warn: #e7ad42; --sp-warn-deep: #f0b64e; --sp-warn-soft: #f6d27e;
  --sp-crit: #f07171; --sp-crit-soft: #f69a9a;
  --sp-info: #7e8c84;

  --sp-chart-text: #c8d4cc; --sp-chart-axis: #91a097; --sp-chart-grid: #29362f;
  --sp-chart-tooltip-bg: rgba(18,28,23,.98); --sp-chart-tooltip-border: #3a4941;
  --sp-hero-bg:
    radial-gradient(circle at 80% 15%, rgba(85,201,130,.18), transparent 34%),
    linear-gradient(120deg, #0c1c14 0%, #122e1f 55%, #0a1a12 100%);
  --sp-login-bg: radial-gradient(900px 520px at 10% 0%, rgba(21,153,87,.18), transparent 60%),
    radial-gradient(800px 500px at 100% 100%, rgba(217,144,24,.08), transparent 60%), #0d1411;
  --sp-shadow: 0 1px 2px rgba(0,0,0,.35), 0 10px 30px rgba(0,0,0,.24);
  --sp-shadow-hover: 0 3px 6px rgba(0,0,0,.36), 0 18px 42px rgba(0,0,0,.34);
}

* { box-sizing: border-box; }
html { background: var(--sp-bg); }
body {
  margin: 0;
  background:
    radial-gradient(circle at 85% -10%, rgba(21,153,87,.035), transparent 30%),
    var(--sp-bg);
  font-family: var(--sp-font);
  color: var(--sp-text);
  -webkit-font-smoothing: antialiased;
  color-scheme: light;
}
[data-theme="dark"] body { color-scheme: dark; }

.ant-layout { background: transparent !important; }

/* ---------- SIDEBAR ---------- */
.ant-layout-sider { box-shadow: 8px 0 30px rgba(0,0,0,.055); z-index: 10; }
.ant-layout-sider .ant-layout-sider-children { background: var(--sp-sidebar-bg); }
.logo {
  height: 76px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 17px;
  border-bottom: 1px solid var(--sp-sidebar-border);
}
.sp-brand-mark {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 20px;
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,.30), transparent 28%),
    linear-gradient(135deg, #55c982, #159957 58%, #0d7542);
  box-shadow: 0 10px 24px rgba(21,153,87,.26);
}
.sp-logo-copy { display: flex; flex-direction: column; min-width: 0; }
.sp-logo-copy b {
  font-size: 18px; line-height: 1.05; letter-spacing: -.5px; color: #fff;
}
.sp-logo-copy small {
  display: block; margin-top: 5px;
  color: rgba(255,255,255,.42);
  font-size: 8px; letter-spacing: 1.35px; font-weight: 800;
}
.ant-layout-sider .ant-menu-dark { background: transparent; padding: 14px 10px; }
.ant-layout-sider .ant-menu-dark .ant-menu-item {
  height: 44px; line-height: 44px; margin: 4px 0;
  border-radius: 12px;
  color: rgba(255,255,255,.64);
  font-weight: 550;
  transition: all .18s ease;
}
.ant-layout-sider .ant-menu-dark .ant-menu-item:hover {
  color: #fff; background: rgba(255,255,255,.055);
}
.ant-layout-sider .ant-menu-dark .ant-menu-item-selected {
  background: var(--sp-sidebar-active) !important;
  box-shadow: 0 8px 22px var(--sp-sidebar-active-glow);
  color: #fff !important;
}
.ant-layout-sider .ant-menu-dark .ant-menu-item-selected::after { display: none; }
.sp-side-footer {
  margin: 10px; padding: 13px;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 13px;
  color: rgba(255,255,255,.45);
  font-size: 9px; line-height: 1.55;
  text-transform: uppercase; letter-spacing: .7px;
}
.sp-side-footer strong {
  display: block;
  color: rgba(255,255,255,.78);
  letter-spacing: .2px; text-transform: none;
  font-size: 11px; margin-bottom: 3px;
}

/* ---------- HEADER ---------- */
.ant-layout-header {
  background: var(--sp-header-bg) !important;
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--sp-border) !important;
  box-shadow: var(--sp-header-shadow);
  position: sticky; top: 0; z-index: 9;
}

/* ---------- CONTENT / PAGE ---------- */
.ant-layout-content { padding-top: 24px !important; padding-bottom: 36px !important; }
.page-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.page-title {
  font-size: 27px; line-height: 1.15; font-weight: 800; letter-spacing: -.8px;
}
.row-note { color: var(--sp-muted); font-size: 12px; }
.muted { color: var(--sp-faint); }
/* отменённые записи (Э13: отгрузка молока — гасится, не удаляется) */
tr.row-muted > td { opacity: .45; text-decoration: line-through; }
tr.row-muted > td .ant-tag { text-decoration: none; }

/* ---------- KPI ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.kpi-card {
  min-height: 104px;
  background: var(--sp-card);
  border-radius: var(--sp-radius);
  padding: 15px 17px;
  box-shadow: var(--sp-shadow);
  border: 1px solid var(--sp-border);
  position: relative; overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.kpi-card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--sp-info);
}
.kpi-card.ok::before { background: var(--sp-ok); }
.kpi-card.warn::before { background: var(--sp-warn); }
.kpi-card.crit::before { background: var(--sp-crit); }
.kpi-card.teal::before { background: var(--sp-teal); }
.kpi-card.violet::before { background: var(--sp-violet); }
.kpi-card.blue::before { background: var(--sp-chart-2); }
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--sp-shadow-hover); }
.kpi-title {
  font-size: 10px; color: var(--sp-muted);
  font-weight: 750; text-transform: uppercase; letter-spacing: .8px;
}
.kpi-value {
  margin-top: 5px; font-size: 26px; font-weight: 800; line-height: 1.2;
  font-variant-numeric: tabular-nums; letter-spacing: -.5px;
}
.kpi-value small { font-size: 13px; font-weight: 600; color: var(--sp-muted); }
.kpi-sub { font-size: 11px; color: var(--sp-faint); margin-top: 4px; }

/* ---------- WIDGETS (настраиваемый дашборд) ---------- */
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.widget {
  background: var(--sp-card);
  border-radius: var(--sp-radius);
  padding: 14px 16px 16px;
  box-shadow: var(--sp-shadow);
  border: 1px solid var(--sp-border);
  transition: box-shadow .2s ease, transform .2s ease;
  position: relative;
  min-width: 0;
}
.widget:hover { box-shadow: var(--sp-shadow-hover); }
.widget.w-full { grid-column: 1 / -1; }
.widget-title {
  font-weight: 750; font-size: 14px; letter-spacing: -.1px;
  display: flex; align-items: center; gap: 8px;
  margin: 4px 4px 2px; min-height: 26px;
}
.widget-title .sp-ico {
  width: 26px; height: 26px; border-radius: 8px;
  display: grid; place-items: center; font-size: 14px;
  background: var(--sp-thi-gradient, linear-gradient(135deg, #f1f8f3, #f8faf6 60%, #fff8e9));
}
.widget-title::after {
  content: ""; display: block; position: absolute;
}
.widget-title .t-line {
  display: block; width: 28px; height: 3px; border-radius: 10px;
  background: var(--sp-accent-gradient); margin-left: auto;
}
.widget-body { margin-top: 10px; min-height: 40px; }
.widget-foot {
  margin-top: 10px; padding-top: 8px;
  border-top: 1px dashed var(--sp-border);
  color: var(--sp-faint); font-size: 11px;
  display: flex; gap: 10px; align-items: center;
}
/* режим настройки: рамки и кнопки управления */
.widget.editing { border-style: dashed; border-color: var(--sp-brand); cursor: grab; }
.widget.editing:hover { transform: translateY(-2px); }
.widget-controls {
  position: absolute; top: 10px; right: 10px; z-index: 3;
  display: none; gap: 4px;
}
.widget.editing .widget-controls { display: flex; }
.widget-controls .ant-btn { border-radius: 8px; }
.dash-add-tile {
  border: 2px dashed var(--sp-border-strong);
  border-radius: var(--sp-radius);
  min-height: 120px;
  display: grid; place-items: center;
  color: var(--sp-muted); font-weight: 600;
  cursor: pointer; background: transparent;
  transition: all .18s ease;
  grid-column: span 1;
}
.dash-add-tile:hover { border-color: var(--sp-brand); color: var(--sp-brand); background: rgba(21,153,87,.04); }

/* каталог виджетов */
.wcat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.wcat-card {
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius-sm);
  padding: 14px;
  display: flex; flex-direction: column; gap: 6px;
  background: var(--sp-card);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.wcat-card:hover { border-color: var(--sp-brand); box-shadow: var(--sp-shadow); }
.wcat-card .wc-ico {
  width: 36px; height: 36px; border-radius: 11px;
  display: grid; place-items: center; font-size: 18px;
}
.wcat-card b { font-size: 13.5px; }
.wcat-card span { font-size: 11.5px; color: var(--sp-muted); line-height: 1.45; flex: 1; }

/* ---------- HERO (шапка «Сегодня») ---------- */
.sp-hero {
  min-height: 132px;
  display: grid; grid-template-columns: 1.55fr .9fr;
  gap: 20px; align-items: center;
  padding: 24px 26px; margin-bottom: 18px;
  border-radius: 22px;
  color: #fff; position: relative; overflow: hidden;
  background: var(--sp-hero-bg);
  box-shadow: 0 18px 48px rgba(13,55,35,.18);
}
.sp-hero::before, .sp-hero::after {
  content: ""; position: absolute;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 50%; pointer-events: none;
}
.sp-hero::before { width: 340px; height: 340px; right: -120px; top: -210px; }
.sp-hero::after { width: 200px; height: 200px; right: 120px; bottom: -150px; }
.sp-hero-copy { position: relative; z-index: 1; }
.sp-eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px;
  font-weight: 800; opacity: .58; margin-bottom: 8px;
}
.sp-hero-title { font-size: 27px; line-height: 1.08; font-weight: 850; letter-spacing: -1px; }
.sp-hero-subtitle {
  margin-top: 8px; max-width: 640px;
  color: rgba(255,255,255,.68); font-size: 13px; line-height: 1.55;
}
.sp-hero-actions {
  position: relative; z-index: 1;
  display: flex; justify-content: flex-end; gap: 9px; flex-wrap: wrap;
}
.sp-hero-actions .ant-btn {
  height: 40px; padding: 0 15px; border-radius: 12px;
  border-color: rgba(255,255,255,.18);
  background: rgba(255,255,255,.08);
  color: #fff; backdrop-filter: blur(8px);
}
.sp-hero-actions .ant-btn-primary {
  background: #fff; color: #12633e; border-color: #fff;
  box-shadow: 0 9px 25px rgba(0,0,0,.16);
}

/* ---------- ЛЕНТА СОБЫТИЙ ---------- */
.feed-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 2px; border-bottom: 1px solid var(--sp-border);
}
.feed-item:last-child { border-bottom: 0; }
.feed-ico {
  width: 32px; height: 32px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-size: 15px;
  background: var(--sp-bg); border: 1px solid var(--sp-border);
}
.feed-text { font-size: 13px; line-height: 1.4; min-width: 0; }
.feed-text b { font-weight: 650; }
.feed-meta { margin-left: auto; flex: none; font-size: 11.5px; color: var(--sp-faint); text-align: right; white-space: nowrap; }

/* ---------- ТАБЛИЦЫ / AntD polish ---------- */
.ant-card {
  border-radius: var(--sp-radius) !important;
  box-shadow: var(--sp-shadow) !important;
  border-color: var(--sp-border) !important;
}
.ant-btn { border-radius: 10px; font-weight: 600; box-shadow: none; }
.ant-btn-primary { box-shadow: 0 6px 16px rgba(21,153,87,.20); }
.ant-input, .ant-input-affix-wrapper, .ant-select-selector,
.ant-picker, .ant-input-number, .ant-input-number-input { border-radius: 10px !important; }
.ant-input:focus, .ant-input-affix-wrapper-focused,
.ant-select-focused .ant-select-selector {
  box-shadow: 0 0 0 3px rgba(21,153,87,.10) !important;
}
.ant-tag { border-radius: 999px; font-weight: 600; }
.ant-alert { border-radius: 13px; }
.ant-modal .ant-modal-content { border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.18); }

/* Все Drawer'ы — по центру экрана, как модальное окно редактирования */
.ant-drawer .ant-drawer-content-wrapper {
  top: 50% !important; left: 50% !important; right: auto !important; bottom: auto !important;
  transform: translate(-50%, -50%) !important;
  width: 70vw !important; min-width: auto; max-width: 92vw;
  height: auto !important; max-height: 88vh;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
  overflow: hidden;
}
.ant-drawer .ant-drawer-content { border-radius: 18px; height: auto; max-height: 88vh; display: flex; flex-direction: column; animation: sp-drawer-fade .2s ease; }
.ant-drawer .ant-drawer-header { padding: 18px 32px; }
.ant-drawer .ant-drawer-body { padding: 24px 32px; overflow: auto; }
@keyframes sp-drawer-fade { from { opacity: 0; } to { opacity: 1; } }

/* Карточка животного: события — правая колонка (1/3 ширины), видна сразу,
   без прокрутки всей карточки; на узких экранах — обратно в одну колонку */
.acard-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 0 26px; align-items: start; }
.acard-right {
  position: sticky; top: 0;
  max-height: calc(88vh - 118px);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 2px 4px 14px 18px;
  border-left: 1px solid var(--sp-border, rgba(0,0,0,.08));
}
.acard-right::-webkit-scrollbar { width: 5px }
.acard-right::-webkit-scrollbar-thumb { border-radius: 4px; background: var(--sp-muted, #bbb) }
@media (max-width: 900px) {
  .acard-grid { grid-template-columns: 1fr }
  .acard-right { position: static; max-height: none; border-left: 0; padding-left: 4px }
}
.ant-dropdown-menu, .ant-select-dropdown { border-radius: 12px !important; padding: 6px !important; }
.ant-dropdown-menu-item, .ant-select-item { border-radius: 8px !important; }
.ant-table-wrapper { border-radius: var(--sp-radius); overflow: hidden; }
.ant-table { background: var(--sp-card) !important; }
.ant-table-thead > tr > th {
  background: var(--sp-bg) !important;
  color: var(--sp-text-soft) !important;
  font-size: 12px; font-weight: 700; letter-spacing: .2px;
  border-bottom: 2px solid var(--sp-border-strong) !important;
}
.ant-table-tbody > tr > td {
  border-bottom-color: var(--sp-border) !important;
  padding-top: 12px !important; padding-bottom: 12px !important;
}
.ant-table-tbody > tr:hover > td { background: rgba(21,153,87,.035) !important; }
.ant-table-row { cursor: pointer; }
.ant-descriptions-item-label { color: var(--sp-muted) !important; }

/* chips-фильтр по состояниям */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  height: 30px; display: inline-flex; align-items: center; gap: 6px;
  padding: 0 13px; border-radius: 15px;
  border: 1px solid var(--sp-border-strong);
  background: var(--sp-card);
  font-size: 12.5px; color: var(--sp-text-soft);
  cursor: pointer; white-space: nowrap;
  transition: all .15s ease;
}
.chip:hover { border-color: var(--sp-brand); color: var(--sp-brand); }
.chip.active {
  background: rgba(21,153,87,.10); border-color: var(--sp-brand);
  color: var(--sp-brand-dark); font-weight: 650;
}
.chip b { font-weight: 600; color: var(--sp-muted); }
.chip.active b { color: var(--sp-brand-dark); }

/* группы кормления */
.grp-row { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--sp-border); }
.grp-row:last-child { border-bottom: 0; }
.grp-name { font-size: 13px; font-weight: 600; min-width: 0; }
.grp-key { font-size: 10.5px; color: var(--sp-faint); font-family: ui-monospace, Consolas, monospace; }
.grp-bar { flex: 1; height: 8px; border-radius: 8px; background: var(--sp-bg); overflow: hidden; min-width: 60px; }
.grp-bar i { display: block; height: 100%; border-radius: 8px; background: var(--sp-accent-gradient); }
.grp-head { font-size: 15px; font-weight: 750; font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }

/* ---------- КАЛЕНДАРЬ МЕСЯЦА (Э9) ---------- */
/* minmax(0,1fr): без нулевого минимума nowrap-тексты чипов распирают треки
   (1fr = minmax(auto,1fr)) и сетка вылезает за ширину экрана */
.cal-grid {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px;
}
.cal-weekday {
  text-align: center; font-size: 11px; font-weight: 700; letter-spacing: .4px;
  text-transform: uppercase; color: var(--sp-faint); padding: 4px 0 6px;
}
.cal-cell {
  min-width: 0;
  min-height: 92px; border: 1px solid var(--sp-border); border-radius: var(--sp-radius-sm);
  background: var(--sp-card); padding: 6px 7px; display: flex; flex-direction: column; gap: 4px;
  cursor: default;
}
.cal-cell.empty { border-color: transparent; background: transparent; }
.cal-cell.has { cursor: pointer; }
.cal-cell.has:hover { border-color: var(--sp-border-strong); box-shadow: var(--sp-shadow); }
.cal-cell.today { border-color: var(--sp-brand); box-shadow: 0 0 0 1px var(--sp-brand) inset; }
.cal-daynum { font-size: 12px; font-weight: 700; color: var(--sp-muted);
  font-variant-numeric: tabular-nums; }
.cal-cell.today .cal-daynum { color: var(--sp-brand-dark); }
.cal-chip {
  display: flex; align-items: center; gap: 4px; min-width: 0;
  font-size: 10.5px; font-weight: 600; line-height: 1.25;
  padding: 2px 6px; border-radius: 7px;
  background: var(--sp-bg); border: 1px solid transparent;
  color: var(--sp-text-soft); cursor: pointer;
}
.cal-chip:hover { border-color: var(--sp-border-strong); }
.cal-chip-ico { flex: none; font-size: 11px; }
.cal-chip-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-chip.ok { color: var(--sp-ok); }
.cal-chip.warn { color: var(--sp-warn-deep); }
.cal-chip.info { color: var(--sp-text-soft); }
.cal-chip.violet { color: var(--sp-violet); }
.cal-chip.teal { color: var(--sp-teal); }
.cal-chip.overdue { color: var(--sp-crit); border-color: var(--sp-crit-soft); }
.cal-more { font-size: 10px; color: var(--sp-faint); font-weight: 650; }
.cal-cnt { flex: none; font-variant-numeric: tabular-nums; color: var(--sp-muted); font-weight: 700; }
/* режим «Неделя»: 7 высоких колонок с группировкой по типу */
.cal-week .cal-cell { min-height: 170px; }
/* группы записей (панель дня и режим «День») */
.cal-dgroup { margin-bottom: 12px; }
.cal-ghead {
  display: flex; align-items: center; gap: 6px; padding: 4px 8px; margin-bottom: 2px;
  border-radius: 8px; background: var(--sp-bg);
  font-size: 12px; font-weight: 700; text-transform: lowercase;
}
.cal-ghead.ok { color: var(--sp-ok); }
.cal-ghead.warn { color: var(--sp-warn-deep); }
.cal-ghead.info { color: var(--sp-text-soft); }
.cal-ghead.violet { color: var(--sp-violet); }
.cal-ghead.teal { color: var(--sp-teal); }
@media (max-width: 900px) {
  .cal-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .cal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cal-cell { min-height: 64px; }
  /* неделя/день на телефоне остаются одной строкой из 7/1 колонок */
  .cal-week.cal-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}

/* ---------- РОДОСЛОВНАЯ (Э9) ---------- */
.ped-tree { display: flex; gap: 10px; align-items: stretch; }
.ped-col { flex: 1; display: flex; flex-direction: column; gap: 6px; justify-content: center; }
.ped-node {
  border: 1px solid var(--sp-border); border-radius: var(--sp-radius-sm);
  background: var(--sp-card); padding: 6px 9px; font-size: 12px;
}
.ped-node.empty { border-style: dashed; opacity: .45; }
.ped-node.dim { background: transparent; }
.ped-num { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ped-num a { color: var(--sp-brand-dark); }
.ped-sub { font-size: 10.5px; color: var(--sp-faint); margin-top: 1px; }
@media (max-width: 620px) {
  .ped-tree { flex-direction: column; }
  .ped-col { flex-direction: row; flex-wrap: wrap; }
  .ped-col .ped-node { flex: 1 1 40%; }
}

/* пустые состояния */
.sp-empty {
  padding: 44px 20px; text-align: center;
  border: 1px dashed var(--sp-border-strong);
  border-radius: 18px; background: var(--sp-card);
}
.sp-empty-icon {
  width: 52px; height: 52px; margin: 0 auto 12px;
  display: grid; place-items: center;
  border-radius: 16px; font-size: 23px;
  background: linear-gradient(135deg, #f1f8f3, #f8faf6 60%, #fff8e9);
  color: var(--sp-brand);
}
.sp-empty p { color: var(--sp-muted); font-size: 13px; }

/* карточка животного: события */
.ev-item { display: flex; gap: 11px; padding: 9px 0; border-bottom: 1px solid var(--sp-border); }
.ev-item:last-child { border-bottom: 0; }
.ev-date { font-size: 11px; color: var(--sp-faint); white-space: nowrap; min-width: 58px; padding-top: 2px; }

/* фото животного: карточка + миниатюра в ленте событий */
.animal-photo {
  width: 100%; max-height: 280px; object-fit: cover;
  border-radius: 14px; margin-bottom: 12px;
  border: 1px solid var(--sp-border);
}
.animal-photo.empty {
  height: 120px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 6px; font-size: 30px; color: var(--sp-muted);
  background: var(--sp-bg);
}
.animal-photo.empty span { font-size: 12px; }
.ev-thumb {
  display: block; width: 148px; height: 96px; object-fit: cover;
  border-radius: 10px; margin-top: 6px; border: 1px solid var(--sp-border);
}

/* ---------- Э12: цели KPI, онбординг, журнал показателей, импорт ---------- */
.goal-row {
  display: flex; align-items: center; gap: 12px; padding: 8px 0;
  border-bottom: 1px solid var(--sp-border);
}
.goal-row:last-child { border-bottom: 0; }
.goal-bar {
  flex: 1; max-width: 220px; height: 8px; border-radius: 6px;
  background: var(--sp-bg); overflow: hidden;
}
.goal-bar i { display: block; height: 100%; border-radius: 6px; transition: width .4s; }

.onb-card { border: 1px solid color-mix(in srgb, var(--sp-brand) 35%, var(--sp-border)); }
.onb-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.onb-step {
  display: flex; gap: 10px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--sp-border); background: var(--sp-bg); font-size: 12.5px;
}
.onb-step small { display: block; color: var(--sp-muted); font-size: 11px; }
.onb-step.done { opacity: .55; }
.onb-check {
  width: 20px; height: 20px; flex: 0 0 20px; border-radius: 50%;
  border: 1.6px solid var(--sp-border-strong); display: flex;
  align-items: center; justify-content: center; font-size: 12px; color: var(--sp-ok);
}
.onb-step.done .onb-check { border-color: var(--sp-ok); background: color-mix(in srgb, var(--sp-ok) 14%, transparent); }

.mj-cell { cursor: pointer; padding: 2px 6px; border-radius: 6px; display: inline-block; min-width: 34px; }
.mj-cell:hover { background: var(--sp-bg); }
.mj-today { color: var(--sp-brand); font-weight: 800; margin-left: 3px; }

.day-form { display: flex; flex-direction: column; gap: 10px; max-height: 60vh; overflow-y: auto; }
.day-form-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }

.imp-map-row { display: flex; align-items: center; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--sp-border); }
.imp-map-row:last-child { border-bottom: 0; }

@media (max-width: 1100px) { .onb-grid { grid-template-columns: 1fr; } }

/* ---------- SCROLLBAR ---------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--sp-border-strong);
  border-radius: 20px; border: 2px solid var(--sp-bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--sp-muted); }

/* ---------- LOGIN ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--sp-login-bg);
}
.login-card {
  width: 370px; padding: 32px; border-radius: 20px;
  background: var(--sp-card);
  border: 1px solid var(--sp-border);
  box-shadow: 0 24px 70px rgba(23,33,27,.12);
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }
@media (max-width: 700px) {
  .ant-layout-content { padding: 16px !important; }
  .page-title { font-size: 22px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi-card { min-height: 92px; padding: 12px; }
  .kpi-value { font-size: 21px; }
  .sp-hero { padding: 20px; border-radius: 18px; grid-template-columns: 1fr; }
  .sp-hero-title { font-size: 22px; }
  .sp-hero-actions { justify-content: flex-start; }
}
@media (max-width: 460px) { .kpi-grid { grid-template-columns: 1fr; } }
