*, *::before, *::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(199, 210, 254, .55), transparent 34rem),
    linear-gradient(180deg, #f8fafc 0%, #ffffff 48%, #eef2ff 100%);
  color: #0f172a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

a {
  color: inherit;
}

.topbar {
  width: min(1200px, calc(100vw - 32px));
  min-height: 78px;
  margin: 0 auto;
  padding: 18px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: transparent;
  color: #0f172a;
  border-bottom: 0;
}

.topbar h1,
.summary h2,
.app-card h2,
.login-panel h1 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 24px;
  line-height: 1.2;
  font-weight: 750;
}

.eyebrow {
  margin: 0 0 3px;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.signout {
  flex: none;
  padding: 9px 13px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  color: #334155;
  background: rgba(255, 255, 255, .78);
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

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

.signout:hover {
  background: #fff;
  border-color: #94a3b8;
}

.shell {
  width: min(1200px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 8px 0 48px;
}

.summary {
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  border: 1px solid #e2e8f0;
  border-radius: 24px;
  background: rgba(255, 255, 255, .86);
  box-shadow: 0 18px 45px rgba(79, 70, 229, .11);
  backdrop-filter: blur(8px);
}

.summary h2 {
  font-size: 24px;
  color: #0f172a;
  font-weight: 750;
}

.summary p {
  margin: 5px 0 0;
  color: #5d6879;
}

.count {
  flex: none;
  min-width: 80px;
  padding: 9px 13px;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 13px;
  font-weight: 850;
  text-align: center;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.app-card {
  min-height: 236px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  border: 1px solid color-mix(in srgb, var(--accent) 58%, #cbd5e1);
  border-radius: 18px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 8%, #fff) 0%, #fff 62%);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--accent) 44%, transparent),
    0 12px 26px rgba(15, 23, 42, .08);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.app-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 78%, #94a3b8);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--accent) 68%, transparent),
    0 18px 34px rgba(79, 70, 229, .13);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 14%, #fff);
  border: 1px solid color-mix(in srgb, var(--accent) 42%, #d7deea);
  color: var(--accent);
  font-weight: 900;
}

.status {
  padding: 4px 10px;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.status.coming-soon {
  background: #f1f3f7;
  color: #687386;
}

.category {
  margin: 16px 0 6px;
  color: #64748b;
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.app-card h2 {
  font-size: 20px;
  color: #0f172a;
  font-weight: 750;
}

.description {
  flex: 1;
  margin: 10px 0 18px;
  color: #4b5668;
  line-height: 1.45;
}

.card-actions {
  display: flex;
}

.open-button {
  height: 38px;
  min-width: 92px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #4f46e5;
  border-radius: 12px;
  background: #4f46e5;
  color: #fff;
  font-weight: 850;
  text-decoration: none;
  box-shadow: 0 10px 22px rgba(79, 70, 229, .25);
}

.open-button:hover {
  background: #4338ca;
}

.open-button.disabled {
  border-color: #d3d9e4;
  background: #f1f3f7;
  color: #687386;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top right, rgba(199, 210, 254, .58), transparent 32rem),
    linear-gradient(180deg, #f8fafc 0%, #fff 48%, #eef2ff 100%);
}

.login-panel {
  width: min(100%, 380px);
  padding: 30px;
  border: 1px solid #e2e8f0;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(79, 70, 229, .14);
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  border-radius: 14px;
  background: #4f46e5;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 12px 24px rgba(79, 70, 229, .28);
}

.login-panel h1 {
  font-size: 22px;
}

.login-panel p {
  margin: 8px 0 22px;
  color: #5d6879;
}

.login-panel label {
  display: block;
  margin: 14px 0 6px;
  color: #344154;
  font-size: 13px;
  font-weight: 700;
}

.login-panel input {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid #c9d2df;
  border-radius: 5px;
  color: #172033;
  font: inherit;
}

.login-panel input:focus {
  outline: 2px solid rgba(47, 111, 237, .18);
  border-color: #2f6fed;
}

.login-panel button {
  width: 100%;
  height: 38px;
  margin-top: 18px;
  border: 0;
  border-radius: 12px;
  background: #4f46e5;
  color: #fff;
  font: inherit;
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(79, 70, 229, .24);
}

.login-panel button:hover {
  background: #4338ca;
}

.error {
  margin: 12px 0 0;
  color: #b42318;
  font-size: 13px;
}

.catalog-editor {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.catalog-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(390px, 1fr));
  gap: 16px;
}

.catalog-card {
  position: relative;
  border: 1px solid color-mix(in srgb, var(--card-accent, #4f46e5) 24%, #e2e8f0);
  border-radius: 18px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--card-accent, #4f46e5) 8%, #fff) 0%, #fff 42%);
  overflow: hidden;
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--card-accent, #4f46e5) 34%, transparent),
    0 12px 26px rgba(15, 23, 42, .08);
}

.catalog-card-head {
  padding: 18px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  border-bottom: 1px solid color-mix(in srgb, var(--card-accent, #4f46e5) 12%, #e6ebf3);
  background: transparent;
}

.catalog-preview {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 42%, #d7deea);
  background: color-mix(in srgb, var(--accent) 14%, #fff);
  color: var(--accent);
  font-size: 15px;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .75);
}

.catalog-card h3 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.catalog-card-head p {
  margin: 5px 0 0;
  color: #687386;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.catalog-card-actions {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 8px;
}

.editor-status {
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.editor-status.available {
  background: #dcfce7;
  color: #166534;
}

.editor-status.coming-soon {
  background: #e2e8f0;
  color: #475569;
}

.catalog-desc {
  min-height: 52px;
  padding: 0 18px 16px;
  color: #475569;
  line-height: 1.45;
  border-bottom: 1px solid #edf1f6;
}

.catalog-fields {
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.catalog-fields .field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.catalog-fields label {
  color: #344154;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .01em;
}

.catalog-fields .field.wide {
  grid-column: 1 / -1;
}

.catalog-fields input,
.catalog-fields select,
.catalog-fields textarea {
  width: 100%;
  min-height: 36px;
  padding: 8px 9px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #172033;
  font: inherit;
  font-weight: 400;
}

.catalog-fields input[type="color"] {
  height: 38px;
  padding: 4px;
  background: #fff;
}

.catalog-fields textarea {
  resize: vertical;
  line-height: 1.4;
}

.catalog-fields input:focus,
.catalog-fields select:focus,
.catalog-fields textarea:focus {
  outline: 2px solid rgba(47, 111, 237, .18);
  border-color: #2f6fed;
}

.icon-action {
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid #c9d2df;
  background: #fff;
  color: #344154;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.icon-action.danger {
  color: #b42318;
  border-color: #efc3bf;
  background: #fff7f6;
}

.add-app-button {
  height: 38px;
  padding: 0 14px;
  border: 1px solid #4f46e5;
  border-radius: 12px;
  background: #4f46e5;
  color: #fff;
  font: inherit;
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(79, 70, 229, .22);
}

.advanced-json {
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 12px 26px rgba(15, 23, 42, .06);
}

.advanced-json summary {
  padding: 13px 14px;
  cursor: pointer;
  color: #172033;
  font-weight: 850;
  background: #f8fafc;
  border-bottom: 1px solid #e6ebf3;
}

.advanced-json p {
  margin: 12px 14px 0;
  color: #687386;
}

.advanced-json textarea {
  display: block;
  width: 100%;
  min-height: 360px;
  margin-top: 12px;
  padding: 16px;
  border: 0;
  border-top: 1px solid #e6ebf3;
  resize: vertical;
  color: #172033;
  background: #fbfcff;
  font: 13px/1.45 "Menlo", "Consolas", "Courier New", monospace;
}

.advanced-json textarea:focus {
  outline: 2px solid rgba(47, 111, 237, .2);
  outline-offset: -2px;
}

.editor-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 12px 26px rgba(15, 23, 42, .06);
}

.editor-actions button,
.secondary-link {
  height: 36px;
  min-width: 92px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  font-weight: 850;
  text-decoration: none;
}

.editor-actions button {
  border: 1px solid #4f46e5;
  background: #4f46e5;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 850;
  box-shadow: 0 10px 22px rgba(79, 70, 229, .22);
}

.secondary-link {
  border: 1px solid #c9d2df;
  color: #344154;
  background: #fff;
}

.notice {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 5px;
  font-weight: 700;
}

.notice.ok {
  border: 1px solid #b8dfc3;
  background: #edf9f0;
  color: #087a2f;
}

.notice.err {
  border: 1px solid #f0c0bc;
  background: #fff0ef;
  color: #b42318;
}

/* Shared surfaces for the built-in network tools. Keeping colors here instead
   of inline in templates allows the complete result UI to follow dark mode. */
.tool-results-stack,
.tool-results-single,
.mac-tools-grid {
  margin-top: 2rem;
}

.tool-results-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.mac-tools-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  align-items: start;
}

.tool-panel {
  min-width: 0;
  padding: 1.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 24px;
  background: #fff;
  color: #172033;
  box-shadow: 0 12px 26px rgba(15, 23, 42, .08);
}

.tool-panel h3 {
  margin: 0;
  color: #0f172a;
  font-size: 18px;
}

.tool-panel h4 {
  color: #1e293b;
}

.table-scroll,
.history-scroll {
  overflow: auto;
}

.tool-table,
.history-table {
  width: 100%;
  border-collapse: collapse;
}

.tool-table {
  margin-top: 1rem;
}

.tool-table th,
.tool-table td {
  padding: 12px;
  border-bottom: 1px solid #edf1f6;
  text-align: left;
  vertical-align: top;
}

.tool-table th {
  width: 200px;
  color: #64748b;
  font-weight: 750;
}

.tool-table.compact th,
.tool-table.compact td {
  padding: 10px 0;
  font-size: 13px;
}

.tool-table.compact th {
  width: 140px;
}

.mono {
  font-family: "Menlo", "Consolas", "Courier New", monospace;
  overflow-wrap: anywhere;
}

.code-panel,
.binary-panel,
.value-list li {
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #334155;
}

.code-panel {
  margin: 1rem 0 0;
  padding: 1.5rem;
  border-radius: 12px;
  overflow-x: auto;
  font: 13px/1.5 "Menlo", "Consolas", "Courier New", monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.review-section {
  margin-top: 1.5rem;
}

.review-section h4 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding-bottom: 8px;
  border-bottom: 2px solid #f1f5f9;
  font-size: 16px;
}

.status-dot {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 50%;
}

.status-dot.ok { background: #10b981; }
.status-dot.warn { background: #f59e0b; }
.status-dot.err { background: #ef4444; }

.review-content {
  padding: 10px 0;
}

.value-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.value-list li {
  margin-bottom: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  font: 13px/1.45 "Menlo", "Consolas", "Courier New", monospace;
  word-break: break-word;
}

.review-note {
  margin: 8px 0 0;
  color: #64748b;
  font-size: 12px;
  font-style: italic;
}

.binary-panel {
  margin-top: 1.5rem;
  padding: 1rem;
  border-radius: 12px;
}

.binary-panel h4 {
  margin: 0 0 10px;
  color: #64748b;
  font-size: 14px;
  text-transform: uppercase;
}

.binary-values {
  overflow-x: auto;
  font: 13px/1.6 "Menlo", "Consolas", "Courier New", monospace;
}

.binary-values > div {
  display: flex;
  gap: 10px;
  min-width: max-content;
}

.binary-values > div > span:first-child {
  width: 80px;
  color: #64748b;
}

.binary-values hr {
  height: 1px;
  margin: 5px 0;
  border: 0;
  background: #cbd5e1;
}

.binary-values .binary-network,
.binary-values .binary-network > span:first-child {
  color: #4f46e5;
  font-weight: 750;
}

.format-results {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #edf1f6;
}

.format-results h4 {
  margin: 0 0 10px;
}

.history-scroll {
  max-height: 500px;
}

.history-table {
  font-size: 12px;
}

.history-table th,
.history-table td {
  padding: 8px 4px;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
}

.history-table th {
  color: #64748b;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.history-vendor { font-weight: 600; }
.history-mac { color: #4f46e5; }
.history-note { color: #64748b; }

.empty-state {
  margin-top: 1rem;
  color: #64748b;
  font-style: italic;
}

@media (prefers-color-scheme: dark) {
  html {
    color-scheme: dark;
  }

  body {
    background:
      radial-gradient(circle at top right, rgba(67, 56, 202, .45), transparent 34rem),
      linear-gradient(180deg, #0f172a 0%, #111827 48%, #0f172a 100%);
    color: #e5e7eb;
  }

  .topbar,
  .topbar h1,
  .summary h2,
  .app-card h2,
  .catalog-card h3,
  .login-panel h1 {
    color: #f8fafc;
  }

  .eyebrow,
  .summary p,
  .category,
  .catalog-card-head p,
  .advanced-json p {
    color: #94a3b8;
  }

  .signout,
  .secondary-link {
    border-color: #334155;
    background: rgba(15, 23, 42, .72);
    color: #e2e8f0;
  }

  .signout:hover,
  .secondary-link:hover {
    background: #1e293b;
    border-color: #64748b;
  }

  .summary,
  .login-panel,
  .advanced-json,
  .editor-actions {
    border-color: #334155;
    background: rgba(30, 41, 59, .86);
    box-shadow: 0 20px 48px rgba(2, 6, 23, .45);
  }

  .count {
    border-color: #4f46e5;
    background: rgba(49, 46, 129, .55);
    color: #c7d2fe;
  }

  .app-card {
    border-color: color-mix(in srgb, var(--accent) 78%, #334155);
    background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 10%, #1e293b) 0%, #172033 72%);
    box-shadow:
      inset 0 0 0 1px color-mix(in srgb, var(--accent) 80%, transparent),
      0 18px 36px rgba(2, 6, 23, .38);
  }

  .app-card:hover {
    border-color: color-mix(in srgb, var(--accent) 92%, #64748b);
    box-shadow:
      inset 0 0 0 1px color-mix(in srgb, var(--accent) 92%, transparent),
      0 24px 44px rgba(2, 6, 23, .48);
  }

  .description,
  .catalog-desc {
    color: #cbd5e1;
  }

  .app-icon,
  .catalog-preview {
    background: color-mix(in srgb, var(--accent) 20%, #1e293b);
    border-color: color-mix(in srgb, var(--accent) 70%, #334155);
  }

  .status.coming-soon,
  .editor-status.coming-soon {
    background: rgba(51, 65, 85, .9);
    color: #cbd5e1;
  }

  .open-button.disabled {
    border-color: #475569;
    background: #1e293b;
    color: #94a3b8;
  }

  .login-page {
    background:
      radial-gradient(circle at top right, rgba(67, 56, 202, .45), transparent 32rem),
      linear-gradient(180deg, #0f172a 0%, #111827 48%, #0f172a 100%);
  }

  .login-panel input,
  .catalog-fields input,
  .catalog-fields select,
  .catalog-fields textarea,
  .advanced-json textarea {
    border-color: #334155;
    background: #0f172a;
    color: #e2e8f0;
  }

  .login-panel label,
  .catalog-fields label {
    color: #cbd5e1;
  }

  .catalog-card {
    border-color: color-mix(in srgb, var(--card-accent, #4f46e5) 72%, #334155);
    background: linear-gradient(90deg, color-mix(in srgb, var(--card-accent, #4f46e5) 10%, #1e293b) 0%, #172033 72%);
    box-shadow:
      inset 0 0 0 1px color-mix(in srgb, var(--card-accent, #4f46e5) 78%, transparent),
      0 18px 36px rgba(2, 6, 23, .38);
  }

  .catalog-card-head,
  .catalog-desc {
    border-color: #334155;
  }

  .icon-action,
  .advanced-json summary {
    border-color: #334155;
    background: #1e293b;
    color: #e2e8f0;
  }

  .icon-action.danger {
    border-color: #7f1d1d;
    background: rgba(127, 29, 29, .22);
    color: #fecaca;
  }

  .notice.ok {
    border-color: #166534;
    background: rgba(22, 101, 52, .22);
    color: #bbf7d0;
  }

  .notice.err {
    border-color: #7f1d1d;
    background: rgba(127, 29, 29, .24);
    color: #fecaca;
  }

  .tool-panel {
    border-color: #334155;
    background: rgba(30, 41, 59, .9);
    color: #e2e8f0;
    box-shadow: 0 20px 42px rgba(2, 6, 23, .4);
  }

  .tool-panel h3,
  .tool-panel h4 {
    color: #f8fafc;
  }

  .tool-table th,
  .tool-table td,
  .history-table th,
  .history-table td,
  .format-results,
  .review-section h4 {
    border-color: #334155;
  }

  .tool-table th,
  .history-table th,
  .review-note,
  .history-note,
  .empty-state,
  .binary-panel h4,
  .binary-values > div > span:first-child {
    color: #94a3b8;
  }

  .code-panel,
  .binary-panel,
  .value-list li {
    border-color: #334155;
    background: #0f172a;
    color: #e2e8f0;
  }

  .binary-values hr {
    background: #475569;
  }

  .binary-values .binary-network,
  .binary-values .binary-network > span:first-child,
  .history-mac {
    color: #a5b4fc;
  }
}

@media (max-width: 620px) {
  .topbar {
    padding: 12px 16px;
  }

  .topbar h1 {
    font-size: 19px;
  }

  .shell {
    width: min(100vw - 20px, 1180px);
    padding-top: 18px;
  }

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

  .catalog-list,
  .catalog-fields {
    grid-template-columns: 1fr;
  }

  .mac-tools-grid {
    grid-template-columns: 1fr;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .count {
    width: 100%;
  }
}
