:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f3f4f6;
  color: #252525;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f3f4f6;
}

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

.mobile-nav {
  display: none;
}

.mobile-write-action {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 20px;
  border-right: 1px solid #4a4a4a;
  background: #1f1f1f;
  padding: 24px 18px;
  overflow: auto;
}

.sidebar h1 {
  font-size: 1.7rem;
}

.side-nav {
  display: grid;
  align-content: start;
  gap: 8px;
}

.side-nav strong {
  margin-top: 12px;
  color: #ffb36b;
  font-size: 0.82rem;
  text-transform: uppercase;
}

.nav-link {
  min-height: 40px;
  width: 100%;
  justify-content: start;
  text-align: left;
  color: #f5f5f5;
  background: transparent;
}

.nav-link.is-active,
.nav-link:hover {
  color: #1f1f1f;
  background: #f97316;
}

.main-area {
  min-width: 0;
  padding: 24px;
  display: grid;
  align-content: start;
  gap: 16px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.page-header h2 {
  margin: 0;
  font-size: 1.8rem;
}

.inline-tools {
  margin-top: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.hidden-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.mobile-action-panel {
  display: grid;
  gap: 12px;
}

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

.app {
  width: min(980px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  align-content: start;
  gap: 16px;
}

.topbar {
  min-height: 112px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #ffb36b;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.1rem, 10vw, 4.2rem);
  line-height: 0.95;
  letter-spacing: 0;
  color: #ffffff;
}

h2 {
  font-size: 1.05rem;
  margin-bottom: 10px;
}

.badge {
  flex: 0 0 auto;
  border: 1px solid #555555;
  border-radius: 999px;
  padding: 8px 12px;
  background: #2f2f2f;
  color: #d7d7d7;
  font-size: 0.9rem;
  font-weight: 800;
}

.badge[data-supported="true"] {
  border-color: #f97316;
  color: #ffb36b;
  background: #3a2a1f;
}

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

.menu-card {
  min-height: 132px;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 8px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 18px;
  background: #ffffff;
  color: #252525;
  text-align: left;
  box-shadow: 0 14px 32px rgba(36, 36, 36, 0.08);
}

.menu-card strong {
  color: #ffb36b;
  font-size: 1.25rem;
}

.menu-card span {
  color: #646464;
  line-height: 1.35;
}

.view {
  display: none;
  gap: 14px;
}

.view.is-active {
  display: grid;
}

.panel,
.status-panel,
.detail-panel,
.device-card {
  border: 1px solid #4a4a4a;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 14px 32px rgba(36, 36, 36, 0.08);
}

.panel,
.status-panel,
.detail-panel {
  padding: 18px;
}

.submenu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  flex-wrap: wrap;
}

.submenu-header h2 {
  flex: 1;
  margin: 0;
}

.back-button {
  min-width: 104px;
}

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

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

.bulk-panel {
  display: grid;
  grid-template-columns: auto auto minmax(150px, 1fr) minmax(160px, 0.8fr) minmax(150px, 1fr) minmax(150px, 1fr);
  gap: 10px;
  align-items: end;
}

.check-label {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.check-label input,
.row-selector input {
  width: 18px;
  min-height: 18px;
  accent-color: #f97316;
}

.selection-count {
  align-self: center;
  color: #ffb36b;
  font-weight: 800;
}

.bulk-date {
  min-width: 0;
}

.device-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.device-card.is-selected {
  border-color: #f97316;
}

.card-main {
  min-height: 72px;
  display: grid;
  justify-items: start;
  gap: 3px;
  padding: 12px 14px;
  background: #ffffff;
  color: #252525;
  text-align: left;
}

.row-selector {
  width: 50px;
  min-height: 62px;
  display: grid;
  place-items: center;
  border-right: 1px solid #4a4a4a;
}

.card-main.compact {
  min-height: 62px;
  grid-template-columns: minmax(96px, 0.75fr) minmax(140px, 1.4fr) minmax(110px, 1fr) minmax(96px, 0.8fr);
  align-items: center;
}

.card-main span {
  color: #ffb36b;
  font-weight: 700;
}

.card-main small {
  color: #707070;
}

.card-main .is-overdue {
  color: #ff6b6b;
  font-weight: 850;
}

.card-action {
  min-width: 132px;
  border-left: 1px solid #4a4a4a;
  border-radius: 0;
}

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

.compact-form {
  display: grid;
  grid-template-columns: minmax(120px, 0.45fr) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

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

.type-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
  box-shadow: 0 14px 32px rgba(36, 36, 36, 0.08);
}

.type-card span {
  color: #252525;
  font-weight: 800;
}

.type-card strong {
  color: #ffb36b;
  margin-right: 8px;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: end;
}

.grid-form h2,
.wide {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 7px;
  color: #3d3d3d;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid #5a5a5a;
  border-radius: 7px;
  padding: 11px 12px;
  background: #ffffff;
  color: #252525;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #f97316;
  outline: 3px solid rgba(249, 115, 22, 0.25);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.actions.single {
  grid-template-columns: 1fr;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 7px;
  padding: 0 14px;
  color: #1f1f1f;
  background: #f97316;
  font-weight: 850;
  cursor: pointer;
}

button.secondary {
  color: #ffffff;
  background: #555555;
}

button.danger {
  color: #ffffff;
  background: #b4232a;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.hint,
.empty {
  color: #6d6d6d;
  line-height: 1.45;
}

.hint {
  margin-bottom: 14px;
}

.preview {
  margin: 14px 0;
}

dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

dt {
  color: #6d6d6d;
  font-size: 0.82rem;
  font-weight: 800;
}

dd {
  margin: 2px 0 0;
  color: #252525;
  overflow-wrap: anywhere;
}

#statusText {
  color: #3d3d3d;
  line-height: 1.45;
}

#statusText[data-type="error"] {
  color: #ff6b6b;
}

@media (max-width: 720px) {
  .desktop-shell {
    grid-template-columns: 1fr;
    padding-bottom: 84px;
  }

  .sidebar {
    display: none;
  }

  .main-area {
    padding: 14px;
  }

  .mobile-nav {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    border: 1px solid #dedede;
    border-radius: 8px;
    padding: 6px;
    background: #ffffff;
    box-shadow: 0 14px 32px rgba(36, 36, 36, 0.18);
  }

  .mobile-nav .nav-link {
    min-height: 46px;
    padding: 0 6px;
    color: #3d3d3d;
    background: #f3f4f6;
    text-align: center;
    justify-content: center;
    font-size: 0.84rem;
  }

  .mobile-nav .nav-link.is-active {
    color: #1f1f1f;
    background: #f97316;
  }

  .page-header {
    align-items: stretch;
  }

  .page-header h2 {
    font-size: 1.4rem;
  }

  #devicesView .page-header .secondary,
  #devicesView .page-header #newDeviceButton,
  #devicesView .filter-panel,
  #devicesView .bulk-panel,
  #devicesView .row-selector,
  .status-panel {
    display: none;
  }

  #devicesView .card-action:not(.mobile-write-action) {
    display: none;
  }

  #devicesView .mobile-write-action {
    display: block;
  }

  .app {
    padding: 16px;
  }

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

  .menu-grid,
  .filter-panel,
  .bulk-panel,
  .grid-form,
  .compact-form,
  .inline-tools,
  .actions,
  dl {
    grid-template-columns: 1fr;
  }

  .device-card {
    grid-template-columns: 1fr;
  }

  .row-selector {
    width: 100%;
    min-height: 42px;
    border-right: 0;
    border-bottom: 1px solid #4a4a4a;
  }

  .card-action {
    border-left: 0;
    border-top: 1px solid #4a4a4a;
    border-radius: 0;
  }

  .card-main.compact {
    grid-template-columns: 1fr;
  }

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

  .submenu-header h2 {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .submenu-header .back-button {
    grid-column: 1;
    grid-row: 2;
  }

  .submenu-header button:not(.back-button) {
    grid-column: auto;
    grid-row: auto;
  }
}
