:root {
  --bg: #080a0b;
  --bg-2: #0d1012;
  --panel: #111517;
  --panel-2: #151a1d;
  --line: #293037;
  --line-soft: #1f252a;
  --ink: #f3ead8;
  --muted: #9da7a8;
  --dim: #687477;
  --gold: #d8b56d;
  --gold-2: #9d7c3c;
  --green: #4ec78b;
  --red: #e0675f;
  --teal: #40bdb7;
  --blue: #6f98d6;
  --amber: #c88e3c;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 0%, rgba(216, 181, 109, 0.12), transparent 28%),
    linear-gradient(180deg, #050606 0%, var(--bg) 42%, #0b0d0e 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.8), transparent 80%);
}

.shell {
  width: min(1680px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 8px 2px 18px;
}

.eyebrow {
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 2.2px;
  text-transform: uppercase;
}

h1 {
  margin: 8px 0 6px;
  font-family: Georgia, "Times New Roman", "Songti SC", serif;
  font-size: clamp(34px, 4.2vw, 62px);
  font-weight: 500;
  line-height: 0.95;
  letter-spacing: 0;
}

.topbar p,
.panel-head p,
.note {
  margin: 0;
  color: var(--muted);
}

.source-pill {
  flex: none;
  border: 1px solid rgba(216, 181, 109, 0.45);
  background: linear-gradient(180deg, rgba(216, 181, 109, 0.16), rgba(216, 181, 109, 0.06));
  border-radius: 999px;
  padding: 9px 14px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  box-shadow: var(--shadow);
}

.world-clock-strip {
  flex: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(96px, 1fr));
  gap: 8px;
  min-width: 360px;
}

.world-clock-strip > div {
  border: 1px solid rgba(216, 181, 109, 0.32);
  border-radius: 6px;
  padding: 9px 12px;
  background: linear-gradient(180deg, rgba(216, 181, 109, 0.13), rgba(17, 21, 23, 0.92));
  box-shadow: var(--shadow);
}

.world-clock-strip span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.2px;
}

.world-clock-strip strong {
  display: block;
  margin-top: 5px;
  color: var(--gold);
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.source-grid,
.control-strip,
.kpi-grid,
.dashboard-grid {
  display: grid;
  gap: 10px;
}

.workspace-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.side-panel {
  position: sticky;
  top: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100vh - 28px);
  overflow: auto;
  padding: 14px;
  background: linear-gradient(180deg, rgba(21, 26, 29, 0.98), rgba(8, 10, 11, 0.98));
  border: 1px solid rgba(216, 181, 109, 0.22);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.side-panel::-webkit-scrollbar {
  width: 8px;
}

.side-panel::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 999px;
}

.side-panel::-webkit-scrollbar-thumb {
  background: rgba(216, 181, 109, 0.34);
  border-radius: 999px;
}

.side-title {
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 12px;
}

.side-title span {
  display: block;
  color: var(--gold);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.8px;
}

.side-title strong {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
}

.content-panel {
  min-width: 0;
}

.source-grid {
  grid-template-columns: 1.05fr 1.2fr 1.2fr 1fr;
  margin-bottom: 10px;
}

.source-grid > div,
.control-strip label,
.kpi,
.panel {
  background: linear-gradient(180deg, rgba(21, 26, 29, 0.98), rgba(13, 16, 18, 0.98));
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.source-grid > div {
  min-height: 76px;
  padding: 12px 14px;
}

.source-grid span,
.kpi span,
.control-strip span {
  display: block;
  color: var(--dim);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.1px;
  text-transform: uppercase;
}

.source-grid strong {
  display: block;
  margin-top: 7px;
  color: var(--ink);
  font-size: 22px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.source-grid small,
.kpi small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.control-strip {
  grid-template-columns: 1fr;
  margin-bottom: 0;
}

.control-strip label {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
  padding: 14px;
}

.control-strip output {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 900;
}

input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--gold);
}

.side-nav {
  display: grid;
  gap: 5px;
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
}

.side-nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  border-left: 2px solid transparent;
  border-radius: 6px;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-decoration: none;
}

.side-nav a:hover {
  border-left-color: var(--gold);
  color: var(--ink);
  background: rgba(216, 181, 109, 0.08);
}

.side-nav b {
  display: grid;
  place-items: center;
  width: 24px;
  height: 22px;
  border: 1px solid rgba(216, 181, 109, 0.20);
  border-radius: 5px;
  color: var(--gold);
  background: rgba(216, 181, 109, 0.06);
  font-size: 10px;
}

.upload-dock {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
}

.gear-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(216, 181, 109, 0.42);
  border-radius: 8px;
  color: var(--gold);
  background: linear-gradient(180deg, rgba(216, 181, 109, 0.14), rgba(10, 13, 15, 0.96));
  box-shadow: inset 0 0 0 1px rgba(216, 181, 109, 0.06);
  cursor: pointer;
}

.gear-button:hover,
.gear-button[aria-expanded="true"] {
  color: var(--ink);
  border-color: rgba(216, 181, 109, 0.75);
  background: linear-gradient(180deg, rgba(216, 181, 109, 0.24), rgba(20, 18, 14, 0.96));
}

.gear-button span {
  font-size: 20px;
  line-height: 1;
}

.upload-drawer {
  display: grid;
  gap: 12px;
  border: 1px solid rgba(216, 181, 109, 0.28);
  border-radius: 8px;
  padding: 12px;
  background: rgba(8, 10, 11, 0.88);
}

.upload-drawer[hidden] {
  display: none;
}

.upload-drawer-head {
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 10px;
}

.upload-drawer-head span {
  display: block;
  color: var(--gold);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.6px;
}

.upload-drawer-head strong {
  display: block;
  margin-top: 5px;
  font-size: 14px;
}

.kpi-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-bottom: 10px;
}

.kpi {
  min-height: 98px;
  padding: 13px 14px;
}

.kpi.primary {
  border-color: rgba(216, 181, 109, 0.58);
  background: linear-gradient(180deg, rgba(216, 181, 109, 0.18), rgba(20, 18, 14, 0.96));
}

.kpi strong {
  display: block;
  margin-top: 8px;
  color: var(--ink);
  font-size: clamp(21px, 2vw, 31px);
  line-height: 1;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.kpi.primary strong {
  color: var(--gold);
}

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

.panel {
  padding: 13px 13px 8px;
}

.panel.wide {
  grid-column: span 2;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  min-height: 54px;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 10px;
}

.panel-head h2 {
  margin: 0 0 5px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 850;
  letter-spacing: 0;
}

.panel-head p {
  font-size: 12px;
  line-height: 1.35;
}

.panel-head > span {
  flex: none;
  color: var(--gold);
  background: rgba(216, 181, 109, 0.09);
  border: 1px solid rgba(216, 181, 109, 0.24);
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}

.panel-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 9px 16px;
  max-width: 720px;
  padding-top: 2px;
}

.panel-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
}

.panel-legend i {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  border-radius: 4px;
  background: var(--c);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.panel-legend i.ring {
  border: 3px solid var(--c);
  border-radius: 999px;
  background: #ffffff;
}

.chart {
  width: 100%;
  height: 380px;
  margin-top: 8px;
}

.chart.large {
  height: 414px;
}

.chart.xlarge {
  height: 680px;
}

.module .module-body {
  display: grid;
  gap: 12px;
  min-height: 360px;
  padding: 14px 2px 4px;
}

.module input[type="file"],
.upload-drawer input[type="file"] {
  width: 100%;
  color: var(--muted);
  border: 1px dashed rgba(216, 181, 109, 0.38);
  border-radius: 6px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.025);
}

.upload-drawer .module-body {
  display: grid;
  gap: 10px;
}

.upload-drawer .template-table {
  max-height: 260px;
  overflow: auto;
}

.upload-drawer .template-row {
  grid-template-columns: 1fr 0.8fr;
}

.upload-drawer .template-row span:nth-child(3),
.upload-drawer .template-row span:nth-child(4) {
  display: none;
}

.status-line {
  color: var(--gold);
  font-size: 12px;
  line-height: 1.45;
  border-left: 3px solid var(--gold-2);
  padding-left: 10px;
}

.template-table {
  display: grid;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--line-soft);
}

.template-row {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr 0.7fr 1.1fr;
  gap: 1px;
}

.template-row span {
  min-width: 0;
  padding: 9px 10px;
  overflow: hidden;
  color: var(--muted);
  background: rgba(10, 13, 15, 0.96);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-row span[contenteditable="true"] {
  color: var(--ink);
  background: rgba(216, 181, 109, 0.06);
  outline: none;
}

.template-head span {
  color: var(--gold);
  font-weight: 900;
  text-transform: uppercase;
}

.note {
  padding: 18px 4px 6px;
  font-size: 11px;
  text-align: center;
}

@media (max-width: 1180px) {
  .workspace-layout {
    grid-template-columns: 230px minmax(0, 1fr);
  }

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

@media (max-width: 880px) {
  .shell {
    padding: 14px;
  }

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

  .world-clock-strip {
    width: 100%;
    min-width: 0;
  }

  .workspace-layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
    max-height: none;
  }

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

  .source-grid,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .panel.wide {
    grid-column: auto;
  }

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

  .chart,
  .chart.large,
  .chart.xlarge {
    height: 350px;
  }

  #powerTripleChart.chart.xlarge {
    height: 680px;
  }

  .template-row {
    grid-template-columns: 1fr 0.8fr;
  }

  .template-row span:nth-child(3),
  .template-row span:nth-child(4) {
    display: none;
  }

  .panel-head {
    flex-direction: column;
  }

  .panel-legend {
    justify-content: flex-start;
    max-width: 100%;
  }
}
