:root {
  color-scheme: dark;
  --bg: #0d0f12;
  --surface: #15181d;
  --surface-2: #1b1f26;
  --surface-3: #232833;
  --text: #f6f7fb;
  --muted: #9ba3b2;
  --soft: #c7cedb;
  --line: #2d3440;
  --accent: #e11d48;
  --accent-2: #fb7185;
  --green: #22c55e;
  --amber: #f59e0b;
}

* {
  box-sizing: border-box;
}

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

h1, h2, h3, h4, p, dl, dd {
  margin: 0;
}

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(225, 29, 72, 0.16), transparent 36%),
    radial-gradient(circle at 80% 10%, rgba(251, 113, 133, 0.10), transparent 32%),
    var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  background: rgba(21, 24, 29, 0.94);
  border-radius: 8px;
  padding: 32px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
}

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 900;
  letter-spacing: 0;
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  font-size: 14px;
}

.login-panel h1 {
  margin-top: 22px;
  font-size: 30px;
  line-height: 1.1;
}

.login-panel p {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.55;
}

.button, button {
  border: 1px solid var(--line);
  background: var(--surface-3);
  color: var(--text);
  border-radius: 6px;
  padding: 10px 14px;
  text-decoration: none;
}

.button.primary,
.login-button {
  display: inline-flex;
  justify-content: center;
  width: 100%;
  margin-top: 24px;
  border-color: var(--accent);
  background: var(--accent);
  font-weight: 800;
}

.phone-login-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.phone-login-form button,
.account-form button {
  border-color: var(--accent);
  background: var(--accent);
  font-weight: 800;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  border-right: 1px solid var(--line);
  background: #101318;
  padding: 22px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-row h1 {
  font-size: 18px;
}

.brand-row p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.side-nav {
  display: grid;
  gap: 8px;
  margin-top: 34px;
}

.side-nav button,
#logout {
  width: 100%;
  text-align: left;
  border-color: transparent;
  background: transparent;
  color: var(--soft);
}

.side-nav button:hover,
#logout:hover {
  background: var(--surface-2);
}

.side-nav button.active {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent);
}

.workspace {
  min-width: 0;
  padding: 26px clamp(18px, 3vw, 38px);
}

.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.workspace-header h2 {
  font-size: clamp(24px, 3vw, 34px);
}

.workspace-header p {
  margin-top: 5px;
  color: var(--muted);
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(80px, 1fr));
  gap: 8px;
  min-width: min(520px, 100%);
}

.status-strip div {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 10px 12px;
}

dt {
  color: var(--muted);
  font-size: 12px;
}

dd {
  margin-top: 3px;
  font-size: 18px;
  font-weight: 800;
}

.view {
  display: none;
  margin-top: 20px;
}

.view.active {
  display: block;
}

.character-layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.business-layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.list-panel,
.detail-panel,
.panel {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
}

.list-panel {
  overflow: hidden;
}

.list-header {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.list-header h3,
.panel h3 {
  font-size: 16px;
}

input, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #0f1217;
  color: var(--text);
  border-radius: 6px;
  padding: 11px 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.18);
}

.character-list {
  max-height: calc(100vh - 210px);
  overflow: auto;
}

.character-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 0;
  padding: 13px 16px;
  text-align: left;
}

.character-row:hover,
.character-row.active {
  background: #20252d;
}

.character-row strong,
.character-row small {
  display: block;
}

.character-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.money-pill {
  flex: 0 0 auto;
  border: 1px solid rgba(34, 197, 94, 0.25);
  background: rgba(34, 197, 94, 0.10);
  color: #86efac;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}

.detail-panel {
  min-height: calc(100vh - 166px);
  padding: 18px;
}

.empty-detail,
.empty-state {
  color: var(--muted);
  padding: 18px;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.detail-header h3 {
  margin-top: 4px;
  font-size: 26px;
}

.detail-header span {
  display: inline-block;
  margin-top: 5px;
  color: var(--muted);
}

.balance-box {
  min-width: 130px;
  border: 1px solid rgba(34, 197, 94, 0.24);
  background: rgba(34, 197, 94, 0.10);
  border-radius: 8px;
  padding: 12px;
  text-align: right;
}

.balance-box span {
  margin: 0;
  color: #86efac;
  font-size: 12px;
}

.balance-box strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.detail-card {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 14px;
}

.detail-card h4,
.data-section h4 {
  margin-bottom: 12px;
  font-size: 14px;
}

.detail-card div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.detail-card div:first-of-type {
  border-top: 0;
}

.detail-card span {
  color: var(--muted);
}

.detail-card strong {
  min-width: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.job-editor-card {
  border-color: rgba(225, 29, 72, 0.42);
  background: linear-gradient(180deg, rgba(225, 29, 72, 0.10), var(--surface-2));
}

.character-job-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px;
  gap: 10px;
}

.job-offer-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.character-job-form label,
.job-offer-form label {
  color: var(--muted);
}

.character-job-form button,
.job-offer-form button,
.wide-field {
  grid-column: 1 / -1;
}

.character-job-form button,
.job-offer-form button {
  border-color: var(--accent);
  background: var(--accent);
  font-weight: 800;
}

.direct-job-card {
  border-color: rgba(245, 158, 11, 0.34);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.08), var(--surface-2));
}

.business-access-card {
  border-color: rgba(34, 197, 94, 0.34);
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.08), var(--surface-2));
}

.inline-result {
  min-height: 18px;
  margin-top: 10px;
  color: var(--soft);
  font-size: 13px;
}

.data-section {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

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

.vehicle-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 6px;
  padding: 10px 12px;
}

.vehicle-row span,
.muted {
  color: var(--muted);
}

.inventory-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inventory-list span {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--soft);
  font-size: 13px;
}

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

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

.offer-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 6px;
  padding: 10px 12px;
}

.offer-row strong,
.offer-row span {
  display: block;
}

.offer-row span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.offer-row mark {
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(155, 163, 178, 0.14);
  color: var(--soft);
  font-size: 12px;
  font-weight: 800;
  text-transform: capitalize;
}

.offer-row .status-accepted {
  background: rgba(34, 197, 94, 0.14);
  color: #86efac;
}

.offer-row .status-declined,
.offer-row .status-cancelled {
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
}

.offer-row .status-pending {
  background: rgba(245, 158, 11, 0.16);
  color: #fcd34d;
}

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

pre {
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  background: #0f1217;
  border-radius: 6px;
  padding: 12px;
  color: var(--soft);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.panel {
  padding: 18px;
}

.tool-form {
  display: grid;
  grid-template-columns: 130px minmax(220px, 1fr) 120px auto;
  gap: 12px;
  align-items: end;
  margin-top: 16px;
}

.account-panel {
  max-width: 720px;
}

.account-panel .muted {
  margin-top: 8px;
}

.account-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
  margin-top: 16px;
}

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

.tool-form button {
  border-color: var(--accent);
  background: var(--accent);
  font-weight: 800;
}

.tool-result {
  margin-top: 12px;
  color: var(--soft);
}

.logs {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.log-row {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 12px;
}

.log-row div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.log-row time,
.log-row span {
  color: var(--muted);
  font-size: 12px;
}

.log-row p {
  margin: 8px 0 4px;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
  }

  .side-nav {
    display: flex;
    flex-wrap: wrap;
    margin-top: 18px;
  }

  #logout {
    width: auto;
  }

  .workspace-header,
  .character-layout,
  .business-layout,
  .business-columns {
    grid-template-columns: 1fr;
  }

  .workspace-header {
    display: grid;
  }

  .status-strip {
    min-width: 0;
  }

  .character-list {
    max-height: 420px;
  }
}

@media (max-width: 720px) {
  .sidebar,
  .workspace {
    padding: 16px;
  }

  .sidebar {
    display: grid;
  }

  .status-strip,
  .detail-grid,
  .split,
  .tool-form,
  .account-form {
    grid-template-columns: 1fr;
  }

  .detail-header,
  .vehicle-row {
    display: grid;
  }

  .balance-box {
    text-align: left;
  }
}
