:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #eef5f3;
  --ink: #15201f;
  --muted: #6d7a78;
  --line: #dce4e2;
  --line-strong: #c4d0cd;
  --green: #0f8f6d;
  --green-dark: #087051;
  --green-soft: #dff5ed;
  --amber: #b56a0a;
  --amber-soft: #fff3d8;
  --red: #ba3d3d;
  --red-soft: #fde8e8;
  --blue: #2d6cdf;
  --blue-soft: #e7efff;
  --nav: #172322;
  --nav-soft: #243230;
  --shadow: 0 14px 35px rgba(21, 32, 31, 0.08);
  --radius: 8px;
  font-family: "Inter", "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 14px;
  color: #eaf4f2;
  background: var(--nav);
}

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

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

.brand small {
  margin-top: 2px;
  color: #a9b9b6;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #1fb58d;
  color: #06231a;
  font-weight: 800;
}

.brand-mark.big {
  width: 52px;
  height: 52px;
  margin-bottom: 12px;
  font-size: 20px;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  color: #cfe0dd;
  background: transparent;
  text-align: left;
}

.nav-item svg,
.icon-button svg,
.primary-btn svg,
.ghost-btn svg,
.danger-btn svg,
.upload-btn svg,
.search svg,
.alert-line svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
  flex: 0 0 auto;
}

.nav-item:hover,
.nav-item.active {
  background: var(--nav-soft);
  color: #ffffff;
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: #b7c7c4;
  font-size: 13px;
}

.safe-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.14);
}

.main {
  min-width: 0;
  padding: 24px;
}

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

.topbar h1,
.surface h2,
.dialog-card h2,
.login-panel h1 {
  margin: 0;
  color: var(--ink);
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 25px;
}

.surface h2,
.dialog-card h2 {
  font-size: 17px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search {
  width: min(360px, 38vw);
  height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.icon-button,
.primary-btn,
.ghost-btn,
.danger-btn,
.upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
}

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

.primary-btn {
  padding: 0 14px;
  border-color: var(--green-dark);
  background: var(--green);
  color: #fff;
  font-weight: 700;
}

.primary-btn:hover {
  background: var(--green-dark);
}

.primary-btn.wide {
  width: 100%;
}

.ghost-btn,
.upload-btn {
  padding: 0 12px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.danger-btn {
  padding: 0 12px;
  border-color: #efc7c7;
  background: var(--red-soft);
  color: var(--red);
}

.upload-btn input {
  display: none;
}

.alert-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid #cde8dd;
  border-radius: 8px;
  background: #f0fbf6;
  color: #24413b;
}

.content-view {
  display: none;
}

.content-view.active {
  display: block;
}

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

.metric-card,
.surface {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.metric-card {
  min-height: 112px;
  padding: 16px;
}

.metric-card .metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
}

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

.metric-card small {
  display: block;
  margin-top: 9px;
  color: var(--muted);
}

.surface {
  padding: 16px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.85fr);
  gap: 12px;
  margin-bottom: 12px;
}

.dashboard-grid.compact {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

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

.account-tile {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.account-tile-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.account-tile h3,
.product-card h3,
.asset-card h3,
.message-item h3,
.task-card h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
}

.tile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.pill,
.status,
.priority {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #eef2f5;
  color: #47515a;
}

.status.ok {
  background: var(--green-soft);
  color: var(--green-dark);
}

.status.watch {
  background: var(--amber-soft);
  color: var(--amber);
}

.status.rest,
.priority.high {
  background: var(--red-soft);
  color: var(--red);
}

.priority.medium {
  background: var(--amber-soft);
  color: var(--amber);
}

.priority.low {
  background: var(--blue-soft);
  color: var(--blue);
}

.health-bar {
  height: 8px;
  margin-top: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: #e5ecea;
}

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

.task-stack,
.message-list,
.review-list {
  display: grid;
  gap: 8px;
}

.task-row,
.message-item,
.review-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.task-row:first-child,
.message-item:first-child,
.review-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.task-row p,
.message-item p,
.review-item p,
.product-card p,
.asset-card p {
  margin: 4px 0 0;
  color: var(--muted);
}

.pipeline-mini {
  display: grid;
  gap: 10px;
}

.pipeline-mini-row {
  display: grid;
  grid-template-columns: 70px 1fr 38px;
  align-items: center;
  gap: 8px;
}

.mini-track {
  height: 9px;
  border-radius: 999px;
  background: #e7eceb;
  overflow: hidden;
}

.mini-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.segmented button {
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.segmented button.active {
  background: var(--green-soft);
  color: var(--green-dark);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.data-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  color: #5e6b69;
  background: #f8faf9;
  font-size: 12px;
}

.row-actions {
  display: inline-flex;
  gap: 6px;
}

.row-actions button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
}

.pipeline-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 12px;
  overflow-x: auto;
}

.pipeline-col {
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.pipeline-col-head {
  display: flex;
  justify-content: space-between;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.pipeline-list,
.task-board,
.asset-grid {
  display: grid;
  gap: 10px;
}

.pipeline-list {
  padding: 10px;
}

.product-card,
.task-card,
.asset-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.product-stats,
.card-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.task-board {
  grid-template-columns: repeat(3, minmax(240px, 1fr));
}

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

.task-col h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.inbox-layout,
.analytics-layout,
.settings-layout,
.live-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 12px;
}

.message-list.full {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.side-panel {
  align-self: start;
}

.plain-list {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.plain-list li + li {
  margin-top: 8px;
}

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

.asset-card pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 10px 0 0;
  padding: 10px;
  border-radius: 8px;
  background: #f5f7f7;
  color: #34403f;
}

.chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(42px, 1fr));
  align-items: end;
  gap: 10px;
  min-height: 280px;
  padding-top: 20px;
}

.bar-wrap {
  display: grid;
  align-items: end;
  gap: 7px;
  height: 230px;
}

.bar {
  display: block;
  min-height: 10px;
  border-radius: 7px 7px 2px 2px;
  background: linear-gradient(180deg, #18a77f, #7abfe0);
}

.bar-label {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.settings-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.settings-form label,
.login-panel label,
.form-field {
  display: grid;
  gap: 6px;
  color: #4c5b58;
  font-weight: 700;
}

.settings-form input,
.settings-form textarea,
.login-panel input,
.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: 0;
}

.settings-form textarea,
.form-field textarea {
  resize: vertical;
}

.maintenance {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.auth-box {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
}

.auth-box a {
  display: block;
  margin-top: 8px;
  color: var(--green-dark);
  word-break: break-all;
}

.live-accounts {
  margin-top: 12px;
}

.live-account-list {
  display: grid;
  gap: 10px;
}

.live-account {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.live-account h3 {
  margin: 0;
  font-size: 16px;
}

.live-account p {
  margin: 5px 0 0;
  color: var(--muted);
}

.live-actions {
  display: flex;
  flex-wrap: wrap;
  align-content: start;
  justify-content: flex-end;
  gap: 7px;
}

.api-console {
  display: grid;
  grid-template-columns: 240px minmax(260px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.api-console label {
  display: grid;
  gap: 6px;
  color: #4c5b58;
  font-weight: 700;
}

.api-console .wide {
  grid-column: 1 / -1;
}

.api-console input,
.api-console select,
.api-console textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}

.api-result {
  max-height: 360px;
  overflow: auto;
  margin: 14px 0 0;
  padding: 12px;
  border-radius: 8px;
  background: #101816;
  color: #d9f7ef;
  white-space: pre-wrap;
  word-break: break-word;
}

.muted {
  color: var(--muted);
}

.login-screen {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 24px;
  background: #eef4f3;
  z-index: 20;
}

.login-screen.active {
  display: grid;
}

.login-panel {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin-bottom: 18px;
  font-size: 24px;
}

.login-panel label + label {
  margin-top: 12px;
}

.login-panel button {
  margin-top: 16px;
}

dialog {
  width: min(720px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(9, 18, 17, 0.42);
}

.dialog-card {
  padding: 18px;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 16px;
}

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

.form-field.wide {
  grid-column: 1 / -1;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  min-width: 220px;
  max-width: calc(100vw - 40px);
  padding: 11px 14px;
  border-radius: 8px;
  background: #16211f;
  color: #fff;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 30;
}

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

.empty-state {
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 78px minmax(0, 1fr);
  }

  .brand div,
  .nav-item b,
  .sidebar-foot span:not(.safe-dot) {
    display: none;
  }

  .sidebar {
    padding: 18px 10px;
  }

  .brand {
    justify-content: center;
    padding: 0;
  }

  .nav-item {
    justify-content: center;
    padding: 0;
  }

  .dashboard-grid,
  .dashboard-grid.compact,
  .inbox-layout,
  .analytics-layout,
  .settings-layout,
  .live-layout {
    grid-template-columns: 1fr;
  }

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

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

@media (max-width: 720px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 12;
    height: 64px;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 8px;
    overflow-x: auto;
  }

  .brand,
  .sidebar-foot {
    display: none;
  }

  .nav {
    display: flex;
    gap: 4px;
  }

  .nav-item {
    width: 46px;
    height: 46px;
    min-height: 46px;
  }

  .main {
    padding: 16px 14px 84px;
  }

  .topbar,
  .toolbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
  }

  .search {
    width: 100%;
  }

  .metric-grid,
  .matrix,
  .task-board,
  .asset-grid,
  .form-grid,
  .api-console {
    grid-template-columns: 1fr;
  }

  .live-account {
    grid-template-columns: 1fr;
  }

  .live-actions {
    justify-content: flex-start;
  }

  .pipeline-board {
    grid-template-columns: repeat(4, 260px);
  }

  .segmented {
    max-width: 100%;
    overflow-x: auto;
  }

  .alert-line {
    align-items: flex-start;
  }
}
