:root {
  --paper: #f7f5ef;
  --panel: #ffffff;
  --ink: #171717;
  --muted: #696969;
  --line: #d8d5cc;
  --accent: #11615b;
  --accent-soft: #e0f0ed;
  --warning: #7a4b00;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

.app {
  display: grid;
  grid-template-rows: minmax(0, 1fr) 152px;
  gap: 10px;
  height: 100vh;
  padding: 10px;
  overflow: hidden;
}

.app.is-calendar {
  grid-template-rows: minmax(0, 1fr);
}

.app.is-calendar .dog-panel {
  display: none;
}

.dog-panel,
.board-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.dog-panel {
  display: grid;
  grid-template-columns: 190px 230px minmax(0, 1fr);
  min-width: 0;
  overflow: hidden;
}

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

.panel-header {
  padding: 10px 12px;
  border-right: 1px solid var(--line);
}

.header-metrics {
  display: flex;
  align-items: center;
  gap: 10px;
}

.metric {
  display: grid;
  min-width: 130px;
  min-height: 54px;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 7px 12px;
}

.metric span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.metric strong {
  color: var(--ink);
  font-size: 20px;
  line-height: 1.1;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-size: 26px;
  line-height: 1.05;
}

h2 {
  font-size: 22px;
}

.icon-button {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 26px;
}

.search {
  display: grid;
  gap: 4px;
  width: auto;
  align-content: center;
  padding: 8px 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.search input {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  font-size: 14px;
  text-transform: none;
}

.dog-list {
  display: flex;
  gap: 6px;
  align-items: stretch;
  padding: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.dog-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  width: 148px;
  min-width: 148px;
  min-height: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 7px;
  touch-action: none;
  user-select: none;
}

.dog-card.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dog-card.is-assigned {
  background: #f2f1ec;
  opacity: 0.72;
}

.dog-photo,
.dog-initials {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  object-fit: cover;
  background: #ebe8df;
}

.dog-initials {
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 14px;
  font-weight: 900;
}

.dog-copy {
  display: grid;
  min-width: 0;
}

.dog-name {
  overflow: hidden;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.08;
  overflow-wrap: anywhere;
  white-space: normal;
}

.dog-owner,
.dog-stay,
.dog-location {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.15;
  overflow-wrap: anywhere;
  white-space: normal;
}

.dog-stay {
  color: var(--ink);
  font-weight: 950;
}

.dog-location {
  color: var(--accent);
  font-weight: 850;
}

.board-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.status {
  min-width: 170px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  text-align: center;
}

.status.is-busy {
  color: var(--warning);
}

.status.is-ok {
  color: var(--accent);
}

.room-tabs {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.room-tab {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 14px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
}

.room-tab.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.room-board {
  flex: 1;
  min-height: 0;
  padding: 10px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.calendar-board {
  display: grid;
  gap: 12px;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px 16px;
}

.calendar-header strong {
  color: var(--accent);
  font-size: 22px;
}

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

.sync-button {
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  padding: 0 14px;
  color: #fff;
  font-size: 14px;
  font-weight: 950;
}

.calendar-list {
  display: grid;
  gap: 8px;
}

.calendar-event {
  display: grid;
  grid-template-columns: 115px minmax(0, 1fr) 170px;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px 14px;
}

.calendar-time {
  color: var(--ink);
  font-size: 22px;
  font-weight: 950;
}

.calendar-title {
  color: var(--ink);
  font-size: 19px;
  font-weight: 950;
  overflow-wrap: anywhere;
}

.calendar-meta,
.calendar-source,
.calendar-deposit,
.calendar-checkin {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.calendar-deposit {
  margin-top: 4px;
  color: var(--warning);
}

.calendar-checkin {
  margin-top: 4px;
  color: var(--accent);
}

.calendar-deposit.is-paid {
  color: var(--accent);
}

.calendar-source {
  display: grid;
  gap: 4px;
  justify-self: end;
  text-align: right;
  text-transform: uppercase;
}

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

.calendar-empty,
.calendar-warning {
  display: grid;
  place-items: center;
  min-height: 120px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 18px;
  font-weight: 900;
  text-align: center;
}

.calendar-warning {
  min-height: auto;
  place-items: start;
  color: var(--warning);
  padding: 12px 14px;
  text-align: left;
}

.cabin-grid {
  display: grid;
  gap: 8px;
  align-items: stretch;
}

.cabin-grid.is-moego {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  min-width: 0;
}

.cabin-grid.is-local {
  width: 100%;
}

.cabin {
  display: grid;
  grid-template-rows: auto minmax(54px, 1fr) auto;
  min-height: 142px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.cabin-grid.is-moego .cabin {
  min-height: 156px;
}

.cabin.is-drop-target {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.cabin.is-clean {
  border-color: #bfd8d3;
  background: #fbfffe;
}

.cabin.is-dirty {
  border-color: #b7832d;
  background: #fff8e8;
}

.cabin-title {
  display: grid;
  gap: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.assigned-dog {
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 7px 0;
}

.assigned-main {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  min-width: 0;
}

.assigned-photo,
.assigned-initials {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  background: #ebe8df;
}

.assigned-initials {
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 16px;
  font-weight: 950;
}

.assigned-name {
  font-size: 17px;
  font-weight: 950;
  line-height: 1.05;
  overflow: hidden;
  overflow-wrap: anywhere;
  white-space: normal;
}

.assigned-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  overflow: hidden;
  overflow-wrap: anywhere;
  white-space: normal;
}

.empty-cabin {
  display: grid;
  place-items: center;
  min-height: 62px;
  color: #aaa;
  font-size: 16px;
  font-weight: 900;
  text-align: center;
}

.cabin-status {
  min-height: 70px;
  font-size: 24px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.cabin-status.is-clean {
  color: var(--accent);
}

.cabin-status.is-dirty {
  color: var(--warning);
}

.clear-button,
.status-button,
.moego-button {
  justify-self: start;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.status-button {
  color: var(--ink);
}

.moego-button {
  color: var(--accent);
}

.cabin.is-dirty .status-button {
  border-color: #b7832d;
}

.cabin.is-clean .status-button {
  border-color: #8fbdb5;
}

.drag-ghost {
  position: fixed;
  z-index: 1000;
  display: grid;
  place-items: center;
  width: 78px;
  height: 78px;
  border: 3px solid var(--accent);
  border-radius: 14px;
  background: #fff;
  padding: 6px;
  pointer-events: none;
  transform: translate(-50%, -50%);
  box-shadow: var(--shadow);
}

.drag-ghost .dog-photo,
.drag-ghost .dog-initials {
  width: 60px;
  height: 60px;
}

.drag-ghost span {
  display: none;
}

@media (max-width: 900px) {
  .app {
    grid-template-rows: minmax(0, 1fr) 190px;
    gap: 8px;
    padding: 8px;
  }

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

  .header-metrics {
    width: 100%;
    align-items: stretch;
  }

  .metric,
  .status {
    flex: 1;
    min-width: 0;
  }

  .dog-panel {
    grid-template-columns: 170px 210px minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  body {
    min-height: 100dvh;
  }

  .app {
    display: block;
    height: auto;
    min-height: 100dvh;
    overflow: auto;
  }

  .app.is-calendar .board-panel {
    min-height: 100dvh;
  }

  .board-panel {
    min-height: 72dvh;
    overflow: visible;
  }

  .board-header {
    gap: 10px;
    padding: 12px;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 21px;
  }

  .header-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .metric {
    min-height: 50px;
    padding: 7px 10px;
  }

  .metric strong {
    font-size: 18px;
  }

  .status {
    grid-column: 1 / -1;
    min-height: 42px;
    min-width: 0;
    padding: 10px;
  }

  .room-tabs {
    gap: 6px;
    padding: 8px;
  }

  .room-tab {
    min-height: 38px;
    padding: 0 12px;
    font-size: 16px;
    white-space: nowrap;
  }

  .room-board {
    padding: 8px;
    overflow: visible;
  }

  .cabin-grid.is-moego {
    gap: 8px;
    grid-template-columns: repeat(auto-fit, minmax(156px, 1fr)) !important;
    min-width: 0 !important;
  }

  .cabin-grid.is-local {
    gap: 6px;
  }

  .cabin {
    min-height: 136px;
  }

  .cabin-title {
    font-size: 11px;
  }

  .cabin-status {
    min-height: 60px;
    font-size: 22px;
  }

  .assigned-name {
    font-size: 16px;
  }

  .dog-panel {
    display: grid;
    grid-template-columns: 1fr;
    margin-top: 8px;
    overflow: visible;
  }

  .panel-header {
    border-right: 0;
    padding: 10px 12px;
  }

  .icon-button {
    width: 44px;
    height: 44px;
  }

  .search {
    border-right: 0;
    padding: 8px 12px 10px;
  }

  .search input {
    min-height: 40px;
    font-size: 16px;
  }

  .dog-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    max-height: 48dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .dog-card {
    width: 100%;
    min-width: 0;
    min-height: 104px;
  }

  .calendar-header,
  .calendar-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .calendar-event {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .calendar-source {
    justify-self: start;
    text-align: left;
  }
}

@media (max-width: 380px) {
  .header-metrics {
    grid-template-columns: 1fr;
  }

  .status {
    grid-column: auto;
  }

  .dog-list {
    grid-template-columns: 1fr;
  }
}
