:root {
  --bg-canvas: #0e0d0c;
  --bg-surface: #161412;
  --bg-elevated: #1e1b18;
  --bg-hover: #25211d;
  --border-subtle: rgba(255, 240, 224, 0.08);
  --border-strong: rgba(255, 240, 224, 0.16);
  --text-primary: #f5f2ed;
  --text-secondary: #a89f94;
  --text-muted: #756d63;
  --amber: #e87a2b;
  --amber-hover: #f28c42;
  --amber-soft: rgba(232, 122, 43, 0.14);
  --green: #38b87c;
  --green-soft: rgba(56, 184, 124, 0.14);
  --red: #e05a5a;
  --red-soft: rgba(224, 90, 90, 0.14);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-modal: 0 24px 64px rgba(0, 0, 0, 0.65);
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 14px;
}

/* Login Screen */
.loginShell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.loginHero {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px 56px;
  background:
    radial-gradient(640px 420px at 20% 25%, rgba(232, 122, 43, 0.14), transparent 70%),
    linear-gradient(160deg, #171411 0%, #0d0c0b 100%);
  border-right: 1px solid var(--border-subtle);
}

.heroBrand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.heroBrand img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.heroBrand span {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.heroCopy h1 {
  margin: 0 0 16px;
  font-size: 34px;
  line-height: 1.28;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.heroCopy p {
  margin: 0;
  max-width: 46ch;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.75;
}

.heroFeatures {
  display: grid;
  gap: 14px;
  margin-top: 32px;
}

.heroFeatureItem {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border-subtle);
}

.heroFeatureDot {
  width: 8px;
  height: 8px;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--amber);
  flex-shrink: 0;
}

.heroFeatureItem strong {
  display: block;
  font-size: 14px;
  margin-bottom: 2px;
}

.heroFeatureItem span {
  color: var(--text-secondary);
  font-size: 13px;
}

.heroFoot {
  color: var(--text-muted);
  font-size: 12px;
}

.loginFormPane {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 28px;
}

.loginCard {
  width: 100%;
  max-width: 400px;
  padding: 36px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

.loginCard h2 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 650;
}

.loginCard .sub {
  margin: 0 0 28px;
  color: var(--text-secondary);
  font-size: 13px;
}

.demoHintBox {
  margin-top: 22px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-secondary);
}

.demoHintBox strong {
  color: var(--text-primary);
}

.demoHintRow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  gap: 8px;
}

/* App Shell */
.appShell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
}

.sidebarBrand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebarBrand img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.sidebarBrand .title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebarBrand .badge {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--amber-soft);
  color: var(--amber-hover);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.navList {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 16px;
  flex: 1;
}

.navBtn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  text-align: left;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.navBtn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.navBtn.active {
  background: var(--amber-soft);
  color: var(--amber-hover);
}

.sidebarFooter {
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.userMeta {
  min-width: 0;
}

.userMeta .name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.userMeta .role {
  color: var(--text-muted);
  font-size: 12px;
}

/* Main Workspace */
.mainArea {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topBar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 32px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(22, 20, 18, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topBar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
}

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

.contentBody {
  padding: 28px 32px 48px;
  max-width: 1360px;
  width: 100%;
}

/* Cards & Grids */
.kpiGrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpiCard {
  padding: 20px 22px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.kpiLabel {
  color: var(--text-secondary);
  font-size: 13px;
}

.kpiValue {
  margin-top: 8px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.kpiValue.amber {
  color: var(--amber-hover);
}

.kpiSub {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 12px;
}

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 22px 24px;
  margin-bottom: 20px;
}

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

.panelHeader h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
}

.panelHeader .hint {
  color: var(--text-secondary);
  font-size: 13px;
}

/* Bar Chart */
.chartBars {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
  height: 150px;
  padding-top: 12px;
}

.chartCol {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}

.chartBar {
  width: 100%;
  max-width: 28px;
  min-height: 4px;
  border-radius: 5px 5px 2px 2px;
  background: linear-gradient(180deg, var(--amber-hover) 0%, #b55718 100%);
  transition: height 0.25s ease;
}

.chartDate {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Tables */
.tableWrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

th {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 12px;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

.num {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 500;
}

.pill.green { background: var(--green-soft); color: var(--green); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.amber { background: var(--amber-soft); color: var(--amber-hover); }
.pill.muted { background: rgba(255, 255, 255, 0.07); color: var(--text-secondary); }

/* Controls & Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-primary);
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn:hover:not(:disabled) {
  background: var(--bg-hover);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--amber);
  border-color: var(--amber);
  color: #140c06;
  font-weight: 650;
}

.btn.primary:hover:not(:disabled) {
  background: var(--amber-hover);
  border-color: var(--amber-hover);
}

.btn.danger {
  color: var(--red);
  border-color: rgba(224, 90, 90, 0.3);
}

.btn.sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn.full {
  width: 100%;
  padding: 11px 16px;
}

.btnGroup {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-canvas);
  color: var(--text-primary);
  outline: none;
}

.field input:focus, .field select:focus {
  border-color: var(--amber);
}

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

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

.filterRow select, .filterRow input {
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-canvas);
  color: var(--text-primary);
}

/* Modal */
.modalBackdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modalCard {
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 26px 28px;
  box-shadow: var(--shadow-modal);
}

.modalHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modalHeader h3 {
  margin: 0;
  font-size: 18px;
}

.modalFooter {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
}

.alert.error { background: var(--red-soft); color: #ff9c9c; border: 1px solid rgba(224, 90, 90, 0.3); }
.alert.success { background: var(--green-soft); color: #84e5b5; border: 1px solid rgba(56, 184, 124, 0.3); }

.codeBox {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 13px;
  overflow-x: auto;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 200;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--amber);
  color: var(--text-primary);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  font-size: 13px;
}

@media (max-width: 960px) {
  .loginShell { grid-template-columns: 1fr; }
  .loginHero { display: none; }
  .appShell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .kpiGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .formGrid2 { grid-template-columns: 1fr; }
}
