:root {
  --bg: #f6f7f8;
  --surface: #ffffff;
  --surface-muted: #f3f5f6;
  --text: #172026;
  --muted: #66727a;
  --line: #dfe5e8;
  --accent: #d94f28;
  --green: #19765b;
  --blue: #285f9d;
  --red: #a73525;
}

* {
  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;
}

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

.is-logged-out .login-screen {
  display: grid;
}

.is-logged-out .app-shell {
  display: none;
}

.is-logged-in .login-screen {
  display: none;
}

.login-card {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.login-card button[type="submit"] {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.login-brand {
  margin-bottom: 4px;
  color: var(--text);
}

.login-brand span {
  color: var(--muted);
}

.demo-logins {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.86rem;
}

.demo-logins strong {
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #172026;
  color: #fff;
  padding: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  font-weight: 800;
}

.brand span {
  display: block;
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.86rem;
}

.role-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  margin-bottom: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
}

.role-button,
.nav-item {
  border: 0;
  border-radius: 7px;
}

.role-button {
  min-height: 36px;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
}

.role-button.active {
  background: #fff;
  color: var(--text);
}

.customer-preview {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.88rem;
  font-weight: 700;
}

.customer-preview {
  display: none;
}

.customer-preview select {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.customer-preview option {
  color: var(--text);
}

.is-manager .customer-preview {
  display: none;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  min-height: 42px;
  padding: 0 12px;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.main {
  padding: 26px;
  overflow-x: hidden;
}

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

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.eyebrow,
.section-header p,
.metric span,
.account-meta,
.task-meta,
.empty-state,
.request-row span,
.due-text {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 5px;
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 0.75rem;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
}

h2 {
  margin-bottom: 4px;
  font-size: 1.08rem;
}

.ghost-button,
.small-button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
}

.modal {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.modal::backdrop {
  background: rgba(23, 32, 38, 0.52);
}

.modal-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 60px rgba(23, 32, 38, 0.22);
}

.modal-card header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

.modal-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 1.04rem;
}

.modal-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric,
.panel,
.account-card,
.task-card,
.customer-card,
.community-card,
.process-step,
.task-form,
.form-grid,
.filters-bar,
.request-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric {
  padding: 16px;
}

.metric span {
  display: block;
  margin-bottom: 8px;
  font-size: 0.86rem;
}

.metric strong {
  font-size: 1.9rem;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.55fr);
  gap: 16px;
}

.panel,
.task-form,
.form-grid,
.filters-bar {
  padding: 16px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

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

.process-step {
  padding: 16px;
}

.process-step span {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  margin-bottom: 12px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.process-step strong {
  display: block;
  margin-bottom: 7px;
}

.process-step p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.48;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.form-grid.flat {
  margin-bottom: 12px;
  padding: 0;
  border: 0;
}

.filters-bar {
  display: grid;
  grid-template-columns: 170px 170px minmax(240px, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.task-form {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.chain-panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.competitor-panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff8f6;
}

.mode-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.mode-toggle label,
.compliance-check {
  display: flex;
  align-items: center;
  gap: 9px;
}

.mode-toggle input,
.compliance-check input {
  width: auto;
}

label,
fieldset {
  display: grid;
  gap: 7px;
  color: #303b42;
  font-size: 0.92rem;
  font-weight: 750;
}

fieldset {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

legend {
  padding: 0 8px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
}

textarea {
  resize: vertical;
  min-height: 110px;
}

form button[type="submit"] {
  align-self: end;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.account-list,
.task-list,
.customer-list,
.community-list {
  display: grid;
  gap: 10px;
}

.account-card,
.task-card,
.customer-card,
.community-card {
  padding: 14px;
}

.account-card header,
.task-card header,
.customer-card header,
.community-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.request-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 13px 14px;
}

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

.request-row strong {
  margin-bottom: 4px;
}

.row-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.pill-row,
.chain-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: #3b473f;
  font-size: 0.8rem;
  font-weight: 800;
}

.pill.active,
.pill.scheduled {
  background: #e9f5f0;
  color: var(--green);
}

.pill.posted,
.pill.in-progress {
  background: #e8f0fa;
  color: var(--blue);
}

.pill.resting,
.pill.requested {
  background: #fff4e7;
  color: #8a4d12;
}

.pill.paused,
.pill.need-info,
.pill.priority-high {
  background: #fcebea;
  color: var(--red);
}

.pill.mode-competitor-response {
  background: #fff1ed;
  color: #a23c20;
}

.pill.priority-low {
  background: #eef2f3;
  color: #53616a;
}

.task-body {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.52;
}

.task-actions {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto auto;
  gap: 8px;
  align-items: start;
}

.inline-form.single {
  grid-template-columns: 1fr;
}

.inline-form textarea {
  min-height: 76px;
}

.small-button.danger {
  color: var(--red);
}

.task-copy {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.task-copy h3 {
  margin: 0 0 5px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--muted);
}

.task-copy p {
  margin: 0 0 12px;
  white-space: pre-wrap;
  line-height: 1.52;
}

.task-copy p:last-child {
  margin-bottom: 0;
}

.task-copy a {
  color: var(--blue);
  overflow-wrap: anywhere;
}

.chain-list {
  display: grid;
  gap: 7px;
  margin: 0 0 12px;
  padding-left: 22px;
  line-height: 1.52;
}

.chain-list li {
  padding-left: 4px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-muted);
  font-weight: 650;
}

.checkbox-grid input {
  width: auto;
}

.empty-state {
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.65);
}

.is-customer .manager-only {
  display: none;
}

@media (max-width: 920px) {
  .app-shell,
  .metrics-grid,
  .split-layout,
  .form-grid,
  .filters-bar,
  .process-grid,
  .inline-form,
  .request-row {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

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

  .row-meta {
    justify-content: space-between;
  }
}
