
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #172033;
  --muted: #73809a;
  --border: #e4e9f2;
  --primary: #6d4aff;
  --primary-dark: #5636e8;
  --primary-soft: #eee9ff;
  --success: #16a36a;
  --success-soft: #e8f8f1;
  --warning: #e99a1f;
  --warning-soft: #fff5e2;
  --danger: #dc4c64;
  --danger-soft: #fdecef;
  --sidebar: #171b2e;
  --sidebar-muted: #9aa3bf;
  --shadow: 0 14px 35px rgba(35, 45, 80, .08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 18px;
  background:
    radial-gradient(circle at top left, rgba(109, 74, 255, .24), transparent 34%),
    var(--sidebar);
  color: white;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px 30px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, #8c70ff, #5d3be7);
  font-size: 23px;
  box-shadow: 0 10px 24px rgba(109, 74, 255, .35);
}

.brand strong {
  display: block;
  font-size: 16px;
}

.brand span {
  display: block;
  margin-top: 2px;
  color: var(--sidebar-muted);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 13px;
  color: var(--sidebar-muted);
  font-size: 14px;
  font-weight: 700;
  transition: .2s ease;
}

.nav a:hover,
.nav a.active {
  color: white;
  background: rgba(255,255,255,.10);
  transform: translateX(2px);
}

.nav-icon {
  width: 24px;
  text-align: center;
  font-size: 18px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 18px;
  border-radius: 16px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.08);
}

.sidebar-footer strong {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
}

.sidebar-footer p {
  margin: 0;
  color: var(--sidebar-muted);
  font-size: 12px;
  line-height: 1.55;
}

.main {
  min-width: 0;
  padding: 28px 34px 42px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  align-items: center;
  margin-bottom: 28px;
}

.page-heading h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 36px);
  letter-spacing: -.04em;
}

.page-heading p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search {
  width: min(320px, 30vw);
  height: 44px;
  padding: 0 15px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
  outline: none;
  transition: .2s;
}

.search:focus,
.field:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.avatar {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}

.stat-card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stat-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--primary-soft);
  font-size: 20px;
}

.stat-value {
  margin-top: 15px;
  font-size: 28px;
  font-weight: 850;
  letter-spacing: -.03em;
}

.stat-note {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.positive {
  color: var(--success);
}

.negative {
  color: var(--danger);
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(290px, .75fr);
  gap: 22px;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  margin: 0;
  font-size: 17px;
}

.panel-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.panel-body {
  padding: 22px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th {
  padding: 13px 16px;
  background: var(--surface-soft);
  color: var(--muted);
  text-align: left;
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

td {
  padding: 15px 16px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}

tbody tr:hover {
  background: #fbfcff;
}

.item-cell {
  display: flex;
  gap: 12px;
  align-items: center;
}

.item-thumb {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 12px;
  background: var(--primary-soft);
  font-size: 20px;
}

.item-cell strong,
.pet-cell strong {
  display: block;
}

.item-cell span,
.pet-cell span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.success {
  color: var(--success);
  background: var(--success-soft);
}

.badge.warning {
  color: #a4660b;
  background: var(--warning-soft);
}

.badge.danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.badge.neutral {
  color: #58657f;
  background: #eef1f6;
}

.btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 800;
  font-size: 13px;
}

.btn-primary {
  color: white;
  background: var(--primary);
  box-shadow: 0 10px 20px rgba(109, 74, 255, .22);
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-light {
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

.btn-danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-group {
  display: grid;
  gap: 8px;
}

.form-group.full {
  grid-column: 1 / -1;
}

label {
  color: #4c5870;
  font-size: 12px;
  font-weight: 800;
}

.field,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: white;
  outline: none;
}

.field,
.select {
  height: 43px;
  padding: 0 13px;
}

.textarea {
  min-height: 96px;
  padding: 12px 13px;
  resize: vertical;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.progress-list {
  display: grid;
  gap: 18px;
}

.progress-row {
  display: grid;
  gap: 8px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
}

.progress-meta span {
  color: var(--muted);
}

.progress {
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: #edf0f5;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #9c87ff);
}

.card-list {
  display: grid;
  gap: 12px;
}

.mini-card {
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}

.mini-card .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.mini-card p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.pet-cell {
  display: flex;
  align-items: center;
  gap: 11px;
}

.pet-avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff3de;
  font-size: 20px;
}

.price {
  font-weight: 850;
}

.kpi-large {
  padding: 26px;
  border-radius: var(--radius);
  color: white;
  background:
    radial-gradient(circle at top right, rgba(255,255,255,.26), transparent 35%),
    linear-gradient(135deg, #6d4aff, #3d2ba5);
  box-shadow: var(--shadow);
}

.kpi-large small {
  opacity: .8;
  font-weight: 700;
}

.kpi-large strong {
  display: block;
  margin-top: 12px;
  font-size: 36px;
}

.kpi-large p {
  margin: 8px 0 0;
  opacity: .82;
  font-size: 12px;
}

.chart {
  height: 230px;
  display: flex;
  align-items: end;
  gap: 16px;
  padding: 24px 10px 4px;
}

.chart-col {
  flex: 1;
  display: grid;
  justify-items: center;
  gap: 9px;
}

.chart-bar {
  width: min(34px, 80%);
  min-height: 8px;
  border-radius: 9px 9px 4px 4px;
  background: linear-gradient(180deg, #8e74ff, #6040e9);
}

.chart-col span {
  color: var(--muted);
  font-size: 11px;
}

.quick-filter {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: white;
  font-size: 11px;
  font-weight: 800;
}

.filter-chip.active {
  color: var(--primary);
  border-color: #cfc4ff;
  background: var(--primary-soft);
}

.room-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 14px;
}

.room-card {
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface-soft);
}

.room-card .room-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.room-card h3 {
  margin: 0;
  font-size: 14px;
}

.room-card p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.total-box {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-top: 17px;
  padding: 16px;
  border-radius: 13px;
  background: var(--primary-soft);
}

.total-box span {
  color: var(--muted);
  font-size: 12px;
}

.total-box strong {
  color: var(--primary);
  font-size: 21px;
}

@media (max-width: 1100px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .room-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 18px;
  }

  .brand {
    padding-bottom: 18px;
  }

  .nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav a {
    justify-content: center;
    min-height: 54px;
    padding: 7px;
    text-align: center;
    font-size: 11px;
    flex-direction: column;
    gap: 3px;
  }

  .sidebar-footer {
    display: none;
  }

  .main {
    padding: 22px 16px 34px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
  }

  .search {
    width: 100%;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .room-grid {
    grid-template-columns: 1fr;
  }
}

.app-toast { position: fixed; right: 24px; bottom: 24px; z-index: 9999; padding: 13px 18px; border-radius: 12px; background: #171b2e; color: #fff; font-size: 13px; font-weight: 750; box-shadow: 0 14px 35px rgba(23,27,46,.25); opacity: 0; transform: translateY(12px); transition: .22s ease; }
.app-toast.show { opacity: 1; transform: translateY(0); }


/* --- Inpatient clinical workspace v5 --- */
.pet-management-grid {
  grid-template-columns: minmax(0, 1.45fr) minmax(380px, .85fr);
}

.pet-master-table {
  min-width: 880px;
}

.inpatient-workspace {
  display: grid;
  grid-template-columns: minmax(520px, .92fr) minmax(560px, 1.08fr);
  gap: 22px;
  align-items: start;
}

.inpatient-list-panel,
.patient-detail-panel {
  min-width: 0;
}

.inpatient-table-wrap {
  max-height: 670px;
  overflow: auto;
}

.inpatient-table {
  min-width: 660px;
}

.inpatient-row {
  cursor: pointer;
  transition: .18s ease;
}

.inpatient-row:hover {
  background: #f8f6ff;
}

.inpatient-row.selected {
  background: var(--primary-soft);
}

.inpatient-row.selected td:first-child {
  box-shadow: inset 4px 0 0 var(--primary);
}

.patient-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 22px 24px 18px;
}

.patient-identity {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.patient-avatar {
  width: 52px;
  height: 52px;
  font-size: 25px;
  flex: 0 0 auto;
}

.patient-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.patient-header h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -.025em;
}

.patient-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.patient-tabs {
  display: flex;
  gap: 7px;
  padding: 0 22px 14px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.patient-tab {
  min-height: 39px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.patient-tab:hover {
  color: var(--text);
  background: var(--surface-soft);
}

.patient-tab.active {
  color: var(--primary);
  border-color: #d8d0ff;
  background: var(--primary-soft);
}

.patient-tab-content {
  min-height: 560px;
  padding: 22px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.detail-card {
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}

.detail-card.full {
  grid-column: 1 / -1;
}

.detail-card span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.detail-card strong {
  display: block;
  font-size: 13px;
  line-height: 1.55;
}

.medication-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  margin-bottom: 16px;
  border: 1px solid #ffd3da;
  border-radius: 13px;
  background: var(--danger-soft);
  color: #963247;
  font-size: 12px;
  line-height: 1.5;
}

.clinical-section-title {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  margin: 4px 0 12px;
}

.clinical-section-title h3 {
  margin: 0;
  font-size: 14px;
}

.clinical-section-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.clinical-table {
  min-width: 760px;
}

.clinical-table th,
.clinical-table td {
  padding: 11px 12px;
}

.admin-record {
  display: grid;
  gap: 3px;
}

.admin-record small {
  color: var(--muted);
  font-size: 10px;
}

.treatment-add {
  margin-top: 18px;
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface-soft);
}

.treatment-add h3 {
  margin: 0 0 14px;
  font-size: 14px;
}

.hotel-assignment {
  display: grid;
  gap: 14px;
}

.hotel-current {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-radius: 15px;
  color: white;
  background: linear-gradient(135deg, #6d4aff, #4630b7);
}

.hotel-current small {
  display: block;
  opacity: .75;
  margin-bottom: 5px;
}

.hotel-current strong {
  font-size: 22px;
}

.hotel-current p {
  margin: 5px 0 0;
  opacity: .8;
  font-size: 11px;
}

.hotel-room-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: rgba(255,255,255,.14);
  font-size: 25px;
}

.payment-table {
  min-width: 720px;
}

.payment-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 12px;
  margin-top: 16px;
}

.payment-summary .summary-card {
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}

.payment-summary span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.payment-summary strong {
  display: block;
  margin-top: 7px;
  font-size: 17px;
}

.payment-summary .summary-card.total {
  color: var(--primary);
  border-color: #d8d0ff;
  background: var(--primary-soft);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 280px;
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  display: block;
  color: var(--text);
  margin-bottom: 5px;
}

.status-given {
  color: var(--success);
  font-weight: 850;
}

.status-pending {
  color: var(--warning);
  font-weight: 850;
}

@media (max-width: 1380px) {
  .inpatient-workspace {
    grid-template-columns: 1fr;
  }

  .patient-tab-content {
    min-height: 430px;
  }

  .pet-management-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .detail-grid,
  .payment-summary {
    grid-template-columns: 1fr;
  }

  .patient-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .patient-tab-content {
    padding: 16px;
  }
}
