* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 1080px !important;
  background: #f6f7f9 !important;
  color: #1f2933;
  font-family: "Segoe UI", Arial, sans-serif;
}

button, input, select, textarea { font: inherit; }
button { letter-spacing: 0; }

.c57-header-inner { max-width: 1480px; }
.module-tabs { display: flex; align-items: center; gap: 8px; }
.module-tabs .nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: #607080;
  font-weight: 800;
  text-decoration: none;
}

.c57-shell { width: 100%; max-width: none !important; padding: 0 !important; }
.page-wrap { max-width: 1480px; margin: 0 auto; padding: 18px 18px 36px; }
.cage-board-wrap { max-width: 1880px !important; width: calc(100% - 32px) !important; padding: 18px 8px 36px !important; }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.btn, .command-button {
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid #d2dcda;
  border-radius: 7px;
  background: #fff;
  color: #1f2933;
  font-weight: 750;
  cursor: pointer;
}
.btn:hover, .command-button:hover { border-color: #9fb4af; background: #f7faf9; }
.btn-success { color: #fff; background: #2f8f7b; border-color: #2f8f7b; }
.btn-success:hover { color: #fff; background: #237361; }
.btn-danger { color: #91352f; background: #fae8e7; border-color: rgba(189,75,69,.34); }
.btn-secondary { background: #eef2f5; }

.panel {
  background: #fff;
  border: 1px solid #dfe5ec;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(31,41,51,.04);
}
.panel-title { margin: 0 0 12px; color: #1f2d3d; font-size: 1.02rem; font-weight: 800; }
.empty-state { color: #71808c; padding: 14px 4px; }

.dashboard-overview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 12px;
  align-items: stretch;
  margin: 14px 0 18px;
}
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; margin: 0; }
.summary-warning-row { grid-template-columns: repeat(2, minmax(240px, 1fr)); margin-top: 12px; }
.summary-tile {
  min-height: 112px;
  padding: 16px 18px;
  border: 1px solid #dfe5ec;
  border-left: 4px solid #607d8b;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(31,41,51,.05);
}
.summary-tile.success { border-left-color: #2f8f7b; }
.summary-tile.info { border-left-color: #3d7ebd; }
.summary-tile.warning { border-left-color: #b97818; }
.summary-tile.danger { border-left-color: #bd4b45; }
.summary-title { display: block; color: #52616f; font-size: .85rem; font-weight: 750; line-height: 1.2; }
.summary-value { display: block; margin-top: 14px; color: #102a43; font-size: 2rem; line-height: 1; }
.cage-preview-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 14px;
  border: 1px solid #dfe5ec;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(31,41,51,.04);
}
.cage-preview { display: grid; gap: 9px; }
.cage-preview-m-grid { display: grid; grid-template-columns: repeat(7, 16px); gap: 5px; justify-content: center; }
.cage-preview-p-grid { display: grid; grid-template-columns: repeat(6, 16px); gap: 5px; }
.cage-preview-cell { width: 16px; height: 16px; border-radius: 5px; border: 1px solid rgba(31,45,61,.08); }
.cage-preview-cell.inactive, .cage-preview-cell.m-0 { background: #e8edf2; }
.cage-preview-cell.m-1 { background: #bfe8cf; }
.cage-preview-cell.m-2 { background: #34a853; }
.cage-preview-cell.p-pending { background: #ffe173; }
.cage-preview-cell.p-overdue { background: #ef4b4b; }
.cage-preview-cell.p-produced-0 { background: #e3f3e7; }
.cage-preview-cell.p-produced-1, .cage-preview-cell.p-produced-2 { background: #c9e9d0; }
.cage-preview-cell.p-produced-3, .cage-preview-cell.p-produced-4 { background: #9bd7a8; }
.cage-preview-cell.p-produced-5, .cage-preview-cell.p-produced-6 { background: #68bd79; }
.cage-preview-cell.p-produced-7, .cage-preview-cell.p-produced-8 { background: #34a853; }
.cage-preview-cell.p-produced-9, .cage-preview-cell.p-produced-10 { background: #176b32; }

.alert-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.alert-item { padding: 9px 11px; border-left: 4px solid #607d8b; border-radius: 7px; background: #f3f6f8; }
.alert-item.warning, .alert-item.info { background: #fff8e8; border-left-color: #b97818; }
.alert-item.danger { background: #fae8e7; border-left-color: #bd4b45; }

.board-grid { display: grid; grid-template-columns: minmax(320px,.78fr) minmax(620px,1.42fr); gap: 10px; align-items: start; }
.board-grid .panel { padding: 10px; }
.cage-section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cage-section-title .panel-title { margin: 0; }
.cage-add-btn {
  width: 30px; height: 30px; padding: 0; border: 1px solid #b9c9d5; border-radius: 7px;
  background: #fff; color: #17324d; font-size: 1.05rem; font-weight: 900; cursor: pointer;
}
.cage-add-btn:hover { background: #e7f1fb; border-color: #3d7ebd; }
.cage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 8px; }
.cage-card {
  min-height: 108px;
  padding: 7px;
  background: #fff;
  border: 1px solid #d9e1ea !important;
  border-left: 4px solid #607d8b !important;
  border-radius: 8px !important;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.cage-card.m { border-left-color: #3d7ebd !important; }
.cage-card.p { border-left-color: #2f8f7b !important; }
.cage-card.inactive { opacity: .58; background: #f0f2f4; }
.cage-card.drag-over { border-color: #3a86ff !important; box-shadow: 0 0 0 3px rgba(58,134,255,.18); transform: translateY(-1px); }
.cage-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.cage-title { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.cage-id { color: #102a43; font-size: 1rem; font-weight: 850; }
.cage-meta { margin: 3px 0 4px; color: #52616f; font-size: .66rem !important; line-height: 1.18 !important; }
.capacity-dots { display: inline-flex; align-items: center; gap: 4px; }
.capacity-dot { width: 8px; height: 8px; border: 1.5px solid #22577a; border-radius: 50%; background: transparent; }
.capacity-dot.filled { background: #22577a; }
.p-family-dots { display: flex; align-items: center; gap: 3px; min-height: 14px; margin: 4px 0 5px; overflow: hidden; white-space: nowrap; }
.mother-dot { width: 10px; height: 10px; border-radius: 50%; background: #2a9d8f; flex: 0 0 auto; }
.newborn-dot { width: 5px; height: 5px; border-radius: 50%; background: #697986; flex: 0 0 auto; }
.female-list { display: grid; gap: 4px; }
.female-card {
  position: relative; padding: 5px 28px 5px 6px !important; border: 1px solid #d7e0ea; border-radius: 7px !important;
  background: #f9fbfd !important; cursor: grab; user-select: none; box-shadow: none !important;
}
.female-card.has-footer-badge, .female-card.has-right-footer-badge, .female-card.has-bad-mother { padding-bottom: 22px !important; }
.female-card.status-need-pregnancy-check,
.female-card.status-need-production-check,
.female-card.status-weaning-soon,
.female-card.status-due-today { background: #fff1a8 !important; border-color: #e4bd3d !important; }
.female-card.status-overdue-weaning { background: #ffdada !important; border-color: #e26b73 !important; }
.female-card:focus-visible { outline: 2px solid #3d7ebd; outline-offset: 1px; }
.female-ear { display: block; color: #102a43; font-size: .86rem; font-weight: 850; }
.female-detail { display: block; margin-top: 1px; color: #52616f; font-size: .66rem !important; line-height: 1.18 !important; }
.mating-times-badge { position: absolute; top: 5px; right: 5px; min-width: 18px; height: 18px; padding: 0 5px; border: 1px solid #cbd5df; border-radius: 999px; background: #eef2f5; color: #354657; font-size: .66rem; font-weight: 850; line-height: 17px; text-align: center; }
.production-badge { position: absolute; left: 5px; bottom: 4px; padding: 1px 5px; border-radius: 999px; font-size: .62rem; font-weight: 900; line-height: 1.15; }
.production-badge.produced { background: #dff5ef; border: 1px solid #afded4; color: #0f5c53; }
.production-badge.not-produced { background: #fff3cd; border: 1px solid #f0d999; color: #7a4d00; }
.right-footer-badges { position: absolute; right: 5px; bottom: 4px; display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.bad-mother-badge, .mating-days-badge { padding: 1px 5px; border-radius: 999px; font-size: .62rem; font-weight: 900; line-height: 1.15; }
.bad-mother-badge { background: #f8e6e8; border: 1px solid #e2b5bc; color: #7f1d1d; }
.mating-days-badge { background: #eef2f5; border: 1px solid #cbd5df; color: #354657; }
.mating-days-badge.over-30 { background: rgba(178,58,72,.18); border-color: rgba(178,58,72,.34); color: #7f1d1d; }
.status-badge { display: inline-flex; align-items: center; padding: 2px 6px; border: 1px solid transparent; border-radius: 999px; font-size: .66rem; font-weight: 800; line-height: 1.2; }
.status-badge.success { background: #dff5ef; color: #0f5c53; border-color: #afded4; }
.status-badge.muted { background: #eceff2; color: #5d6770; }
.cage-status-toggle { cursor: pointer; }
.warning-line { margin-top: 5px; color: #8a1f2c; font-size: .7rem; font-weight: 750; }
.inactive-cage-panel { margin-top: 12px; }

.app-dialog {
  width: min(620px, calc(100vw - 48px)); max-height: calc(100vh - 60px); padding: 0;
  border: 1px solid #d2dcda; border-radius: 8px; background: #fff; color: #1f2933;
  box-shadow: 0 24px 70px rgba(31,41,51,.25);
}
.compact-dialog { width: 480px; }
.app-dialog::backdrop { background: rgba(31,41,51,.35); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 18px; border-bottom: 1px solid #e3e8e6; }
.dialog-header h2 { margin: 0; font-size: 1.08rem; }
.dialog-body { padding: 18px; overflow-y: auto; }
.dialog-footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 13px 18px; border-top: 1px solid #e3e8e6; }
.split-footer .footer-spacer { flex: 1; }
.icon-button { width: 30px; height: 30px; padding: 0; border: 0; background: transparent; color: #607080; font-size: 1.5rem; line-height: 1; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 13px; }
.form-grid label, .dialog-body > label, .type-fields label, .add-fields label { display: grid; gap: 5px; color: #52616f; font-size: .78rem; font-weight: 750; }
.form-grid input, .form-grid select, .form-grid textarea, .dialog-body > label input {
  width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid #cfd9df; border-radius: 6px; background: #fff; color: #1f2933; font-weight: 500;
}
.form-grid textarea { resize: vertical; }
.form-span { grid-column: 1 / -1; }
.type-fields, .add-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 13px; }
.modal-warning { padding: 12px; border: 1px solid rgba(185,120,24,.3); border-radius: 7px; background: #fff4df; color: #76500f; font-weight: 750; }
.segmented { display: flex; gap: 0; }
.segmented label { display: block; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 8px 14px; border: 1px solid #cfd9df; background: #fff; cursor: pointer; }
.segmented label:first-child span { border-radius: 6px 0 0 6px; }
.segmented label:last-child span { border-radius: 0 6px 6px 0; border-left: 0; }
.segmented input:checked + span { background: #e4f4f0; color: #237361; border-color: rgba(47,143,123,.42); }
.toast-region { position: fixed; top: 18px; right: 18px; z-index: 2000; display: grid; gap: 8px; }
.toast { min-width: 260px; max-width: 420px; padding: 11px 14px; border: 1px solid #afded4; border-radius: 7px; background: #e4f4f0; color: #0f5c53; box-shadow: 0 8px 24px rgba(31,41,51,.15); font-weight: 700; }
.toast.error { border-color: #e2b5bc; background: #fae8e7; color: #91352f; }
.is-hidden { display: none !important; }
.board-loading { opacity: .55; pointer-events: none; }
