:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #63717d;
  --line: #d9e0e4;
  --surface: #ffffff;
  --canvas: #f4f6f7;
  --primary: #176b87;
  --primary-dark: #10556c;
  --accent: #278568;
  --danger: #b93832;
  --warning: #b7791f;
  --focus: #8cc7dc;
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--canvas);
  font-size: 14px;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.topbar {
  min-height: 58px;
  color: #fff;
  background: #182832;
  border-bottom: 3px solid var(--accent);
}

.topbar-inner {
  width: min(1440px, calc(100% - 40px));
  min-height: 58px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 650;
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 32px;
  display: inline-flex;
  align-items: end;
  justify-content: center;
  gap: 4px;
  padding: 6px;
  background: #e9f5f2;
  border: 1px solid #c5e2d9;
  border-radius: 6px;
}

.brand-mark span {
  width: 5px;
  background: var(--accent);
  border-radius: 1px 1px 0 0;
}

.brand-mark span:nth-child(1) { height: 8px; }
.brand-mark span:nth-child(2) { height: 17px; }
.brand-mark span:nth-child(3) { height: 12px; }

.brand-mark-small {
  width: 30px;
  height: 27px;
  padding: 5px;
}

.account-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.account-actions form {
  margin: 0;
}

.account-name {
  color: #cbd7dc;
}

.workspace {
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.page-heading,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.page-heading {
  margin-bottom: 20px;
}

.page-heading h1,
.section-heading h2,
.login-panel h1 {
  margin: 0;
  letter-spacing: 0;
}

.page-heading h1 {
  font-size: 26px;
  line-height: 1.25;
}

.section-heading h2 {
  font-size: 18px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 3px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}

.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 15px;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.button:focus-visible,
input:focus-visible,
.segment:focus-visible,
.page-link:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

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

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

.button-secondary {
  color: var(--primary-dark);
  background: #fff;
  border-color: #9db5c0;
}

.button-secondary:hover {
  background: #eff6f8;
}

.button-quiet {
  color: inherit;
  background: transparent;
  border-color: #8da0aa;
}

.topbar .button-quiet {
  min-height: 32px;
  padding: 4px 11px;
  color: #fff;
  border-color: #536b77;
}

.filter-bar {
  display: flex;
  align-items: end;
  gap: 14px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  color: #34434d;
  font-size: 13px;
  font-weight: 650;
}

.field input {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #aebbc2;
  border-radius: 4px;
}

.field-inline {
  width: 190px;
}

.filter-actions {
  display: flex;
  gap: 8px;
}

.form-error {
  color: var(--danger);
  font-weight: 600;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 22px 0 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.metric {
  min-width: 0;
  padding: 16px 18px;
  border-right: 1px solid var(--line);
}

.metric:last-child {
  border-right: 0;
}

.metric span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  overflow: hidden;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
}

.chart-section,
.table-section {
  padding: 22px 0 0;
  border-top: 1px solid var(--line);
}

.table-section {
  margin-top: 32px;
}

.segmented-control {
  display: inline-flex;
  padding: 2px;
  background: #e7ecef;
  border-radius: 5px;
}

.segment {
  min-width: 62px;
  min-height: 32px;
  padding: 5px 12px;
  color: #50606a;
  background: transparent;
  border: 0;
  border-radius: 3px;
  cursor: pointer;
}

.segment.is-active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 1px 2px rgb(23 33 43 / 12%);
  font-weight: 650;
}

.chart-frame {
  position: relative;
  height: 340px;
  margin-top: 18px;
  padding: 14px 10px 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.empty-state,
.empty-cell {
  color: var(--muted);
  text-align: center;
}

.empty-state {
  position: absolute;
  inset: 0;
  place-content: center;
}

.empty-state:not([hidden]) {
  display: grid;
}

.table-heading {
  margin-bottom: 14px;
}

.result-count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.table-scroll {
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 11px 14px;
  border-bottom: 1px solid #e5eaed;
  text-align: left;
  white-space: nowrap;
}

th {
  color: #45545e;
  background: #f1f4f5;
  font-size: 12px;
  font-weight: 700;
}

tbody tr:hover {
  background: #f5fafb;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.numeric {
  text-align: right;
}

.factory-code {
  color: var(--primary-dark);
  font-weight: 700;
}

.empty-cell {
  height: 100px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 12px;
  margin-top: 16px;
}

.page-link {
  min-width: 68px;
  padding: 6px 10px;
  color: var(--primary-dark);
  background: #fff;
  border: 1px solid #b9c6cc;
  border-radius: 4px;
  text-align: center;
  text-decoration: none;
}

.page-link.is-disabled {
  color: #98a4aa;
  background: #edf0f1;
}

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

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #edf1f2;
}

.login-panel {
  width: min(100%, 390px);
  padding: 34px;
  background: #fff;
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: 7px;
  box-shadow: 0 14px 34px rgb(23 33 43 / 9%);
}

.login-panel .brand-mark {
  margin-bottom: 10px;
}

.brand-name {
  margin: 0 0 24px;
  color: #34434d;
  font-weight: 700;
}

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

.login-subtitle {
  margin: 6px 0 24px;
  color: var(--muted);
}

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

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

.alert {
  margin-bottom: 18px;
  padding: 10px 12px;
  border-radius: 4px;
}

.alert-error {
  color: #7d2622;
  background: #fae9e7;
  border: 1px solid #e9b4b0;
}

@media (max-width: 760px) {
  .topbar-inner,
  .workspace {
    width: min(100% - 24px, 1440px);
  }

  .workspace {
    padding-top: 20px;
  }

  .page-heading {
    align-items: end;
  }

  .page-heading h1 {
    font-size: 22px;
  }

  .filter-bar {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .field-inline {
    width: calc(50% - 7px);
  }

  .filter-actions,
  .form-error {
    width: 100%;
  }

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

  .metric {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metric:nth-child(odd) {
    border-right: 1px solid var(--line);
  }

  .metric:last-child {
    border-bottom: 0;
  }

  .chart-frame {
    height: 300px;
  }
}

@media (max-width: 460px) {
  .account-name {
    display: none;
  }

  .page-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .page-heading .button {
    width: 100%;
  }

  .field-inline {
    width: 100%;
  }

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

  .table-heading {
    flex-direction: row;
  }

  .chart-frame {
    height: 270px;
  }

  .login-panel {
    padding: 26px 22px;
  }
}

.dashboard-tabs { display:flex; gap:8px; border-bottom:1px solid var(--line); margin-bottom:26px; }
.dashboard-tab { padding:11px 18px; color:var(--muted); text-decoration:none; border-bottom:3px solid transparent; font-weight:650; }
.dashboard-tab.is-active { color:var(--primary-dark); border-bottom-color:var(--primary); background:#eaf3f6; border-radius:6px 6px 0 0; }
.dashboard-tab:focus-visible, select:focus-visible { outline:3px solid var(--focus); outline-offset:2px; }
.admin-link { color:#d7edf5; text-decoration:none; font-size:13px; }
.admin-link:hover { text-decoration:underline; }
.alert-success { color:#176344; background:#e7f5ee; border:1px solid #b5ddc9; }
.import-intro { margin-bottom:22px; color:var(--muted); }
.import-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:18px; }
.import-card { background:#fff; padding:22px; border:1px solid var(--line); border-radius:9px; }
.import-card h2 { font-size:18px; margin:0 0 12px; }
.import-card p { color:var(--muted); }
.import-card .import-example { font-size:12px; }
.import-card form { display:grid; gap:15px; margin:22px 0; }
.import-card input[type=file] { padding:9px; font-size:12px; }
.import-card .import-last { font-size:12px; line-height:1.8; border-top:1px solid var(--line); padding-top:14px; }
button:disabled { cursor:wait; opacity:.6; }
.page-link:disabled { color:#98a4aa; cursor:default; background:#edf0f1; }
@media(max-width:1000px) { .import-grid { grid-template-columns:1fr; } }
@media(max-width:600px) {
 .topbar-inner { gap:8px; }
 .account-actions { gap:8px; }
 .admin-link { font-size:12px; }
 .dashboard-tab { flex:1; text-align:center; padding:10px 5px; font-size:13px; }
 .brand { font-size:12px; gap:6px; }
 .brand-mark-small { display:none; }
}

.filter-dropdown {
  position: relative;
}

.filter-dropdown summary {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #aebbc2;
  border-radius: 4px;
  cursor: pointer;
  list-style: none;
}

.filter-dropdown summary::-webkit-details-marker {
  display: none;
}

.filter-dropdown summary::after {
  content: "▾";
  color: var(--muted);
}

.filter-dropdown-summary {
  max-width: 150px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-dropdown[open] summary {
  border-color: var(--primary);
  border-radius: 4px 4px 0 0;
}

.filter-dropdown-menu {
  position: absolute;
  z-index: 10;
  top: calc(100% - 1px);
  left: 0;
  width: max-content;
  min-width: 100%;
  max-width: min(320px, 80vw);
  max-height: 260px;
  overflow-y: auto;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--primary);
  border-radius: 0 0 4px 4px;
  box-shadow: 0 8px 18px rgba(23, 33, 43, 0.14);
}

.filter-options {
  display: grid;
  gap: 4px;
  margin: 0;
}

.filter-options > div {
  min-width: 170px;
}

.filter-options label {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 6px;
  color: var(--ink);
  font-weight: 400;
  white-space: nowrap;
}

.filter-options label:hover {
  background: #eff6f8;
}

.filter-options input {
  width: 16px;
  min-width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
  accent-color: var(--primary);
}


.chart-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.chart-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #34434d;
  font-size: 13px;
  white-space: nowrap;
}

.chart-toggle[hidden] {
  display: none;
}

.chart-toggle input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary);
}

