:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #1c2430;
  --muted: #697586;
  --line: #d7dde5;
  --accent: #1868db;
  --accent-strong: #0f4fb2;
  --danger: #b42318;
  --success: #087443;
  --warning: #9a6700;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
}

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

.login-panel,
.panel,
.list-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(28, 36, 48, 0.08);
}

.login-panel {
  display: grid;
  width: min(420px, 100%);
  gap: 18px;
  padding: 32px;
}

.admin-view {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 18px;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: #111827;
  color: #fff;
  padding: 22px 16px;
}

.brand-block {
  display: grid;
  gap: 4px;
  min-height: 70px;
}

.brand-block .eyebrow {
  color: #8ab4ff;
}

.brand-block strong {
  font-size: 20px;
}

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

.nav-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #cbd5e1;
  padding: 10px 12px;
  text-align: left;
  font-weight: 900;
}

.nav-button:hover,
.nav-button.active {
  background: #ffffff;
  color: #111827;
}

.sidebar .ghost-button {
  border-color: rgba(255, 255, 255, 0.22);
  background: transparent;
  color: #fff;
}

.content-shell {
  display: grid;
  align-content: start;
  gap: 18px;
  min-width: 0;
  padding: 24px;
}

.content-section {
  display: grid;
  gap: 18px;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  min-height: 40px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
}

input:focus,
select:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(24, 104, 219, 0.15);
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 40px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 8px 14px;
  font-weight: 800;
}

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

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

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

.ghost-button {
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.form-message.error {
  color: var(--danger);
}

.form-message.success {
  color: var(--success);
}

.panel {
  padding: 18px;
}

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

.push-panel,
.members-overview {
  display: grid;
  gap: 16px;
}

.push-header,
.section-header,
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.device-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.device-summary > div {
  display: grid;
  gap: 4px;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f9fafb;
}

.device-summary strong {
  font-size: 24px;
}

.device-summary span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.push-grid {
  display: grid;
  grid-template-columns: 140px 140px minmax(220px, 1fr) minmax(280px, 2fr);
  gap: 14px;
}

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

.device-row {
  display: grid;
  grid-template-columns: 86px 1fr 120px 170px;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.device-row strong {
  color: var(--text);
}

.member-toolbar {
  display: grid;
  grid-template-columns: 140px 140px 160px 160px 160px auto;
  align-items: end;
  gap: 12px;
}

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

.member-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

.member-table th,
.member-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

.member-table th {
  background: #f9fafb;
  color: var(--muted);
  font-weight: 900;
}

.mono-cell {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.platform-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--accent);
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 900;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(17, 24, 39, 0.58);
  padding: 20px;
}

.modal-panel {
  display: grid;
  gap: 16px;
  width: min(920px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  border-radius: 8px;
  background: var(--panel);
  padding: 20px;
  box-shadow: 0 24px 60px rgba(17, 24, 39, 0.28);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
}

.wide-field {
  grid-column: span 3;
}

.create-actions {
  display: flex;
  align-items: end;
  gap: 12px;
}

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

.list-panel {
  overflow: hidden;
}

.list-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
}

.product-list {
  display: grid;
}

.product-row {
  display: grid;
  grid-template-columns: 82px 116px minmax(260px, 1fr) 132px 132px 210px 88px;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

.product-row.is-private {
  background: #fff8e5;
}

.product-row.is-deleted {
  background: #fff1f0;
}

.product-id {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.thumb {
  width: 100px;
  height: 100px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f9fafb;
  object-fit: contain;
}

.edit-stack {
  display: grid;
  gap: 8px;
}

.inline-actions {
  display: flex;
  gap: 6px;
}

.small-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 800;
}

.state-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  background: #e9f8f0;
  color: var(--success);
  font-size: 12px;
  font-weight: 900;
}

.state-pill.private {
  background: #fff3c4;
  color: var(--warning);
}

.state-pill.deleted {
  background: #ffe4e0;
  color: var(--danger);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 60px;
  padding: 10px;
}

@media (max-width: 1180px) {
  .create-grid,
  .push-grid,
  .member-toolbar,
  .toolbar,
  .product-row {
    grid-template-columns: 1fr 1fr;
  }

  .wide-field,
  .search-field {
    grid-column: span 2;
  }
}

@media (max-width: 680px) {
  .admin-view {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    grid-template-rows: auto auto auto;
    height: auto;
    border-right: 0;
    padding: 14px;
  }

  .side-nav {
    grid-template-columns: 1fr 1fr;
  }

  .content-shell {
    padding: 14px;
  }

  .topbar,
  .create-actions,
  .inline-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .create-grid,
  .push-grid,
  .member-toolbar,
  .device-summary,
  .device-row,
  .toolbar,
  .product-row {
    grid-template-columns: 1fr;
  }

  .wide-field,
  .search-field {
    grid-column: auto;
  }
}
