:root {
  --black: #191719;
  --ink: #242126;
  --muted: #6f6b78;
  --line: #e8e5ef;
  --soft: #f7f6fb;
  --white: #ffffff;
  --purple: #624f9c;
  --lavender: #9899cb;
  --teal: #15555a;
  --mint: #30b489;
  --green: #2c9f6b;
  --yellow: #d99b1f;
  --red: #cf4446;
  --blue: #3270b6;
  --shadow: 0 18px 50px rgba(21, 85, 90, 0.12);
  --radius: 8px;
  --sidebar: 260px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--soft);
}

body {
  margin: 0;
  color: var(--ink);
  font-family: Verdana, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: 0;
  background:
    linear-gradient(90deg, rgba(98, 79, 156, 0.04), transparent 36%),
    radial-gradient(circle at 0 0, rgba(48, 180, 137, 0.06), transparent 32rem),
    var(--soft);
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  color: var(--white);
  background:
    linear-gradient(180deg, rgba(98, 79, 156, 0.18), transparent 38%),
    var(--black);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--white);
  text-decoration: none;
}

.brand-logo-frame {
  width: 204px;
  max-width: 100%;
  display: block;
  padding: 0;
  border-radius: var(--radius);
  background: transparent;
  border: 0;
  box-shadow: none;
}

.brand-logo {
  display: block;
  width: 100%;
  height: auto;
}

.brand-caption {
  color: var(--lavender);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-button {
  min-height: 42px;
  width: 100%;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  text-align: left;
}

.nav-button:hover,
.nav-button.is-active {
  color: var(--white);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.08);
}

.nav-button.is-locked {
  cursor: not-allowed;
  color: rgba(255, 255, 255, 0.45);
}

.nav-button.is-locked:hover {
  color: rgba(255, 255, 255, 0.58);
  background: rgba(255, 255, 255, 0.03);
  border-color: transparent;
}

.nav-icon {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  color: var(--white);
  background: rgba(152, 153, 203, 0.18);
}

.nav-button.is-active .nav-icon {
  background: var(--purple);
}

.nav-count {
  min-width: 24px;
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--black);
  background: var(--mint);
  font-size: 11px;
  text-align: center;
}

.nav-count.is-closed {
  color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.12);
}

.system-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

.system-note__title {
  margin: 0 0 10px;
  color: var(--white);
  font-weight: 700;
}

.swatches {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.swatches span {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--swatch);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 8;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.branch-control {
  display: grid;
  gap: 4px;
}

.branch-control label,
.field-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

select,
input,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(98, 79, 156, 0.12);
}

.topbar-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-chip {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  color: var(--ink);
  white-space: nowrap;
}

.avatar {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: var(--white);
  background: var(--teal);
  font-size: 11px;
  font-weight: 700;
}

.page {
  padding: 24px;
}

.page-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--purple);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  color: var(--black);
  font-size: 28px;
  line-height: 1.15;
}

.page-subtitle {
  max-width: 780px;
  margin: 8px 0 0;
  color: var(--muted);
}

.toolbar,
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
}

.toolbar {
  justify-content: flex-end;
}

.filters {
  margin-bottom: 14px;
}

.filter-field {
  min-width: 150px;
  display: grid;
  gap: 5px;
}

.filter-field.is-wide {
  min-width: min(100%, 280px);
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.icon-button,
.toggle-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-weight: 700;
  white-space: nowrap;
}

.primary-button {
  color: var(--white);
  background: var(--purple);
}

.primary-button:hover {
  background: #55448e;
}

.secondary-button {
  color: var(--teal);
  background: rgba(21, 85, 90, 0.08);
  border-color: rgba(21, 85, 90, 0.12);
}

.ghost-button,
.toggle-button {
  color: var(--ink);
  background: var(--white);
  border-color: var(--line);
}

.danger-button {
  color: var(--white);
  background: var(--red);
}

.icon-button {
  width: 38px;
  padding: 0;
  color: var(--ink);
  background: var(--white);
  border-color: var(--line);
}

.toggle-button.is-active {
  color: var(--white);
  background: var(--teal);
  border-color: var(--teal);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}

.segmented button {
  min-height: 32px;
  padding: 6px 10px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.segmented button.is-active {
  color: var(--white);
  background: var(--teal);
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.cols-2 {
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
}

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

.panel,
.metric-card,
.empty-state,
.modal-panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

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

.metric-card {
  min-height: 112px;
  display: grid;
  gap: 8px;
  padding: 16px;
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric-card strong {
  color: var(--black);
  font-size: 28px;
  line-height: 1.1;
}

.metric-card small {
  color: var(--muted);
}

.status-dot {
  width: 9px;
  height: 9px;
  display: inline-block;
  border-radius: 50%;
  background: var(--status-color, var(--line));
}

.tag,
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--tag-color, var(--ink));
  background: var(--tag-bg, var(--soft));
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill[data-status="free"] {
  --tag-color: #16704d;
  --tag-bg: rgba(48, 180, 137, 0.14);
}

.status-pill[data-status="booked"] {
  --tag-color: #7b5d00;
  --tag-bg: rgba(217, 155, 31, 0.16);
}

.status-pill[data-status="rented"] {
  --tag-color: #4f3d8a;
  --tag-bg: rgba(98, 79, 156, 0.16);
}

.status-pill[data-status="exit"] {
  --tag-color: #88471b;
  --tag-bg: rgba(217, 155, 31, 0.16);
}

.status-pill[data-status="visit"] {
  --tag-color: #15555a;
  --tag-bg: rgba(21, 85, 90, 0.12);
}

.status-pill[data-status="overdue"],
.status-pill[data-status="blocked"] {
  --tag-color: #9f292d;
  --tag-bg: rgba(207, 68, 70, 0.13);
}

.status-pill[data-status="unavailable"] {
  --tag-color: #5c5a62;
  --tag-bg: #ededf2;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}

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

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: #fbfafc;
  font-size: 12px;
  text-transform: uppercase;
  white-space: nowrap;
}

tbody tr:hover {
  background: rgba(152, 153, 203, 0.08);
}

td input,
td select {
  min-width: 100px;
  min-height: 32px;
}

.link-button {
  padding: 0;
  border: 0;
  color: var(--purple);
  background: transparent;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.scheme-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
}

.floor-map {
  min-height: 560px;
  display: grid;
  grid-template-columns: repeat(12, minmax(42px, 1fr));
  grid-template-rows: repeat(7, 64px);
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(21, 85, 90, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21, 85, 90, 0.04) 1px, transparent 1px),
    #fbfbfd;
  background-size: 32px 32px;
  overflow: auto;
}

.box-tile {
  min-width: 0;
  min-height: 58px;
  position: relative;
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 8px;
  color: var(--tile-text, var(--ink));
  border: 1px solid rgba(25, 23, 25, 0.08);
  border-radius: 7px;
  background: var(--tile-bg);
  text-align: left;
  box-shadow: 0 8px 20px rgba(25, 23, 25, 0.06);
}

.box-tile:hover,
.box-tile.is-active {
  outline: 3px solid rgba(98, 79, 156, 0.18);
}

.box-tile strong {
  font-size: 13px;
}

.box-tile span {
  font-size: 11px;
}

.box-tile[data-status="free"] {
  --tile-bg: rgba(48, 180, 137, 0.22);
}

.box-tile[data-status="booked"] {
  --tile-bg: rgba(217, 155, 31, 0.22);
}

.box-tile[data-status="rented"] {
  --tile-bg: rgba(98, 79, 156, 0.2);
}

.box-tile[data-status="exit"] {
  --tile-bg: rgba(217, 155, 31, 0.14);
}

.box-tile[data-status="visit"] {
  --tile-bg: rgba(21, 85, 90, 0.15);
}

.box-tile[data-status="overdue"],
.box-tile[data-status="blocked"] {
  --tile-bg: rgba(207, 68, 70, 0.18);
}

.box-tile[data-status="unavailable"] {
  --tile-bg: #e9e8ef;
}

.box-tile.is-battery {
  --tile-bg: linear-gradient(90deg, #cf4446 0%, #d99b1f 48%, #30b489 100%);
  --tile-text: #ffffff;
}

.box-popover {
  align-self: start;
  position: sticky;
  top: 86px;
}

.box-popover dl,
.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}

.box-popover dt,
.details-grid span {
  color: var(--muted);
  font-size: 12px;
}

.box-popover dd,
.details-grid strong {
  margin: 0;
  font-weight: 700;
}

.device-list {
  display: grid;
  gap: 10px;
}

.device-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfafc;
}

.device-item strong {
  display: block;
}

.device-item small {
  color: var(--muted);
}

.price-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}

.price-cell {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}

.price-cell span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.price-cell input {
  margin-top: 6px;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 13px minmax(0, 1fr);
  gap: 10px;
}

.timeline-item::before {
  content: "";
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--mint);
}

.empty-state {
  padding: 28px;
  display: grid;
  gap: 10px;
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  color: var(--black);
  font-size: 18px;
}

.skeleton-stack {
  display: grid;
  gap: 16px;
}

.skeleton-line,
.skeleton-card,
.skeleton-table-row {
  overflow: hidden;
  position: relative;
  border-radius: var(--radius);
  background: #ebe8f2;
}

.skeleton-line::after,
.skeleton-card::after,
.skeleton-table-row::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.68), transparent);
  animation: shimmer 1.2s infinite;
}

.skeleton-line {
  width: min(100%, 560px);
  height: 18px;
}

.skeleton-card {
  min-height: 132px;
}

.skeleton-table-row {
  height: 44px;
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  display: grid;
  gap: 10px;
}

.toast {
  width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  color: var(--white);
  background: var(--teal);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(25, 23, 25, 0.48);
}

.modal-panel {
  width: min(1040px, 100%);
  max-height: min(820px, calc(100vh - 48px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.modal-panel.is-confirm {
  width: min(460px, 100%);
}

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

.modal-footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.modal-title {
  margin: 0;
  font-size: 20px;
}

.modal-body {
  padding: 18px;
  overflow: auto;
}

.modal-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.65fr);
  gap: 16px;
}

.modal-grid > .grid {
  align-content: start;
}

.close-button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--white);
}

details {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}

summary {
  padding: 12px;
  cursor: pointer;
  font-weight: 700;
}

details .details-body {
  padding: 0 12px 12px;
}

.photo-placeholder {
  min-height: 180px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(98, 79, 156, 0.38);
  border-radius: var(--radius);
  color: var(--purple);
  background:
    repeating-linear-gradient(135deg, rgba(152, 153, 203, 0.12) 0 12px, transparent 12px 24px),
    #fbfafc;
  font-weight: 700;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 86px minmax(0, 1fr);
  }

  .sidebar {
    padding: 16px 10px;
  }

  .brand-caption,
  .nav-button span:not(.nav-icon):not(.nav-count),
  .system-note {
    display: none;
  }

  .brand-logo-frame {
    width: 56px;
    padding: 0;
  }

  .nav-button {
    grid-template-columns: 1fr;
    place-items: center;
  }

  .nav-count {
    display: none;
  }

  .scheme-layout,
  .grid.cols-2,
  .modal-grid {
    grid-template-columns: 1fr;
  }

  .box-popover {
    position: static;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .brand {
    min-width: 102px;
  }

  .nav-list {
    display: flex;
    min-width: max-content;
  }

  .topbar,
  .page-header,
  .pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    position: static;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }

  .page {
    padding: 16px;
  }

  .page-header {
    display: grid;
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 24px;
  }

  .grid.cols-3,
  .box-popover dl,
  .details-grid {
    grid-template-columns: 1fr;
  }

  .floor-map {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: minmax(86px, auto);
  }

  .box-tile {
    grid-column: auto !important;
    grid-column-start: auto !important;
    grid-column-end: auto !important;
    grid-row: auto !important;
    grid-row-start: auto !important;
    grid-row-end: auto !important;
    min-height: 86px;
  }

  .user-chip span:last-child {
    display: none;
  }
}
