:root {
  color-scheme: light;
  --ink: #15191e;
  --muted: #68717c;
  --line: #dce1e6;
  --line-strong: #c6cdd5;
  --paper: #f4f6f7;
  --panel: #ffffff;
  --blue: #1769e0;
  --blue-soft: #edf4ff;
  --green: #16835f;
  --green-soft: #e9f7f1;
  --red: #c03245;
  --red-soft: #fff0f2;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  letter-spacing: 0;
}

button, input { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(1040px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--panel);
  border-inline: 1px solid var(--line);
}

.app-header {
  min-height: 62px;
  display: grid;
  grid-template-columns: auto minmax(300px, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255,255,255,.96);
}

.logo-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 19px;
  font-weight: 800;
  border: 0;
  background: transparent;
  padding: 0;
}

.brand-logo {
  display: block;
  width: 132px;
  height: 34px;
  object-fit: contain;
  object-position: left center;
}

.global-command {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}
.global-command input { flex: 1; min-width: 110px; }
.global-command button { white-space: nowrap; padding-inline: 11px; }

.account-menu {
  min-width: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}
.account-menu span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.workspace { padding: 28px 28px 60px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}
.page-head h1 { margin: 3px 0 0; font-size: 26px; line-height: 1.15; }
.eyebrow { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.count { color: var(--muted); font-size: 13px; }

.command-bar,
.relation-fields {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

input {
  min-width: 0;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  padding: 0 11px;
  outline: none;
}
input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23,105,224,.12); }
.command-bar input { flex: 1; }

.primary,
.secondary,
.provider-button,
.google-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 0 14px;
  font-weight: 750;
}
.primary { background: var(--green); color: #fff; }
.secondary { background: #fff; color: var(--ink); border-color: var(--line-strong); }
.primary:hover { background: #106d4e; }
.secondary:hover { background: #f6f8fa; }

.table-wrap {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: auto;
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); }
th { background: #f5f7f8; color: var(--muted); font-size: 11px; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfd; }

.actions-cell { text-align: right; white-space: nowrap; }
.muted-cell { color: var(--muted); }

.record-link,
.text-button {
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 0;
  font-weight: 700;
}
.record-link { display: inline-flex; align-items: center; gap: 8px; text-align: left; }
.text-button + .text-button { margin-left: 10px; }
.text-button:hover, .record-link:hover { text-decoration: underline; }
.danger-text { color: var(--red); }

.record-id {
  display: inline-grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border-radius: 4px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 11px;
  font-weight: 850;
}
.item-id { background: var(--green-soft); color: var(--green); }

.detail-title { display: flex; align-items: center; gap: 12px; }
.detail-title > .record-id { width: 36px; height: 36px; font-size: 14px; }
.detail-name-row,
.inline-name-form,
.detail-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.detail-name-row h1 { margin: 3px 0 0; }
.inline-name-form input { width: min(360px, 54vw); }
.detail-head-actions { justify-content: flex-end; flex-wrap: wrap; }
.opp-detail-link { font-size: 13px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 20px; }
.detail-grid-single { grid-template-columns: minmax(0, 1fr); }
.detail-head { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.opp-category-section {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.opp-category-section > .secondary { justify-self: start; }
.opp-category-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.picker-intro { margin: 0; color: var(--muted); font-size: 13px; }
.opp-picker-table { margin-top: 14px; }

.relation-command { padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.relation-command h2 { margin: 0 0 10px; font-size: 14px; }
.relation-fields .suggestion-field { flex: 1.15; }
.relation-fields > input { flex: 1; }

.suggestion-field { position: relative; min-width: 0; }
.suggestion-field > input { width: 100%; }
.suggestions {
  display: none;
  position: absolute;
  top: 44px;
  left: 0;
  right: 0;
  z-index: 25;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
  box-shadow: 0 12px 26px rgba(25,35,45,.12);
  overflow: hidden;
}
.suggestions.visible { display: grid; }
.suggestions button {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 11px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  text-align: left;
}
.suggestions button:hover { background: var(--blue-soft); }
.suggestions small { color: var(--muted); white-space: nowrap; }

.relation-table { margin-top: 18px; }
.inline-description { width: 100%; min-width: 150px; }
.description-text { color: var(--ink); line-height: 1.45; }
.empty-description { color: var(--muted); font-style: italic; }
.icon-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.icon-button {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--blue);
}
.icon-button:hover { background: var(--blue-soft); }
.icon-button svg { width: 16px; height: 16px; }
.danger-icon { color: var(--red); }
.danger-icon:hover { background: var(--red-soft); }


.alert {
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid;
  border-radius: 5px;
  font-size: 13px;
}
.alert.error { color: var(--red); border-color: #efbdc5; background: var(--red-soft); }
.alert.success { color: var(--green); border-color: #b8dfd0; background: var(--green-soft); }

.empty-state {
  margin-top: 20px;
  padding: 38px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  color: var(--muted);
  text-align: center;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #f4f6f7;
}
.auth-panel {
  width: min(400px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 18px 55px rgba(24,32,42,.09);
}
.auth-panel h1 { margin: 34px 0 8px; font-size: 28px; }
.auth-panel p { margin: 0 0 24px; color: var(--muted); line-height: 1.55; }
.email-auth-form {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}
.email-auth-form label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}
.email-auth-form input {
  width: 100%;
}
.email-auth-form .primary {
  width: 100%;
  justify-content: center;
}
.auth-reset {
  justify-self: center;
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 18px;
  color: var(--muted);
  font-size: 12px;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}
.auth-actions {
  display: grid;
  gap: 10px;
}
.provider-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-color: var(--line-strong);
  background: #fff;
  color: var(--ink);
}
.provider-button:hover { background: #f6f8fa; }
.apple-button {
  border-color: #111;
  background: #111;
  color: #fff;
}
.apple-button:hover { background: #272727; }
.apple-symbol {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 20px;
  line-height: 1;
}
.google-g { color: var(--blue); font-weight: 900; }

@media (max-width: 760px) {
  .app-shell { border: 0; }
  .app-header { grid-template-columns: 1fr auto; padding: 0 14px; }
  .global-command {
    order: 3;
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    padding: 8px 0;
    border-top: 1px solid var(--line);
  }
  .global-command input { width: 100%; min-width: 0; }
  .global-command button { min-height: 36px; padding-inline: 8px; font-size: 12px; }
  .account-menu {
    max-width: 48vw;
    gap: 8px;
  }
  .account-menu span {
    display: block;
    max-width: 24vw;
    font-size: 12px;
  }
  .workspace { padding: 20px 14px 50px; }
  .command-bar { flex-wrap: wrap; }
  .command-bar input { flex: 1 1 100%; }
  .relation-fields {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }
  .relation-fields .suggestion-field,
  .relation-fields > input {
    width: 100%;
    min-width: 0;
  }
  .relation-fields > button {
    white-space: nowrap;
  }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-head { align-items: flex-start; }
  .detail-head-actions { justify-content: flex-start; }
  .inline-name-form input { width: min(250px, 54vw); }
  th, td { padding: 10px 9px; }
  .actions-cell .text-button { display: block; margin: 4px 0; }
  .page-head h1 { font-size: 23px; }
}
