:root {
  color-scheme: light;
  --ink: #17191c;
  --muted: #687078;
  --line: #dfe3e6;
  --surface: #ffffff;
  --canvas: #f4f6f7;
  --soft: #edf1f2;
  --accent: #df2f3a;
  --accent-dark: #b81e29;
  --success: #16784b;
  --warning: #a65b00;
  --danger: #bf2733;
  --info: #246f8c;
  --sidebar: #17191c;
  --sidebar-muted: #aab0b5;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--canvas);
  color: var(--ink);
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.auth-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(320px, 460px) minmax(240px, 1fr);
  align-items: center;
  padding: 40px;
  background: #17191c;
  color: #fff;
}

.auth-brand {
  align-self: start;
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-brand div,
.sidebar-brand div {
  display: grid;
}

.auth-brand strong,
.sidebar-brand strong {
  font-size: 15px;
}

.auth-brand span:last-child,
.sidebar-brand span:last-child {
  color: #aab0b5;
  font-size: 12px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff !important;
  font-weight: 800;
  font-size: 13px !important;
}

.auth-panel {
  grid-column: 2;
  width: 100%;
  padding: 34px;
  background: #fff;
  border: 1px solid #2d3034;
  border-radius: 6px;
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(0,0,0,.35);
}

.auth-heading {
  margin-bottom: 26px;
}

.auth-heading h1 {
  margin: 7px 0 0;
  font-size: 28px;
  line-height: 1.2;
}

.auth-heading p {
  margin: 8px 0 0;
  color: var(--muted);
}

.eyebrow,
.breadcrumb {
  margin: 0;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 18px;
  color: #34383c;
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #cbd1d5;
  border-radius: 4px;
  outline: none;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 88px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--info);
  box-shadow: 0 0 0 3px rgba(36, 111, 140, .12);
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 45px;
}

.password-toggle {
  position: absolute;
  right: 4px;
  top: 4px;
}

.otp-input {
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 8px;
}

.primary-button,
.secondary-button,
.text-button,
.danger-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 4px;
  padding: 9px 14px;
  font-weight: 750;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button {
  border: 1px solid #cbd1d5;
  background: #fff;
  color: var(--ink);
}

.danger-button {
  background: #fae9eb;
  color: var(--danger);
}

.text-button {
  width: 100%;
  margin-top: 7px;
  background: transparent;
  color: var(--info);
}

.text-button.muted {
  color: var(--muted);
}

.text-link {
  padding: 6px 0;
  border: 0;
  background: transparent;
  color: var(--info);
  font-size: 12px;
  font-weight: 700;
}

.icon-button {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 36px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
}

.icon-button:hover {
  background: rgba(127,127,127,.12);
}

svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
}

.form-error {
  min-height: 18px;
  margin: -6px 0 10px;
  color: var(--danger);
  font-size: 12px;
}

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 236px;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: #fff;
}

.sidebar-brand {
  height: 74px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 20px;
  border-bottom: 1px solid #2b2e32;
}

.main-nav {
  display: grid;
  gap: 4px;
  padding: 18px 12px;
}

.main-nav button {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--sidebar-muted);
  text-align: left;
}

.main-nav button:hover,
.main-nav button.active {
  background: #2a2d31;
  color: #fff;
}

.main-nav button.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar-footer {
  margin-top: auto;
  min-height: 74px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #2b2e32;
}

.signed-in {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
}

.signed-in div {
  min-width: 0;
  display: grid;
}

.signed-in strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
}

.signed-in span:last-child {
  color: var(--sidebar-muted);
  font-size: 10px;
}

.avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  flex: 0 0 32px;
  border-radius: 50%;
  background: #e8ecee;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.workspace {
  grid-column: 2;
  min-width: 0;
}

.topbar {
  height: 74px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.topbar h1 {
  margin: 3px 0 0;
  font-size: 19px;
  line-height: 1.1;
}

.topbar-status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(22,120,75,.13);
}

.mobile-menu {
  display: none;
}

.content {
  width: min(1400px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.section-toolbar {
  min-height: 44px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 20px;
}

.section-toolbar > div:first-child {
  margin-right: auto;
}

.section-toolbar h2 {
  margin: 0;
  font-size: 16px;
}

.section-toolbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: var(--surface);
}

.metric {
  min-width: 0;
  min-height: 112px;
  padding: 18px;
  border-right: 1px solid var(--line);
}

.metric:last-child {
  border-right: 0;
}

.metric-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric-value {
  display: block;
  margin-top: 12px;
  font-size: 27px;
  font-weight: 760;
}

.metric-note {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, .7fr);
  gap: 20px;
  margin-top: 20px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--surface);
}

.panel-header {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2 {
  margin: 0;
  font-size: 14px;
}

.panel-header > :last-child {
  margin-left: auto;
}

.panel-header > :last-child + * {
  margin-left: 8px;
}

.pixos-live-panel {
  margin-bottom: 24px;
}

.pixos-live-panel .panel-header {
  gap: 10px;
  min-height: 68px;
  height: auto;
  flex-wrap: wrap;
}

.pixos-live-panel .panel-header h2 {
  margin: 0;
}

.pixos-live-panel .panel-header > div {
  display: grid;
  gap: 2px;
}

.pixos-live-panel .panel-header button {
  min-height: 34px;
  padding: 7px 10px;
}

.pixos-live-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0 18px;
  padding: 0 16px 10px;
}

.pixos-live-grid .key-value {
  grid-template-columns: 1fr;
  align-content: start;
  min-width: 0;
  border-top: 0;
  border-bottom: 1px solid var(--line);
}

.dialog-note {
  margin: -4px 0 18px;
  padding: 10px 11px;
  border-left: 3px solid var(--info);
  background: #edf3f5;
  color: #43535c;
  font-size: 12px;
  line-height: 1.5;
}

.provider-status {
  padding: 18px;
}

.provider-name {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
  font-weight: 750;
}

.provider-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: #edf3f5;
  color: var(--info);
}

.key-value {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.key-value span:first-child {
  color: var(--muted);
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 12px;
}

th,
td {
  height: 48px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  height: 38px;
  background: #f8f9f9;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

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

.cell-main {
  display: grid;
  gap: 2px;
}

.cell-main strong {
  color: var(--ink);
}

.cell-main span,
.mono-muted {
  color: var(--muted);
  font-size: 11px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.badge {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 7px;
  border-radius: 3px;
  background: var(--soft);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.badge.online,
.badge.success,
.badge.paid,
.badge.active,
.badge.completed {
  background: #e6f3ec;
  color: var(--success);
}

.badge.offline,
.badge.failed,
.badge.activation_failed,
.badge.disabled {
  background: #fae9eb;
  color: var(--danger);
}

.badge.degraded,
.badge.pending,
.badge.activation_pending,
.badge.cancelled {
  background: #fff1dc;
  color: var(--warning);
}

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

.item-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(260px, 1fr));
  gap: 14px;
}

.item-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.item-card header {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.item-card header > div:nth-child(2) {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.item-card header strong,
.item-card header span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-card header span {
  color: var(--muted);
  font-size: 11px;
}

.item-card header .badge {
  margin-left: auto;
}

.item-card-body {
  padding: 8px 14px;
}

.item-card footer {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}

.empty-state,
.loading-state {
  min-height: 220px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.loading-state svg {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

dialog {
  width: min(560px, calc(100vw - 28px));
  max-height: calc(100vh - 40px);
  padding: 0;
  border: 0;
  border-radius: 6px;
  box-shadow: 0 24px 80px rgba(0,0,0,.3);
}

dialog::backdrop {
  background: rgba(15,17,19,.65);
}

.dialog-shell header,
.dialog-shell footer {
  display: flex;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.dialog-shell header > button {
  margin-left: auto;
}

.dialog-shell h2 {
  margin: 4px 0 0;
  font-size: 18px;
}

.dialog-fields {
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  padding: 20px 18px 2px;
}

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

.dialog-shell .form-error {
  padding: 0 18px;
}

.toggle-line {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 15px;
  color: var(--ink);
  font-weight: 650;
}

.toggle-line input {
  width: 18px;
  min-height: 18px;
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}

.full-span {
  grid-column: 1 / -1;
}

.toast-region {
  position: fixed;
  z-index: 100;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 8px;
}

.toast {
  min-width: 260px;
  max-width: 380px;
  padding: 12px 14px;
  border-left: 4px solid var(--success);
  background: #fff;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
  font-size: 12px;
}

.toast.error {
  border-color: var(--danger);
}

.sidebar-scrim {
  display: none;
}

@media (max-width: 1060px) {
  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }

  .metric:nth-child(2) {
    border-right: 0;
  }

  .metric:nth-child(-n+2) {
    border-bottom: 1px solid var(--line);
  }

  .item-grid {
    grid-template-columns: repeat(2, minmax(250px, 1fr));
  }

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

@media (max-width: 760px) {
  .auth-view {
    grid-template-columns: 1fr;
    align-content: center;
    gap: 24px;
    padding: 20px;
  }

  .auth-brand,
  .auth-panel {
    grid-column: 1;
  }

  .auth-brand {
    align-self: auto;
  }

  .auth-panel {
    padding: 24px;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    width: min(280px, 82vw);
    transform: translateX(-105%);
    transition: transform .2s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-scrim {
    position: fixed;
    inset: 0;
    z-index: 15;
    display: block;
    border: 0;
    background: rgba(15,17,19,.56);
  }

  .workspace {
    width: 100%;
  }

  .topbar {
    height: 66px;
    padding: 0 14px;
  }

  .mobile-menu {
    display: inline-grid;
  }

  .topbar-status span:last-child {
    display: none;
  }

  .content {
    padding: 18px 14px 30px;
  }

  .section-toolbar {
    flex-wrap: wrap;
  }

  .section-toolbar > div:first-child {
    flex: 1 0 100%;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .item-grid {
    grid-template-columns: 1fr;
  }

  .pixos-live-grid {
    grid-template-columns: 1fr 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .full-span {
    grid-column: auto;
  }
}

@media (max-width: 460px) {
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .metric {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metric:last-child {
    border-bottom: 0;
  }

  .section-toolbar .primary-button,
  .section-toolbar .secondary-button {
    flex: 1;
  }

  .pixos-live-grid {
    grid-template-columns: 1fr;
  }
}
