/* enreach App Studio — design system (extracted from the App Studio mockup). */

:root {
  --accent: #6a2c91;
  --accent-dark: #5a2580;
  --accent-light: #9b4fd0;
  --accent-wash: #f7f1fc;

  --sidebar-bg: #100f16;
  --sidebar-text: #c9c6d6;
  --sidebar-muted: #6e6b7e;

  --page-bg: #f5f5f9;
  --card-bg: #ffffff;
  --text: #1b1b24;
  --text-muted: #9a9aa8;
  --border: #eceaf2;
  --border-strong: #cfcdda;

  --ok-bg: #e4f6ec;
  --ok-fg: #1c7a45;
  --run-bg: #eaf1fb;
  --run-fg: #2160a6;
  --warn-bg: #fff3df;
  --warn-fg: #9a6400;
  --err-bg: #fce6e6;
  --err-fg: #c23a2c;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 3px rgba(16, 15, 22, 0.08);
  --shadow-lg: 0 8px 30px rgba(16, 15, 22, 0.12);

  --font: 'Hanken Grotesk', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', monospace;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--page-bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a {
  color: var(--accent);
}
#app.loading {
  display: grid;
  place-items: center;
  height: 100vh;
  color: var(--text-muted);
}

/* ---------- Login ---------- */
.login {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}
.login-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 32px;
  width: 100%;
  max-width: 380px;
}
.login-brand {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.02em;
  margin-bottom: 2px;
}
.login-brand .accent {
  color: var(--accent);
}
.login-sub {
  color: var(--text-muted);
  margin-bottom: 22px;
}
.login form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- App shell ---------- */
.shell {
  display: grid;
  grid-template-columns: 264px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 6px;
}
.brand-logo {
  height: 30px;
  width: auto;
  display: block;
  align-self: flex-start;
}
.login-logo {
  height: 34px;
  width: auto;
  display: block;
  margin-bottom: 10px;
}
.brand .subtitle {
  font-size: 12px;
  color: var(--sidebar-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  cursor: pointer;
  border: none;
  background: transparent;
  font: inherit;
  font-weight: 600;
  text-align: left;
  width: 100%;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
}
.nav-item.active {
  background: var(--accent);
  color: #fff;
}
.nav-item .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
}
.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.acct {
  padding: 0 6px;
}
.acct .client {
  color: #fff;
  font-weight: 600;
}
.acct .role {
  font-size: 12px;
  color: var(--sidebar-muted);
}
.lang-toggle {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 999px;
  padding: 3px;
  align-self: flex-start;
}
.lang-toggle button {
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.lang-toggle button.on {
  background: #fff;
  color: var(--sidebar-bg);
}

/* ---------- Main ---------- */
.main {
  padding: 32px 40px;
  max-width: 1100px;
}
.page-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
}
.page-sub {
  color: var(--text-muted);
  margin: 4px 0 24px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card + .card {
  margin-top: 16px;
}
.card-title {
  font-weight: 700;
  font-size: 15px;
  margin: 0 0 2px;
}
.card-sub {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 14px;
}
.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.banner {
  background: linear-gradient(120deg, var(--accent), var(--accent-dark));
  color: #fff;
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow);
}
.banner h2 {
  margin: 0 0 4px;
  font-size: 18px;
}
.banner p {
  margin: 0;
  opacity: 0.9;
  max-width: 520px;
}

/* ---------- Pills ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}
.pill.ok {
  background: var(--ok-bg);
  color: var(--ok-fg);
}
.pill.run {
  background: var(--run-bg);
  color: var(--run-fg);
}
.pill.warn {
  background: var(--warn-bg);
  color: var(--warn-fg);
}
.pill.err {
  background: var(--err-bg);
  color: var(--err-fg);
}
.pill.muted {
  background: #f0eff5;
  color: var(--text-muted);
}

/* ---------- Forms / buttons ---------- */
label.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
}
input[type='text'],
input[type='email'],
input[type='password'],
textarea {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  width: 100%;
}
/* Native selects ignore the form styling above; dress them like the inputs and
   draw our own arrow so they match the rest of the portal. */
select {
  font: inherit;
  padding: 10px 36px 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background-color: #fff;
  color: var(--text);
  width: 100%;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%236b6880' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
select:disabled {
  background-color: var(--bg);
  color: var(--text-muted);
  cursor: default;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--accent-light);
  outline-offset: 1px;
  border-color: var(--accent);
}
.btn {
  font: inherit;
  font-weight: 700;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn.primary {
  background: var(--accent);
  color: #fff;
}
.btn.primary:hover {
  background: var(--accent-dark);
}
.btn.ghost {
  background: #fff;
  border-color: var(--border-strong);
  color: var(--text);
}
.btn.ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn.small {
  padding: 7px 12px;
  font-size: 13px;
}

.mono {
  font-family: var(--mono);
  font-size: 12px;
}
.row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.muted {
  color: var(--text-muted);
}
.error-msg {
  color: var(--err-fg);
  font-size: 13px;
}
.notice {
  background: var(--accent-wash);
  border: 1px solid #e6daf2;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: var(--text);
}
/* Where a run has got to. The bar is filled from stages the console actually
   announced — nothing here advances on a timer. */
.progress {
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.stage-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  font-size: 13px;
}
.stage {
  color: var(--text-muted);
  position: relative;
  padding-left: 18px;
}
.stage::before {
  content: '○';
  position: absolute;
  left: 0;
}
.stage.done {
  color: var(--text);
}
.stage.done::before {
  content: '✓';
  color: var(--ok-fg);
}
.stage.active {
  color: var(--accent);
  font-weight: 600;
}
.stage.active::before {
  content: '◍';
}
.stage.failed {
  color: var(--err-fg);
}
.stage.failed::before {
  content: '✗';
}

/* The version a past run shipped, beside its branch — the identifying fact, so it
   reads as normal text rather than as an aside. */
.hist-ver {
  color: var(--text);
  margin-left: 4px;
}

/* Why a past run failed, on its history row — coloured like the warning it is,
   without turning the whole row into a banner. */
.hist-why {
  color: var(--warn-fg);
}

/* A refusal from the store, not the portal's usual accent wash: this one has to
   read as "something is wrong and it is not here". */
.notice.warn-notice {
  background: var(--warn-bg);
  border-color: var(--warn-fg);
  color: var(--warn-fg);
}
.notice.warn-notice .app-meta {
  color: inherit;
  opacity: 0.85;
}

.dropzone-label {
  display: block;
  cursor: pointer;
}
.dropzone {
  display: block;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 18px;
  text-align: center;
  color: var(--text-muted);
  background: #fbfaff;
  transition:
    border-color 0.15s,
    color 0.15s;
}
.dropzone-label:hover .dropzone {
  border-color: var(--accent);
  color: var(--accent);
}
.dropzone.over {
  border-color: var(--accent);
  border-style: solid;
  color: var(--accent);
  background: var(--accent-wash);
}
.dropzone.picked {
  border-style: solid;
  border-color: var(--accent);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
}
.spacer {
  height: 16px;
}
.app-meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* App card header: store artwork beside the name. */
.app-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
/* Reserves its slot before the image loads, so the title never jumps. */
.app-icon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 9px;
  background: var(--border);
  overflow: hidden;
}
.app-icon img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

/* One block per platform on an app card: iOS and Android stay visually separate. */
.plat-block + .plat-block {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.plat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
/* Package ids and bundle ids are long; wrap them instead of overflowing the card. */
.plat-head .mono {
  font-size: 12px;
  overflow-wrap: anywhere;
}

/* ---------- Build & Push wizard ---------- */
.steps {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}
.step {
  display: flex;
  align-items: center;
  gap: 8px;
}
.step-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  background: #edebf3;
  color: var(--text-muted);
}
.step.done .step-dot,
.step.current .step-dot {
  background: var(--accent);
  color: #fff;
}
.step-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}
.step.current .step-label {
  color: var(--text);
}
.step-line {
  flex: 1;
  height: 2px;
  background: #e4e2ec;
  min-width: 24px;
}
.step-line.done {
  background: var(--accent);
}

/* Live versions: one row per fact, so a long Android versionName cannot push the
   badge and the check date onto a line of their own. */
.ver-block + .ver-block {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.ver-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  padding: 3px 0;
}
.ver-label {
  color: var(--text-muted);
  font-size: 12px;
  min-width: 108px;
}
.ver-line .mono {
  overflow-wrap: anywhere;
}

/* iOS and Android are mapped independently — give each its own boxed group so the
   fields cannot be read as one continuous list. */
.plat-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px 14px;
  margin: 0 0 12px;
  min-width: 0;
}
.plat-fieldset legend {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0 6px;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 6px;
  /* No uppercasing: "iOS" and "Android" are names, and it rendered as "IOS". */
}
.plat-icon {
  width: 15px;
  height: 15px;
  fill: currentColor;
  flex: none;
}
/* Wherever a platform is named, the glyph sits with its label. */
.plat-pill,
.plat-name,
.ver-store,
.cred-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.cred-title .plat-icon,
.ver-store .plat-icon {
  color: var(--text-muted);
}

/* Divides the admin panels from each other and from the customer list: three
   kinds of thing on one page, and cards alone did not say so. */
.section-sep {
  height: 1px;
  background: var(--border);
  margin: 18px 2px;
}

/* Portal accounts, listed inside a customer card. */
.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 0;
}
.user-row + .user-row {
  border-top: 1px solid var(--border);
}
.invite-note input {
  font-family: var(--mono);
  font-size: 12px;
}

/* App picker: the dashboard card, made selectable. */
.pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.pick-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 14px;
  cursor: pointer;
  font: inherit;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}
.pick-card:hover {
  border-color: var(--border-strong);
}
.pick-card.selected {
  border-color: var(--accent);
  background: var(--accent-wash);
}
.pick-body {
  min-width: 0;
  flex: 1;
}
.pick-name {
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
}
.pick-plats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.plat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.plat-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fcfbfd;
  padding: 16px;
  cursor: pointer;
  font: inherit;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.plat-card:hover:not(:disabled) {
  border-color: var(--accent-light);
}
.plat-card.selected {
  border-color: var(--accent);
  background: var(--accent-wash);
}
.plat-card:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.plat-card .plat-name {
  font-weight: 700;
}
.check-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: #fff;
  flex: none;
}
.plat-card.selected .check-dot,
.pick-card.selected .check-dot {
  border-color: var(--accent);
  background: var(--accent);
}

.radio-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  font-weight: 600;
}
.radio-row input {
  accent-color: var(--accent);
}
.radio-hint {
  font-weight: 400;
  font-size: 12px;
  color: var(--warn-fg);
}

.recap-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.recap-row:last-of-type {
  border-bottom: none;
}
.recap-row .k {
  color: var(--text-muted);
}

.logbox {
  background: var(--sidebar-bg);
  color: #d6f5e3;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.run-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--accent-wash);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.hist-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.hist-row:last-child {
  border-bottom: none;
}

@media (max-width: 720px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .sidebar-footer {
    margin: 0;
  }
  .main {
    padding: 20px;
  }
}

/* --- credential groups: one band per store ----------------------------------
   Four cards in a row read as one list of eight things. They are two sets of
   credentials for two different stores, and an operator works on one at a time —
   so each store gets a labelled band, and the app name is said once above them
   instead of being repeated in every card title. */
.app-group {
  margin-top: 24px;
}
.app-group-title {
  font-weight: 700;
  font-size: 16px;
  margin: 0 0 4px 2px;
}
.cred-group {
  border-left: 3px solid var(--border);
  padding-left: 14px;
  margin-top: 12px;
}
.cred-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
}
.cred-group-head svg,
.cred-group-head img {
  width: 14px;
  height: 14px;
}
/* The accent is the only colour difference: enough to tell the bands apart at a
   glance, not enough to compete with the cards themselves. */
.cred-group-ios {
  border-left-color: #8e8e93;
}
.cred-group-android {
  border-left-color: #3ddc84;
}
.cred-group .card + .card {
  margin-top: 12px;
}

/* ---------- Monitoring ---------- */
/* A finding is a paragraph, not a table row: what it says matters more than lining
   up, and the detail carries Apple's or Google's own wording at full length. */
.finding {
  border-left: 3px solid var(--border);
  padding: 10px 0 10px 14px;
  margin-top: 12px;
}
.finding.blocked {
  border-left-color: var(--err-fg);
}
.finding.warn {
  border-left-color: var(--warn-fg);
}
.finding-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.finding-title {
  font-weight: 600;
  font-size: 14px;
}
.finding-detail {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}
.finding-meta {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}
.check-row {
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.check-row:first-of-type {
  border-top: 0;
}
.check-name {
  font-weight: 600;
  font-size: 14px;
}
.check-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.muted.small {
  font-size: 12px;
}

/* The sidebar badge. Pushed to the far edge so the menu labels stay left-aligned
   and the number is read as a count rather than as part of the word. */
.nav-badge {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.nav-badge.blocked {
  background: var(--err-fg);
  color: #fff;
}
.nav-badge.warn {
  background: var(--warn-fg);
  color: #fff;
}
/* On the selected entry the accent already carries the colour, so the badge
   borrows the page background instead of competing with it. */
.nav-item.active .nav-badge {
  background: #fff;
  color: var(--accent);
}
