:root {
  --ink: #13242c;
  --muted: #5f6f78;
  --line: #d7e2e7;
  --paper: #eef4f6;
  --surface: #ffffff;
  --forest: #087f8c;
  --forest-dark: #0b3d4a;
  --gold: #7a9a01;
  --clay: #b24b32;
  --blue: #235f7a;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(12, 45, 58, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family:
    Inter, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei",
    sans-serif;
  letter-spacing: 0;
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  align-content: center;
  gap: 22px;
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 28px 18px;
}

.login-brand {
  padding: 10px 2px;
}

.login-brand p {
  margin: 14px 0 8px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.login-brand h1 {
  margin: 0 0 10px;
  max-width: 520px;
}

.login-brand span {
  display: block;
  color: var(--muted);
  line-height: 1.65;
}

.login-panel {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.role-entry-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.role-entry {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--forest-dark);
  font-weight: 900;
}

.role-entry.active {
  border-color: var(--forest-dark);
  background: var(--forest-dark);
  color: #fff;
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  width: 260px;
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: #f7fbfc;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--forest-dark);
  color: #eafffb;
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

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

.nav-links {
  display: grid;
  gap: 8px;
}

.nav-links a {
  border-radius: 8px;
  padding: 12px 14px;
  color: #263c45;
  font-weight: 800;
}

.nav-links a:hover,
.nav-links a.active {
  background: #dff1f3;
  color: var(--forest);
}

.project-badge {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
}

.project-badge span,
.metric-card span,
.panel-heading span,
.isolation-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.project-badge strong {
  display: block;
  margin-top: 6px;
  color: var(--forest-dark);
  font-size: 18px;
}

.app-shell {
  min-height: 100vh;
  margin-left: 260px;
  padding: 28px clamp(18px, 4vw, 46px) 46px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(32px, 4vw, 44px);
  line-height: 1.08;
}

h2 {
  margin: 0;
  font-size: 20px;
}

.topbar-actions,
.toolbar,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.status-pill {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.online {
  border-color: rgba(31, 106, 85, 0.32);
  color: var(--forest);
}

.status-pill.offline {
  border-color: rgba(169, 65, 53, 0.32);
  color: var(--danger);
}

.primary-button,
.secondary-button,
.icon-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 900;
  white-space: nowrap;
}

.primary-button {
  background: var(--forest);
  color: #fff;
}

.secondary-button {
  border-color: var(--line);
  background: var(--surface);
  color: var(--forest-dark);
}

.icon-button {
  width: 38px;
  padding: 0;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 22px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.metric-card,
.panel,
.isolation-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 18px;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 34px;
  line-height: 1;
}

.dashboard-grid,
.two-column,
.control-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.9fr);
  gap: 18px;
}

.control-layout {
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.75fr);
  align-items: start;
}

.side-stack {
  display: grid;
  gap: 18px;
}

.panel {
  padding: 18px;
}

.panel-heading {
  margin-bottom: 16px;
}

.toolbar {
  flex-wrap: wrap;
  justify-content: flex-start;
  margin-bottom: 14px;
}

.control-actions {
  display: grid;
  grid-template-columns: 1fr 120px minmax(180px, 1.2fr) auto auto auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.wide-field {
  min-width: 0;
}

label {
  display: grid;
  gap: 7px;
  color: #2d4650;
  font-weight: 800;
}

label span {
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbdbe1;
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

.search-box {
  width: min(420px, 100%);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

td {
  line-height: 1.45;
}

.customer-name strong {
  display: block;
}

.checkbox-cell {
  width: 46px;
}

.checkbox-cell input,
.control-table th input {
  width: 18px;
  height: 18px;
}

.customer-name span,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.tag {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 6px;
  padding: 0 9px;
  background: #e2f3f4;
  color: #155763;
  font-size: 12px;
  font-weight: 900;
}

.tag.high {
  background: #eef6d9;
  color: var(--clay);
}

.tag.due {
  background: #fde9e5;
  color: var(--danger);
}

.task-list,
.stage-list,
.timeline,
.report-list,
.mini-list {
  display: grid;
  gap: 10px;
}

.task-item,
.stage-item,
.timeline-item,
.report-item,
.mini-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #f8fbfc;
}

.task-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.service-task-card {
  align-items: stretch;
  grid-template-columns: minmax(0, 1fr) 138px;
  background: #fbfdfd;
}

.service-card-main {
  display: grid;
  gap: 9px;
  min-width: 0;
}

.priority-kicker {
  width: fit-content;
  border: 1px solid rgba(8, 127, 140, 0.22);
  border-radius: 999px;
  padding: 4px 9px;
  background: #e8f4f5;
  color: var(--forest-dark);
  font-size: 12px;
  font-weight: 900;
}

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

.contact-line {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

.contact-line span,
.ai-block span,
.ai-panel span,
.ai-advice-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.contact-line strong {
  overflow-wrap: anywhere;
  margin: 0;
  font-size: 13px;
}

.ai-block {
  display: grid;
  gap: 4px;
  border-left: 3px solid var(--forest);
  padding: 8px 10px;
  background: #eef7f8;
}

.ai-block strong {
  margin: 0;
  color: var(--forest-dark);
}

.ai-block p,
.ai-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.ai-panel {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(8, 127, 140, 0.22);
  border-radius: 8px;
  padding: 12px;
  background: #f1f8f8;
}

.ai-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ai-panel-heading strong {
  margin: 0;
  color: var(--forest-dark);
}

.ai-advice-grid {
  display: grid;
  gap: 8px;
}

.ai-advice-grid div {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: #fff;
}

.ai-advice-grid strong {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
}

.auto-follow-preview {
  border: 1px solid #d9bd77;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff7e3;
  color: #76510b;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.5;
}

.form-help {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.7;
}

.boss-active {
  border-color: var(--gold);
  background: #f3f7dd;
  color: #4f6600;
}

.boss-action-button {
  min-height: 42px;
  font-size: 14px;
}

.task-actions {
  display: grid;
  align-content: center;
  gap: 8px;
  min-width: 112px;
}

.compact-button {
  min-height: 36px;
  padding: 0 10px;
  font-size: 13px;
}

.compact-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.service-tabs,
.choice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.quick-chip,
.choice-grid button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  background: #fff;
  color: var(--forest-dark);
  font-weight: 900;
}

.quick-chip.active,
.choice-grid button.active {
  border-color: var(--forest);
  background: var(--forest);
  color: #fff;
}

.choice-section {
  display: grid;
  gap: 8px;
}

.choice-section strong,
.task-count-line {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.load-more-button {
  width: 100%;
  margin-top: 12px;
}

.task-item strong,
.timeline-item strong,
.report-item strong,
.mini-item strong {
  display: block;
  margin-bottom: 4px;
}

.mini-item span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.full-button {
  width: 100%;
  margin-top: 10px;
}

.assignment-panel {
  margin-top: 18px;
}

.stage-item {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 42px;
  gap: 12px;
  align-items: center;
}

.stage-bar {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: #dce9ee;
}

.stage-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--forest);
}

.stack-form {
  display: grid;
  gap: 13px;
}

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

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.isolation-grid article {
  padding: 16px;
  box-shadow: none;
}

.isolation-grid strong {
  display: block;
  margin-top: 8px;
  color: var(--forest-dark);
  font-size: 15px;
  overflow-wrap: anywhere;
}

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

.modal::backdrop {
  background: rgba(17, 24, 21, 0.48);
}

.modal-body {
  padding: 20px;
  border-radius: 8px;
  background: var(--surface);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  max-width: min(360px, calc(100vw - 36px));
  transform: translateY(20px);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--forest-dark);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.empty {
  border: 1px dashed #bfd0d8;
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1020px) {
  .sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 12px;
  }

  .nav-links {
    display: flex;
    flex: 1 0 auto;
  }

  .project-badge {
    display: none;
  }

  .app-shell {
    margin-left: 0;
  }

  .metric-grid,
  .dashboard-grid,
  .two-column,
  .control-layout,
  .isolation-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .control-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar,
  .topbar-actions,
  .panel-heading,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .brand small {
    display: none;
  }

  .metric-grid,
  .dashboard-grid,
  .two-column,
  .control-layout,
  .control-actions,
  .form-grid,
  .form-grid.three,
  .isolation-grid {
    grid-template-columns: 1fr;
  }

  .app-shell {
    padding: 18px 12px 32px;
  }

  .task-item,
  .stage-item {
    grid-template-columns: 1fr;
  }

  .service-task-card,
  .contact-grid {
    grid-template-columns: 1fr;
  }

  .task-actions {
    min-width: 0;
  }

  .role-entry-grid {
    grid-template-columns: 1fr;
  }
}
