:root {
  --bg: #f5f7fa;
  --sidebar: #17212d;
  --sidebar-2: #1f2b38;
  --text: #17202c;
  --muted: #667085;
  --line: #e4e8ef;
  --panel: #ffffff;
  --teal: #12a39a;
  --teal-dark: #0d7c77;
  --amber: #f4a11a;
  --green: #55b34e;
  --blue: #4e93df;
  --purple: #9274df;
  --danger: #e64848;
  --shadow: 0 10px 28px rgba(19, 32, 48, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 1180px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

.login-body {
  min-width: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(18, 163, 154, 0.08), transparent 32%),
    var(--bg);
}

.login-card {
  width: min(420px, calc(100vw - 32px));
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.login-brand {
  padding: 0 0 24px;
  color: var(--text);
}

.login-card form {
  display: grid;
  gap: 12px;
}

.login-card label {
  color: #445164;
  font-weight: 650;
}

.login-card input {
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.login-card button {
  height: 44px;
  border: 0;
  border-radius: 8px;
  color: white;
  background: var(--teal);
  cursor: pointer;
}

#loginMessage {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
}

button, input {
  font: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  color: #e8eef6;
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #45d5c9, #0e766f);
  color: white;
  font-weight: 800;
}

.brand strong {
  display: block;
  font-size: 19px;
  line-height: 1.2;
}

.brand span {
  display: block;
  margin-top: 5px;
  color: #aab7c7;
  font-size: 13px;
}

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

.nav-item {
  height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  text-align: left;
  color: #d9e2ee;
  background: transparent;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  color: white;
  background: linear-gradient(90deg, #118c89, #1b777e);
}

.station-card {
  margin-top: auto;
  padding: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.station-card span {
  display: block;
  color: #9eabba;
  font-size: 12px;
}

.station-card strong {
  display: block;
  margin-top: 6px;
  font-size: 14px;
}

.main {
  padding: 18px 18px 28px;
}

.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.select-like,
.range,
.quick-tabs,
.sync,
.refresh {
  height: 42px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.select-like {
  min-width: 260px;
  padding: 0 16px;
  font-weight: 650;
}

.range {
  gap: 8px;
  padding: 0 10px;
}

.range input {
  width: 136px;
  border: 0;
  background: transparent;
  color: #263241;
}

.quick-tabs {
  overflow: hidden;
}

.quick-tabs button,
.segmented button {
  height: 100%;
  min-width: 58px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: #344054;
  cursor: pointer;
}

.quick-tabs button:last-child,
.segmented button:last-child {
  border-right: 0;
}

.quick-tabs .selected,
.segmented .selected {
  color: var(--teal-dark);
  background: #e9fbf8;
}

.sync {
  margin-left: auto;
  padding: 0 14px;
  color: #2a7d3f;
  border: 0;
  background: transparent;
  font-size: 14px;
}

.refresh {
  padding: 0 16px;
  color: #263241;
  cursor: pointer;
}

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

.kpi,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.kpi {
  min-height: 112px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 16px 14px;
}

.kpi-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  font-weight: 800;
}

.kpi span {
  color: #445164;
  font-size: 14px;
}

.kpi strong {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  font-size: 16px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kpi small {
  display: block;
  margin-top: 9px;
  color: var(--danger);
}

.grid {
  display: grid;
  gap: 12px;
}

.grid-main {
  grid-template-columns: minmax(660px, 1.35fr) minmax(360px, 0.65fr);
  margin-bottom: 12px;
}

.grid-lower {
  grid-template-columns: minmax(620px, 1fr) 560px;
}

.panel {
  padding: 18px;
}

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

.panel-head h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
}

.panel-head.compact {
  margin-bottom: 12px;
}

.segmented {
  height: 34px;
  display: flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.chart {
  height: 334px;
  display: flex;
  align-items: end;
  gap: 22px;
  padding: 34px 18px 22px;
  border-radius: 8px;
  background-image: linear-gradient(var(--line) 1px, transparent 1px);
  background-size: 100% 58px;
}

.month-group {
  flex: 1;
  min-width: 58px;
  height: 100%;
  display: grid;
  grid-template-rows: 1fr 20px;
  gap: 8px;
  align-items: end;
}

.bars {
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 7px;
  height: 100%;
}

.bar {
  width: 13px;
  border-radius: 3px 3px 0 0;
}

.bar.revenue { background: var(--teal); }
.bar.cost { background: var(--amber); }
.bar.profit { background: var(--green); }

.month-label {
  text-align: center;
  color: #667085;
  font-size: 12px;
}

.metric-list {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
}

.metric-row:last-child { border-bottom: 0; }
.metric-row span { color: #596579; }
.metric-row strong { font-weight: 650; }

.mini-line {
  height: 110px;
  margin-top: 18px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, transparent 24%, var(--line) 25%, transparent 26%),
    linear-gradient(180deg, transparent 49%, var(--line) 50%, transparent 51%),
    linear-gradient(180deg, transparent 74%, var(--line) 75%, transparent 76%);
  position: relative;
}

.mini-line svg {
  width: 100%;
  height: 100%;
}

.table-panel {
  min-height: 360px;
}

.link-button,
.plain {
  border: 0;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
  white-space: nowrap;
}

th {
  color: #526071;
  font-weight: 650;
  background: #fafbfc;
}

td:nth-child(2) {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-pill {
  display: inline-flex;
  height: 24px;
  align-items: center;
  padding: 0 8px;
  border-radius: 6px;
  color: #12705f;
  background: #e8f8ef;
  font-size: 12px;
}

.stack {
  display: grid;
  gap: 12px;
}

.cost-layout {
  display: grid;
  grid-template-columns: 168px 1fr;
  gap: 18px;
  align-items: center;
}

.donut {
  width: 152px;
  height: 152px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--teal) 0 68%, var(--amber) 68% 78%, var(--blue) 78% 87%, var(--purple) 87% 93%, #8ec9df 93% 100%);
  position: relative;
}

.donut::after {
  content: "";
  position: absolute;
  width: 94px;
  height: 94px;
  border-radius: 50%;
  background: white;
}

.donut span {
  position: relative;
  z-index: 1;
  width: 70px;
  text-align: center;
  color: #4d5969;
  font-size: 13px;
}

.legend {
  display: grid;
  gap: 10px;
}

.legend-row,
.source-card {
  display: grid;
  gap: 4px;
}

.legend-row {
  grid-template-columns: 10px 1fr auto auto;
  align-items: center;
  column-gap: 9px;
  color: #344054;
  font-size: 14px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

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

.source-card {
  min-height: 88px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.source-card strong {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
}

.status {
  color: #177a3a;
  font-size: 12px;
  font-weight: 650;
}

.source-card span:last-child {
  color: #667085;
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 900px) {
  body { min-width: 0; }
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
  }
  .nav { grid-template-columns: repeat(3, 1fr); }
  .station-card { display: none; }
  .topbar { flex-wrap: wrap; height: auto; }
  .sync { margin-left: 0; }
  .kpis,
  .grid-main,
  .grid-lower,
  .sources,
  .cost-layout {
    grid-template-columns: 1fr;
  }
  .chart { overflow-x: auto; }
}
