:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #eef2f5;
  color: #172026;
  --tooltip-font-size: 16px;
  --color-primary: #e5e7eb;
  --color-primary-focus: rgba(31, 41, 55, 0.12);
  --color-secondary: #e5e7eb;
  --color-secondary-hover: #d1d5db;
  --color-attention: #e5e7eb;
  --color-danger: #9f1d1d;
  --color-tooltip: #e5e7eb;
  --color-tooltip-soft: rgba(31, 41, 55, 0.16);
  --color-button-text: #111827;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

.auth-gate {
  align-items: center;
  background: rgba(238, 242, 245, 0.96);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
  z-index: 100;
}

.auth-gate[hidden] {
  display: none;
}

.auth-card {
  background: #ffffff;
  border: 1px solid #d9e0e6;
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
  display: grid;
  gap: 16px;
  max-width: 380px;
  padding: 24px;
  width: 100%;
}

.auth-card h1 {
  font-size: 24px;
}

.auth-card p {
  color: #5c6873;
  line-height: 1.5;
}

.auth-error {
  color: var(--color-danger);
  min-height: 20px;
}

.app-dialog {
  align-items: center;
  background: rgba(15, 23, 42, 0.34);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
  z-index: 90;
}

.app-dialog[hidden] {
  display: none;
}

.app-dialog-card {
  background: #ffffff;
  border: 1px solid #d9e0e6;
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
  display: grid;
  gap: 16px;
  max-width: 440px;
  padding: 24px;
  width: min(100%, 440px);
}

.app-dialog-card h2 {
  font-size: 24px;
  margin: 0;
}

.app-dialog-card p {
  color: #111827;
  line-height: 1.6;
  margin: 0;
  white-space: pre-line;
}

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

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--color-primary);
  color: var(--color-button-text);
  cursor: pointer;
  min-height: 40px;
  padding: 0 16px;
}

button.secondary {
  background: var(--color-secondary);
}

button.secondary:hover:not(:disabled) {
  background: var(--color-secondary-hover);
}

button.attention {
  background: var(--color-attention);
  box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.18);
}

button:disabled,
button.is-locked {
  background: #f3f4f6;
  box-shadow: none;
  color: #6b7280;
  cursor: not-allowed;
}

.call-prep-prompt {
  align-items: center;
  animation: callPrepPulse 1s ease-in-out infinite;
  background: var(--color-tooltip);
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 14px 36px var(--color-tooltip-soft);
  color: var(--color-button-text);
  display: flex;
  font-size: var(--tooltip-font-size);
  gap: 12px;
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px;
  position: fixed;
  z-index: 80;
}

.call-prep-prompt::after {
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-top: 10px solid var(--color-tooltip);
  bottom: -10px;
  content: "";
  left: 50%;
  position: absolute;
  transform: translateX(-50%);
}

.call-prep-prompt[hidden] {
  display: none;
}

.call-prep-prompt span {
  flex: 1 1 auto;
  line-height: 1.45;
  min-width: 0;
}

.call-prep-prompt button {
  flex: 0 0 auto;
  background: #d1d5db;
  color: var(--color-button-text);
}

@keyframes callPrepPulse {
  0%,
  100% {
    transform: translateY(0);
    box-shadow: 0 14px 36px var(--color-tooltip-soft);
  }
  50% {
    transform: translateY(-2px);
    box-shadow:
      0 0 0 4px rgba(17, 24, 39, 0.18),
      0 14px 36px var(--color-tooltip-soft);
  }
}

.shell {
  margin: 0 auto;
  max-width: 1180px;
  padding: 24px;
}

.shell[hidden] {
  display: none !important;
}

.topbar {
  align-items: end;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.topbar-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.brand-block {
  align-items: center;
  display: inline-flex;
  gap: 8px;
}

.brand-logo {
  border-radius: 8px;
  display: block;
  height: 40px;
  object-fit: cover;
  width: 40px;
}

.connection-pill {
  color: #4a5560;
  font-size: 13px;
  line-height: 1;
  transform: translateY(2px);
}

.section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.section-nav button {
  min-height: 36px;
  padding: 0 14px;
}

.console-section[hidden] {
  display: none;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 17px;
  margin-bottom: 14px;
}

.panel {
  background: #ffffff;
  border: 1px solid #d9e0e6;
  border-radius: 8px;
  padding: 18px;
}

.call-panel {
  margin-bottom: 18px;
}

.call-form {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(220px, 1fr) 180px auto;
}

.sip-form {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: 180px minmax(220px, 1fr) auto auto auto;
}

.user-form {
  display: grid;
  gap: 14px;
}

.user-form button {
  justify-self: start;
}

.user-admin-grid {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(320px, 0.85fr) minmax(360px, 1.15fr);
}

.user-editor,
.user-list-panel {
  border: 1px solid #dce3e9;
  border-radius: 8px;
  padding: 14px;
}

.subpanel-title {
  color: #172026;
  font-size: 18px;
  font-weight: 800;
}

.form-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.compact-input {
  min-height: 40px;
  min-width: 220px;
}

.checkbox-label {
  align-items: center;
  display: flex;
  gap: 8px;
  min-height: 40px;
}

.checkbox-label input {
  min-height: auto;
}

.user-admin-panel .list {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.scheduler-form {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(180px, 240px) minmax(200px, 260px) auto;
  margin-bottom: 14px;
}

.scheduler-panel .list {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.download-panel {
  display: grid;
  gap: 14px;
  justify-items: start;
}

.download-panel .scheduler-form {
  margin-bottom: 0;
  width: 100%;
}

.scheduler-user-row {
  background: #fbfcfd;
}

.scheduler-subpanel {
  margin-top: 16px;
}

.user-list-panel .item {
  background: #fbfcfd;
}

.pager {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.pager span {
  color: #4a5560;
  font-size: 13px;
}

label {
  color: #4a5560;
  display: grid;
  font-size: 13px;
  gap: 6px;
}

input,
select {
  border: 1px solid #c7d0d9;
  border-radius: 8px;
  min-height: 40px;
  padding: 0 10px;
}

select[multiple] {
  min-height: 118px;
  padding: 8px 10px;
}

.access-source-select[hidden] {
  display: none;
}

.access-tree {
  border: 1px solid #c7d0d9;
  border-radius: 8px;
  display: grid;
  gap: 6px;
  max-height: 260px;
  overflow: auto;
  padding: 8px;
}

.access-point {
  border: 1px solid #e2e8ee;
  border-radius: 8px;
  overflow: hidden;
}

.access-point-toggle {
  align-items: center;
  background: #f6f8fa;
  color: #172026;
  display: grid;
  gap: 8px;
  grid-template-columns: auto 1fr auto;
  min-height: 38px;
  padding: 0 10px;
  text-align: left;
  width: 100%;
}

.access-point-toggle:hover {
  background: #eef5f5;
}

.access-caret {
  color: var(--color-primary);
  font-size: 14px;
  width: 16px;
}

.access-point-name {
  font-weight: 800;
}

.access-point-summary {
  color: #697683;
  font-size: 12px;
}

.access-point-options {
  display: grid;
  gap: 4px;
  padding: 8px 10px 10px 28px;
}

.access-point-options[hidden] {
  display: none;
}

.access-option {
  align-items: center;
  color: #33414d;
  display: flex;
  flex-direction: row;
  font-size: 13px;
  gap: 8px;
  min-height: 28px;
}

.access-option input {
  min-height: auto;
}

.access-option-all {
  background: #eef5f5;
  border: 1px solid #d2e4e3;
  border-radius: 8px;
  font-weight: 800;
  padding: 8px 10px;
}

.access-empty {
  padding: 8px 2px;
}

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

.pair-overview-panel {
  grid-column: 1 / -1;
}

.operations-grid {
  align-items: stretch;
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr 1fr;
}

.operations-grid > * {
  min-height: 0;
  min-width: 0;
}

.device-zone {
  display: grid;
  gap: 0;
}

.side-stack {
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr;
  min-height: 0;
}

.device-list-panel {
  align-content: start;
  display: grid;
  gap: 14px 12px;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

.console-section > h2,
.console-section > .panel-title-row h2,
.pair-overview-panel > h2,
.device-list-panel > h2,
.device-title-row h2,
.screen-panel .panel-title-row h2 {
  font-size: 24px;
  line-height: 40px;
  margin: 0;
}

.device-list-panel .list {
  display: contents;
  min-height: 0;
}

.device-list-panel .tab-panel {
  display: grid;
  grid-auto-rows: minmax(220px, 1fr);
  grid-column: 1 / -1;
  grid-row: 2;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.device-list-panel .list > .meta {
  grid-column: 1 / -1;
  grid-row: 2;
}

.device-list-panel .item {
  align-content: start;
  overflow: auto;
}

.log-panel {
  margin-top: 18px;
}

.lower-grid {
  margin-top: 18px;
}

.screen-panel {
  margin-top: 18px;
}

.operations-grid .screen-panel {
  margin-top: 0;
}

.screen-panel {
  justify-self: stretch;
  min-width: 0;
  overflow: hidden;
}

.screen-panel.is-maximized {
  bottom: 18px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
  display: grid;
  grid-template-rows: auto auto auto auto auto 1fr;
  left: 18px;
  overflow: auto;
  position: fixed;
  right: 18px;
  top: 18px;
  z-index: 50;
}

.panel-title-row {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
}

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

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

.events-panel .list {
  max-height: 320px;
  overflow: auto;
  padding-right: 4px;
}

.item {
  border: 1px solid #dce3e9;
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 12px;
}

.item-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.item-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

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

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

.call-subpanel[hidden] {
  display: none;
}

.device-primary-actions {
  align-self: start;
  margin-bottom: 2px;
}

.pair-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.pair-tabs button {
  min-height: 40px;
  padding: 0 14px;
}

.device-list-panel .pair-tabs {
  grid-column: 2;
  grid-row: 1;
  justify-content: flex-end;
  margin: 0;
  min-width: 0;
}

.device-title-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.icon-text-button {
  align-items: center;
  display: inline-flex;
  gap: 6px;
  justify-content: center;
  white-space: nowrap;
}

.icon-text-button.is-finger {
  background: var(--color-primary);
}

.tab-panel {
  display: grid;
  gap: 10px;
}

.pair-overview-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.pair-overview-summary span {
  background: #f3f6f8;
  border: 1px solid #dce3e9;
  border-radius: 8px;
  color: #33414d;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 8px 10px;
}

.phone-overview-table-wrap {
  border: 1px solid #dce3e9;
  border-radius: 8px;
  overflow: hidden;
}

.phone-overview-table {
  border-collapse: collapse;
  font-size: 14px;
  table-layout: fixed;
  text-align: center;
  width: 100%;
}

.phone-overview-table th,
.phone-overview-table td {
  border-bottom: 1px solid #e7edf2;
  border-right: 1px solid #e7edf2;
  height: 44px;
  overflow: hidden;
  padding: 7px 8px;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

.phone-overview-table tr:last-child th,
.phone-overview-table tr:last-child td {
  border-bottom: 0;
}

.phone-overview-table th {
  background: #eef3f6;
  color: #33414d;
  font-weight: 800;
  width: 92px;
}

.phone-overview-table td {
  width: calc((100% - 92px) / 12);
}

.phone-overview-table td:nth-child(odd) {
  background: #fbfcfd;
}

.phone-overview-table td:nth-child(even) {
  background: #f5f8fa;
}

.phone-overview-table td.health-warning {
  color: #8a5a00;
  font-weight: 700;
}

.phone-overview-table td.health-fault,
.phone-overview-table td.health-offline {
  color: var(--color-danger);
  font-weight: 700;
}

.phone-overview-table td.health-empty {
  color: #8a96a3;
}

.detail-link {
  align-self: center;
  color: #0284c7;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.detail-link:hover {
  text-decoration: underline;
}

.device-detail-card {
  scroll-margin-top: 18px;
}

.device-detail-card:target {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-focus);
}

.title {
  font-size: 16px;
  font-weight: 700;
}

.badge {
  border-radius: 999px;
  background: #e5f3f3;
  color: #0f5f61;
  font-size: 13px;
  padding: 4px 8px;
}

.badge.offline,
.badge.fault {
  background: #f8e4e4;
  color: var(--color-danger);
}

.badge.warning {
  background: #fff4d6;
  color: #8a5a00;
}

.badge.ok {
  background: #e4f6ec;
  color: #17603a;
}

.meta {
  color: #5c6873;
  font-size: 14px;
  line-height: 1.5;
}

.device-row {
  align-items: center;
  border-top: 1px solid #edf1f4;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
}

.screen-workspace {
  align-items: start;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) 44px;
  justify-content: center;
  margin-top: 12px;
  max-width: 100%;
  width: 100%;
}

.screen-status-row {
  align-items: end;
  display: flex;
  flex: 0 0 2em;
  gap: 8px;
  height: 2em;
  justify-content: space-between;
  max-width: 100%;
  min-height: 2em;
  min-width: 0;
  overflow: hidden;
  width: 100%;
}

#appCallButton {
  min-width: 96px;
}

#screenStatus {
  display: block;
  flex: 1 1 0;
  line-height: 2;
  margin-top: 0;
  max-height: 2em;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.screen-stage {
  aspect-ratio: 9 / 16;
  align-items: center;
  background: #000000;
  border-radius: 8px;
  cursor: crosshair;
  display: flex;
  justify-content: center;
  margin-left: auto;
  margin-right: auto;
  max-width: 100%;
  min-height: 0;
  overflow: hidden;
  position: relative;
  touch-action: none;
  user-select: none;
  width: 100%;
}

.screen-panel.is-maximized .screen-workspace {
  align-items: start;
  grid-template-columns: minmax(0, 1fr) 48px;
  margin-left: auto;
  margin-right: auto;
  width: min(100%, calc((100vh - 190px) * 0.5625 + 58px));
}

.screen-panel.is-maximized .screen-stage {
  width: 100%;
}

.screen-text-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.screen-side-tools {
  display: grid;
  gap: 8px;
  grid-auto-rows: 38px;
}

.screen-side-tools button {
  font-size: 22px;
  line-height: 1;
  min-height: 38px;
  padding: 0;
}

.has-tooltip {
  position: relative;
}

.has-tooltip[title]::after {
  background: var(--color-tooltip);
  border-radius: 6px;
  color: var(--color-button-text);
  content: attr(title);
  font-size: var(--tooltip-font-size);
  font-weight: 700;
  line-height: 1;
  opacity: 0;
  padding: 8px 10px;
  pointer-events: none;
  position: absolute;
  right: calc(100% + 8px);
  top: -8px;
  transition: opacity 120ms ease;
  white-space: nowrap;
  z-index: 5;
}

.has-tooltip[title]:hover::after,
.has-tooltip[title]:focus-visible::after {
  opacity: 1;
}

.screen-mode-indicator {
  background: #e5e7eb;
  color: var(--color-button-text);
  font-size: 20px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  position: absolute;
  right: 10px;
  top: 10px;
  width: 38px;
  z-index: 2;
}

.screen-mode-indicator[hidden] {
  display: none;
}

.screen-mode-indicator::after {
  background: var(--color-tooltip);
  border-radius: 6px;
  color: var(--color-button-text);
  content: attr(data-tooltip);
  font-size: var(--tooltip-font-size);
  font-weight: 700;
  right: calc(100% + 8px);
  line-height: 1;
  opacity: 0;
  padding: 7px 9px;
  pointer-events: none;
  position: absolute;
  top: -8px;
  transition: opacity 120ms ease;
  white-space: nowrap;
}

.screen-mode-indicator:hover::after,
.screen-mode-indicator:focus-visible::after {
  opacity: 1;
}

.radio-group {
  align-items: center;
  border: 1px solid #c7d0d9;
  border-radius: 8px;
  display: flex;
  gap: 16px;
  min-height: 40px;
  padding: 0 10px;
}

.radio-label {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}

.radio-label input {
  min-height: auto;
}

.screen-side-tools .compact-text {
  font-size: 12px;
}

.screen-text-form input {
  flex: 1 1 220px;
}

#screenImage {
  -webkit-user-drag: none;
  display: none;
  height: 100%;
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  width: 100%;
}

#screenPlaceholder {
  color: #d1d5db;
  font-size: 14px;
  padding: 20px;
  text-align: center;
}

.muted {
  color: #65727e;
  font-size: 13px;
  margin-top: 10px;
}

@media (max-width: 760px) {
  .shell {
    padding: 16px;
  }

  .topbar,
  .call-form,
  .sip-form,
  .user-form,
  .user-admin-grid,
  .operations-grid,
  .grid {
    grid-template-columns: 1fr;
  }

  .title-actions {
    align-items: stretch;
    display: grid;
    width: 100%;
  }

  .compact-input {
    min-width: 0;
    width: 100%;
  }

  .screen-stage {
    width: 100%;
  }

  .screen-workspace {
    grid-template-columns: minmax(0, 1fr) 42px;
  }

  .screen-panel.is-maximized {
    bottom: 10px;
    left: 10px;
    right: 10px;
    top: 10px;
  }

  .screen-panel.is-maximized .screen-stage {
    width: 100%;
  }

  .screen-panel.is-maximized .screen-workspace {
    width: min(100%, calc((100vh - 230px) * 0.5625 + 52px));
  }

  .topbar {
    align-items: stretch;
    display: grid;
  }
}
