:root {
  --blue-950: #063653;
  --blue-900: #084262;
  --blue-700: #0f78ae;
  --blue-500: #1998d5;
  --ink: #172131;
  --muted: #66738a;
  --line: #d2dce8;
  --soft: #f3f7fb;
  --white: #ffffff;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--soft);
  color: var(--ink);
  font-family: Arial, sans-serif;
}

button,
input {
  font: inherit;
}

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

.app-shell.is-logged-out {
  display: block;
}

.sidebar {
  min-height: 100vh;
  padding: 28px 14px;
  background: var(--blue-950);
  color: var(--white);
}

.brand {
  margin-bottom: 30px;
  font-size: 28px;
  letter-spacing: 3px;
}

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

.nav-item,
.nav-group-label {
  border: 0;
  border-radius: 6px;
  padding: 13px 14px;
  background: transparent;
  color: #d8ebf7;
  text-align: left;
  cursor: pointer;
}

.nav-group-label {
  color: #ffffff;
  cursor: default;
  font-weight: 800;
  opacity: .95;
}

.nav-group-label:disabled {
  color: #ffffff;
}

.nav-item.is-active {
  background: #10567a;
  color: var(--white);
  font-weight: 700;
}

.nav-group {
  display: grid;
  gap: 4px;
}

.nav-subgroup {
  display: grid;
  gap: 4px;
  margin-left: 10px;
}

.nav-subgroup-label {
  padding-top: 8px;
  padding-bottom: 8px;
  font-size: 14px;
}

.nav-subitem {
  margin-left: 18px;
  padding-top: 9px;
  padding-bottom: 9px;
  color: #c7e3f2;
  font-size: 14px;
}

.main {
  padding: 22px 28px;
}

.is-logged-out .main {
  min-height: 100vh;
  padding: 0;
}

.topbar {
  min-height: 68px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
}

.topbar strong,
.topbar span {
  display: block;
}

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

.user-menu {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-icon-button,
.login-card button {
  border: 0;
  border-radius: 6px;
  padding: 12px 18px;
  background: var(--blue-500);
  color: var(--white);
  font-weight: 700;
  cursor: pointer;
}

.user-icon-button {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #b9d8ef;
  border-radius: 50%;
  background: var(--white);
  color: var(--blue-700);
}

.user-icon-button span {
  display: block;
  width: 16px;
  height: 16px;
  margin: 0 auto;
  border: 2px solid currentColor;
  border-radius: 50% 50% 45% 45%;
  position: relative;
}

.user-icon-button span::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -14px;
  width: 22px;
  height: 14px;
  border: 2px solid currentColor;
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  transform: translateX(-50%);
}

.user-dropdown {
  position: absolute;
  z-index: 20;
  top: calc(100% + 10px);
  right: 0;
  min-width: 220px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  box-shadow: 0 22px 50px rgba(23, 33, 49, .12);
}

.user-dropdown button {
  width: 100%;
  border: 0;
  border-radius: 4px;
  padding: 10px 12px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-weight: 700;
  cursor: pointer;
}

.user-dropdown button:hover {
  background: #eef6fb;
}

.login-panel {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.login-card {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 22px 50px rgba(23, 33, 49, .08);
}

.login-card h1 {
  margin: 0 0 22px;
}

.login-card label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-card input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
}

.error-text {
  min-height: 20px;
  margin: 12px 0 0;
  color: #cf2e43;
  font-weight: 700;
}

.password-dialog {
  width: min(440px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(23, 33, 49, .2);
}

.password-dialog::backdrop {
  background: rgba(8, 18, 30, .35);
}

.password-dialog form {
  padding: 24px;
}

.password-dialog h2 {
  margin: 0 0 18px;
}

.password-dialog label {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.password-dialog input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  color: var(--ink);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.dialog-actions button {
  border: 0;
  border-radius: 6px;
  padding: 11px 15px;
  background: var(--blue-500);
  color: var(--white);
  font-weight: 700;
  cursor: pointer;
}

.dialog-actions .secondary-button {
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
}

.admin-panel {
  padding-top: 26px;
}

.page-heading p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.page-heading h1 {
  margin: 0 0 22px;
  font-size: 36px;
}

.stat-grid,
.data-grid {
  display: grid;
  gap: 16px;
}

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

.stat-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.stat-card {
  padding: 18px;
}

.stat-card strong {
  display: block;
  font-size: 34px;
}

.stat-card span {
  color: var(--muted);
  font-weight: 700;
}

.panel {
  margin-top: 18px;
  overflow: hidden;
}

.panel h2 {
  margin: 0;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 20px;
}

.empty-module {
  padding: 18px;
  color: var(--muted);
}

.empty-module strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
}

.empty-module p {
  margin: 0;
}

.screen-overview-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.filter-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.segmented button {
  border: 0;
  border-radius: 6px;
  padding: 9px 13px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.segmented button.active {
  background: #17202a;
  color: #fff;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 320px;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}

.search-field input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
}

.screen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}

.screen-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 22px 50px rgba(23, 33, 49, .06);
  text-align: left;
}

.screen-card:hover {
  border-color: rgba(14, 149, 217, .45);
}

.screen-thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  margin-bottom: 16px;
  border-radius: 7px;
  background: linear-gradient(135deg, #142634, #0e95d9 56%, #efb84a);
  color: #fff;
  overflow: hidden;
}

.screen-thumb-preview {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  border-radius: 7px;
}

.screen-thumb.is-portrait {
  aspect-ratio: 16 / 9;
  background: #e6edf4;
}

.screen-thumb.is-portrait .screen-thumb-preview {
  height: 100%;
  width: auto;
  aspect-ratio: var(--screen-ratio, .5625);
  background: linear-gradient(135deg, #142634, #0e95d9 56%, #efb84a);
}

.screen-thumb strong {
  font-size: 23px;
}

.card-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.screen-card h2 {
  margin: 0 0 6px;
  font-size: 21px;
}

.screen-card p {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
}

.screen-card .screen-owner {
  margin-top: 5px;
  font-size: 14px;
  font-weight: 700;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 12px;
  background: #e8f6ff;
  color: var(--blue-700);
  font-size: 12px;
  font-weight: 800;
}

.status-pill.offline {
  background: #fde8ed;
  color: #cf2e43;
}

.empty-state {
  grid-column: 1 / -1;
  margin: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--muted);
}

.customer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}

.customer-card {
  display: grid;
  gap: 16px;
  width: 100%;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 22px 50px rgba(23, 33, 49, .06);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.customer-card:hover {
  border-color: rgba(14, 149, 217, .45);
}

.customer-card h2 {
  margin: 0 0 6px;
  font-size: 22px;
}

.customer-card p {
  margin: 0;
  color: var(--muted);
}

.customer-card dl,
.customer-summary dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.customer-card dl {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.customer-card dt,
.customer-summary dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.customer-card dd,
.customer-summary dd {
  margin: 3px 0 0;
  font-weight: 800;
}

.customer-summary {
  display: grid;
  grid-template-columns: minmax(220px, 340px) minmax(0, 1fr);
  gap: 24px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 22px 50px rgba(23, 33, 49, .06);
}

.customer-summary p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.customer-summary h2 {
  margin: 0;
  font-size: 30px;
}

.customer-summary dl {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.customer-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  margin: 18px 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.customer-tabs button {
  border: 0;
  border-radius: 6px;
  padding: 12px 14px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.customer-tabs button.active {
  background: var(--blue-950);
  color: var(--white);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 18px;
  border-bottom: 1px solid #e7edf4;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e8f6ff;
  color: var(--blue-700);
  font-weight: 800;
  font-size: 12px;
}

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

  .sidebar {
    min-height: auto;
  }

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

  .screen-overview-toolbar {
    display: grid;
  }

  .search-field {
    min-width: 0;
    width: 100%;
  }

  .customer-summary,
  .customer-summary dl,
  .customer-tabs {
    grid-template-columns: 1fr;
  }

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