:root {
  --home-bg: #f7f8fb;
  --home-surface: #ffffff;
  --home-border: #e7e9f0;
  --home-text: #172033;
  --home-muted: #747b8c;
  --home-primary: #4f46e5;
  --home-primary-dark: #3730a3;
  --home-primary-soft: #f0efff;
  --home-cyan: #12b5ea;
  --home-success: #18a66a;
  --home-warning: #e88c16;
  --home-danger: #e5484d;
  --home-sidebar: 216px;
}

/* 权限控制统一使用 hidden 属性，任何组件样式都不能覆盖它。 */
[hidden] {
  display: none !important;
}

.dashboard-denied {
  padding-top: 32px;
}

.dashboard-denied .surface {
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.dashboard-denied .surface > i {
  font-size: 44px;
  color: var(--home-primary);
  margin-bottom: 14px;
}

.dashboard-denied h1 {
  margin: 0;
  font-size: 22px;
  color: #273247;
}

.dashboard-denied p {
  margin: 10px 0 0;
  color: #7b8497;
}

body {
  background: var(--home-bg) !important;
}

/* 智能印刷工厂背景：图片主体位于右侧，左侧保留给业务内容与登录表单。 */
.auth-page {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background: #07111b !important;
}

.auth-page::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 0;
  background: url('/static/images/printing-ai-factory-bg.png') center right / cover no-repeat;
}

.auth-page::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0;
  background: linear-gradient(90deg, rgba(3, 11, 19, .76) 0%, rgba(3, 11, 19, .46) 48%, rgba(3, 11, 19, .18) 100%);
}

.auth-card,
.auth-filing {
  position: relative;
  z-index: 2;
}

.app-main {
  position: relative;
  isolation: isolate;
  background: transparent;
}

.app-main::before {
  content: "";
  position: fixed;
  z-index: 0;
  top: 68px;
  right: 0;
  bottom: 0;
  left: var(--home-sidebar);
  background: url('/static/images/printing-ai-factory-bg.png') center right / cover no-repeat;
  opacity: .13;
}

.app-main::after {
  content: "";
  position: fixed;
  z-index: 1;
  top: 68px;
  right: 0;
  bottom: 0;
  left: var(--home-sidebar);
  background: linear-gradient(90deg, rgba(247, 248, 251, .96) 0%, rgba(247, 248, 251, .9) 55%, rgba(247, 248, 251, .67) 100%);
}

.workspace {
  position: relative;
  z-index: 2;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--home-sidebar) minmax(0, 1fr);
  color: var(--home-text);
}

.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 14px;
  background: rgba(255, 255, 255, .96);
  border-right: 1px solid var(--home-border);
  display: flex;
  flex-direction: column;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  padding: 7px 13px 25px;
  font-size: 17px;
  font-weight: 750;
  letter-spacing: -.02em;
  white-space: nowrap;
}

.side-nav {
  display: grid;
  gap: 5px;
}

.side-link {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 13px;
  border-radius: 10px;
  color: #4d5567;
  text-decoration: none;
  font-size: 14px;
  font-weight: 560;
  transition: .16s ease;
}

.side-link i {
  width: 20px;
  min-width: 20px;
  font-size: 20px;
  color: #667085;
}

/* 图标字体加载前隐藏内部编码，菜单文字保持原位不跳动。 */
html.tabler-icons-loading .ti {
  visibility: hidden;
}

.side-link:hover {
  color: var(--home-primary);
  background: #f6f6fb;
}

.side-link.active {
  color: var(--home-primary);
  background: var(--home-primary-soft);
  font-weight: 680;
}

.side-link.active i {
  color: var(--home-primary);
}

.sidebar-bottom {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--home-border);
}

.app-main {
  min-width: 0;
}

.topbar-home {
  height: 68px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background: rgba(255, 255, 255, .88);
  border-bottom: 1px solid var(--home-border);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.mobile-menu {
  display: none;
  width: 38px;
  height: 38px;
  border: 1px solid var(--home-border);
  border-radius: 9px;
  color: var(--home-text);
  background: #fff;
  font-size: 20px;
  cursor: pointer;
}

.topbar-spacer {
  flex: 1;
}

.top-action,
.btn-logout {
  min-height: 38px;
  border: 1px solid var(--home-border) !important;
  border-radius: 9px !important;
  padding: 0 13px !important;
  background: #fff !important;
  color: #4d5567 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 13px !important;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

/* 用户管理入口由岗位权限控制，不能用 !important 覆盖行内的隐藏状态。 */
.btn-admin {
  min-height: 38px;
  border: 1px solid var(--home-border) !important;
  border-radius: 9px !important;
  padding: 0 13px !important;
  background: #fff !important;
  color: #4d5567 !important;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 13px !important;
  font-weight: 700 !important;
  text-decoration: none;
  cursor: pointer;
}

.top-action:hover,
.btn-admin:hover,
.btn-logout:hover {
  border-color: #cdd0dc !important;
  color: var(--home-primary) !important;
  transform: none !important;
  box-shadow: none !important;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-left: 5px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: #7d8be2;
  font-weight: 700;
}

.user-meta {
  line-height: 1.2;
}

.user-meta strong {
  display: block;
  font-size: 13px;
}

.user-meta span {
  color: var(--home-muted);
  font-size: 11px;
}

.workspace {
  max-width: 1500px;
  margin: 0 auto;
  padding: 26px 30px 34px;
}

.workspace-heading {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-bottom: 22px;
}

.workspace-title {
  flex: 0 0 auto;
}

.workspace-title h1 {
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -.04em;
}

.workspace-title p {
  margin-top: 5px;
  color: var(--home-muted);
  font-size: 13px;
}

.ai-search {
  flex: 1;
  max-width: 680px;
  margin-left: auto;
  padding: 3px;
  border-radius: 13px;
  background: linear-gradient(100deg, #35c5f4, #6559f5);
  box-shadow: 0 8px 24px rgba(79, 70, 229, .12);
}

.ai-search-inner {
  min-height: 48px;
  padding: 0 7px 0 15px;
  border-radius: 10px;
  background: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-search-inner > i {
  color: var(--home-primary);
  font-size: 20px;
}

.ai-search input {
  min-width: 0;
  flex: 1;
  min-height: 40px !important;
  padding: 0 !important;
  border: 0 !important;
  box-shadow: none !important;
  color: var(--home-text);
  font-size: 14px;
}

.ai-search button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--home-primary);
  font-size: 18px;
  cursor: pointer;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 14px;
  align-items: stretch;
}

.surface {
  background: var(--home-surface);
  border: 1px solid var(--home-border);
  border-radius: 12px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--home-border);
}

.section-title h2 {
  font-size: 16px;
  font-weight: 720;
}

.section-title a,
.section-title button {
  color: var(--home-muted);
  background: none;
  border: 0;
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
}

.quick-list {
  padding: 8px 12px 12px;
}

.quick-link {
  min-height: 46px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #3d4555;
  border-bottom: 1px solid #f0f1f5;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.quick-link:last-child {
  border-bottom: 0;
}

.quick-link > i {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--home-primary);
  background: #f5f4ff;
  font-size: 18px;
}

.quick-link .ti-chevron-right {
  width: auto;
  height: auto;
  margin-left: auto;
  color: #a0a6b4;
  background: none;
  font-size: 15px;
}

.quick-link:hover {
  color: var(--home-primary);
}

.pulse-panel {
  padding-bottom: 13px;
}

.pulse-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 17px 18px 11px;
}

.pulse-metric {
  text-align: center;
  border-right: 1px solid var(--home-border);
}

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

.pulse-metric span {
  display: block;
  color: var(--home-muted);
  font-size: 12px;
}

.pulse-metric strong {
  display: block;
  margin-top: 7px;
  font-size: 26px;
  line-height: 1;
}

.metric-danger strong { color: var(--home-danger); }
.metric-primary strong { color: var(--home-primary); }
.metric-success strong { color: var(--home-success); }

.workload {
  padding: 15px 18px 4px;
  border-top: 1px solid var(--home-border);
}

.workload-head,
.workload-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--home-muted);
  font-size: 11px;
}

.workload-head strong {
  color: #4d5567;
  font-size: 12px;
}

.workload-bars {
  height: 106px;
  margin: 13px 0 8px;
  padding: 10px 6px 0;
  display: flex;
  align-items: end;
  gap: 5px;
  border-bottom: 1px solid #dfe2ea;
  background-image: linear-gradient(#eef0f5 1px, transparent 1px);
  background-size: 100% 31px;
}

.workload-bar {
  flex: 1;
  max-width: 12px;
  border-radius: 3px 3px 0 0;
  background: var(--home-primary);
  opacity: .9;
}

.workload-bar.pending { background: var(--home-danger); }
.workload-bar.delivery { background: var(--home-success); }

.pulse-stats {
  display: flex;
  justify-content: space-around;
  gap: 8px;
  margin-top: 13px;
  color: var(--home-muted);
  font-size: 11px;
}

.pulse-stats strong {
  color: var(--home-text);
  margin-left: 5px;
}

.ai-summary {
  border-color: #dedbff;
}

.ai-summary .section-title h2 {
  display: flex;
  align-items: center;
  gap: 7px;
}

.ai-summary .section-title h2 i {
  color: var(--home-primary);
}

.summary-body {
  padding: 14px 17px 16px;
}

.summary-item {
  position: relative;
  padding: 0 0 13px 16px;
  color: #5f6675;
  font-size: 12px;
  line-height: 1.55;
}

.summary-item::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 7px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--home-primary);
}

.summary-item strong {
  display: block;
  margin-bottom: 2px;
  color: var(--home-text);
  font-size: 13px;
}

.recommended {
  margin-top: 2px;
  padding: 12px;
  border-radius: 9px;
  background: #f6f5ff;
  color: #4d5567;
  font-size: 12px;
  line-height: 1.5;
}

.recommended-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
  color: var(--home-primary-dark);
  font-weight: 700;
}

.recommended a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  color: var(--home-primary);
  text-decoration: none;
  font-weight: 650;
}

.task-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 294px;
  gap: 14px;
  margin-top: 14px;
}

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

.task-toolbar {
  min-height: 54px;
  padding: 0 17px;
  display: flex;
  align-items: center;
  gap: 7px;
  border-bottom: 1px solid var(--home-border);
}

.task-tab {
  padding: 7px 10px;
  border: 0;
  border-radius: 8px;
  color: var(--home-muted);
  background: transparent;
  font-size: 12px;
  cursor: pointer;
}

.task-tab.active {
  color: var(--home-primary);
  background: var(--home-primary-soft);
  font-weight: 700;
}

.task-filter {
  margin-left: auto;
  padding: 7px 10px;
  border: 1px solid var(--home-border);
  border-radius: 8px;
  color: #596172;
  background: #fff;
  font-size: 12px;
}

.task-table-wrap {
  overflow-x: auto;
}

.task-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.task-table th {
  padding: 11px 15px;
  color: #6d7484 !important;
  background: #fbfbfd !important;
  border-bottom: 1px solid var(--home-border) !important;
  text-align: left;
  font-size: 11px;
}

.task-table td {
  padding: 12px 15px;
  border-bottom: 1px solid #eef0f4 !important;
  color: #596172;
  font-size: 12px;
}

.task-table tbody tr:last-child td {
  border-bottom: 0 !important;
}

.priority {
  display: inline-flex;
  min-width: 29px;
  height: 24px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}

.priority.high { color: #c92f36; background: #fff0f1; }
.priority.middle { color: #b66a09; background: #fff5e6; }
.priority.low { color: #16875b; background: #ebf8f1; }

.deadline-danger {
  color: var(--home-danger);
  font-weight: 650;
}

.person {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.person-avatar {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #465166;
  background: #e8ecf7;
  font-size: 10px;
  font-weight: 700;
}

.side-stack {
  display: grid;
  gap: 14px;
  align-content: start;
}

.warning-list {
  padding: 5px 16px 13px;
}

.warning-row {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f0f1f5;
  color: #51596a;
  font-size: 12px;
}

.warning-row:last-child {
  border-bottom: 0;
}

.warning-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--home-danger);
}

.warning-row small {
  display: block;
  margin-top: 2px;
  color: var(--home-muted);
}

.warning-row strong {
  color: var(--home-danger);
  font-size: 11px;
  text-align: right;
}

.create-list {
  padding: 10px 12px 12px;
  display: grid;
  gap: 7px;
}

.create-action {
  min-height: 38px;
  padding: 0 11px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #d9d6ff;
  border-radius: 8px;
  color: var(--home-primary);
  background: #fff;
  text-decoration: none;
  font-size: 12px;
  font-weight: 650;
}

.create-action.primary {
  border-color: var(--home-primary);
  color: #fff;
  background: var(--home-primary);
}

.recent-list {
  padding: 6px 16px 12px;
}

.recent-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  color: #596172;
  text-decoration: none;
  font-size: 12px;
}

.recent-link i {
  color: #7a8191;
}

.changelog {
  margin-top: 14px;
  padding: 0 !important;
}

.changelog-title {
  padding: 16px 18px;
  margin: 0 !important;
  border-bottom: 1px solid var(--home-border);
  color: var(--home-text) !important;
  font-size: 16px !important;
}

.changelog-table-wrap {
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

.footer {
  padding: 18px 30px 25px !important;
  color: #9aa0ad !important;
}

.ai-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100;
  max-width: 380px;
  padding: 14px 16px;
  border: 1px solid #d9d6ff;
  border-radius: 12px;
  color: #41495a;
  background: #fff;
  box-shadow: 0 18px 45px rgba(37, 38, 82, .16);
  font-size: 13px;
  line-height: 1.5;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: .2s ease;
}

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

@media (max-width: 1180px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 920px) {
  .app-shell {
    display: block;
  }
  .app-sidebar {
    position: fixed;
    left: -230px;
    width: 216px;
    transition: left .2s ease;
    box-shadow: 18px 0 45px rgba(23, 32, 51, .12);
  }
  .app-sidebar.open {
    left: 0;
  }
  .mobile-menu {
    display: grid;
    place-items: center;
  }
  .workspace {
    padding: 20px;
  }
  .workspace-heading {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }
  .ai-search {
    width: 100%;
    max-width: none;
    margin-left: 0;
  }
  .task-section {
    grid-template-columns: 1fr;
  }
  .side-stack {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 680px) {
  .auth-page::before { background-position: 65% center; }
  .auth-page::after { background: rgba(3, 11, 19, .58); }
  .app-main::before,
  .app-main::after { left: 0; top: 60px; }
  .topbar-home {
    height: 60px;
    padding: 0 14px;
  }
  .top-action,
  .user-meta {
    display: none;
  }
  .workspace {
    padding: 16px 12px 26px;
  }
  .workspace-title h1 {
    font-size: 24px;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .ai-summary {
    grid-column: auto;
  }
  .side-stack {
    grid-template-columns: 1fr;
  }
  .task-toolbar {
    overflow-x: auto;
  }
  .task-filter {
    display: none;
  }
}

/* 趋势图 */
.trend-panel {
  padding-bottom: 20px;
}
.trend-chart-area {
  padding: 18px 20px 8px;
}
.trend-legend {
  display: flex;
  gap: 18px;
  margin-bottom: 14px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--home-muted);
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}
.dot-order { background: var(--home-primary); }
.dot-delivery { background: var(--home-success); }
.trend-bars {
  height: 180px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  border-bottom: 1px solid #dfe2ea;
  padding: 0 4px;
}
.trend-day-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  height: 100%;
  justify-content: flex-end;
}
.trend-bar-pair {
  display: flex;
  gap: 2px;
  width: 100%;
  justify-content: center;
  align-items: flex-end;
  flex: 1;
}
.trend-bar {
  width: 8px;
  max-width: 14px;
  border-radius: 3px 3px 0 0;
  min-height: 3px;
  transition: height .6s ease;
  position: relative;
}
.trend-bar.order { background: var(--home-primary); opacity: .85; }
.trend-bar.delivery { background: var(--home-success); opacity: .85; }
.trend-bar:hover::after {
  content: attr(data-val);
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--home-text);
  white-space: nowrap;
  background: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
}
.trend-labels {
  display: flex;
  gap: 2px;
  margin-top: 6px;
  padding: 0 4px;
}
.trend-label {
  flex: 1;
  text-align: center;
  font-size: 10px;
  color: var(--home-muted);
}
.trend-empty {
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--home-muted);
  font-size: 13px;
}

/* 机台排产 */
.machine-panel { padding-bottom: 20px; }
.machine-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  padding: 18px 20px 8px;
}
.machine-card {
  border: 1px solid #dfe2ea;
  border-radius: 10px;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow .15s, border-color .15s;
}
.machine-card:hover {
  box-shadow: 0 3px 12px rgba(0,0,0,.08);
  border-color: var(--home-primary);
}
.machine-card .mc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.machine-card .mc-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--home-text);
}
.machine-card .mc-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.machine-card .mc-dot.idle { background: #ccc; }
.machine-card .mc-dot.active { background: var(--home-primary); animation: pulse 1.5s infinite; }
.machine-card .mc-dot.busy { background: #ff9800; animation: pulse 1.5s infinite; }
.machine-card .mc-stats {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--home-muted);
}
.machine-card .mc-stats strong {
  font-size: 18px;
  color: var(--home-text);
  font-weight: 700;
}
.machine-card .mc-bar-wrap {
  height: 6px;
  background: #f0f0f0;
  border-radius: 3px;
  overflow: hidden;
}
.machine-card .mc-bar {
  height: 100%;
  border-radius: 3px;
  transition: width .5s ease;
}
.machine-card .mc-orders {
  font-size: 12px;
  color: var(--home-muted);
  line-height: 1.5;
  max-height: 60px;
  overflow: hidden;
}
.machine-card .mc-orders .mo-item {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

.site-filing {
  padding: 18px 24px 28px;
  color: #98a2b3;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.site-filing a {
  color: inherit;
  text-decoration: none;
}

.site-filing a:hover {
  color: #2563eb;
}

.auth-page {
  flex-direction: column;
}

.auth-filing {
  position: absolute;
  right: 0;
  bottom: 24px;
  left: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  text-align: center;
}

.auth-filing a {
  color: inherit;
  text-decoration: none;
}

.auth-filing a:hover {
  color: #fff;
}
