/* Agent Console — align MES light workbench tokens */
:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: #e5e7eb;
  --accent: #1e3a5f;
  --accent-hover: #163050;
  --link: #1890ff;
  --text: #1f2937;
  --muted: #64748b;
  --subtle: #94a3b8;
  --hover: #f1f5f9;
  --active: #e8f4ff;
  --success: #059669;
  --amber: #d97706;
  --danger: #dc2626;
  --sidebar-w: 220px;
  --header-h: 3.5rem;
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans SC",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

code,
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8125em;
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: var(--link);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* —— Login —— */
.login-shell {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.login-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.login-header__title {
  font-size: 15px;
  font-weight: 600;
  color: #0f172a;
}
.login-header__sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}
.login-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: radial-gradient(ellipse 80% 50% at 50% -10%, rgba(30, 58, 95, 0.08), transparent 55%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 22.5rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface);
  padding: 2rem 1.75rem 1.75rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  text-align: center;
}
.login-card h1 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
}
.login-card .hint {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}
.login-field {
  margin-top: 1.1rem;
  text-align: left;
}
.login-field label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.login-field input,
.login-field select {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  padding: 0.5rem 0.65rem;
  font-size: 0.875rem;
  background: #fff;
}
.login-field input:focus,
.login-field select:focus {
  outline: none;
  border-color: var(--link);
  box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.15);
}
.login-error {
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--danger);
  text-align: left;
}
.login-submit {
  margin-top: 1.25rem;
  width: 100%;
  border: 0;
  border-radius: 0.375rem;
  padding: 0.55rem 1rem;
  background: var(--accent);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}
.login-submit:hover {
  background: var(--accent-hover);
}
.login-demo {
  margin-top: 1rem;
  font-size: 0.6875rem;
  color: var(--subtle);
  line-height: 1.5;
  text-align: left;
}

/* —— App shell —— */
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
}
.app-header {
  height: var(--header-h);
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  box-sizing: border-box;
}
.brand-left {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.625rem;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.brand-block {
  min-width: 0;
}
.brand-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.25;
  color: #0f172a;
}
.brand-sub {
  margin-top: 1px;
  font-size: 11px;
  line-height: 1.25;
  color: var(--muted);
}
.header-right {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  font-size: 12px;
  color: var(--muted);
}
.header-factory {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.header-factory span {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--muted);
}
.header-factory select {
  height: 2rem;
  min-width: 168px;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  background: #fff;
  padding: 0 0.5rem;
  font-size: 12px;
  color: var(--text);
}
.header-factory select:focus {
  outline: none;
  border-color: var(--link);
  box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.15);
}
.header-user {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 12px;
  color: #334155;
}
.header-user .role {
  color: var(--subtle);
  font-size: 11px;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  font-size: 10px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--hover);
  color: var(--muted);
}
.badge.ok {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: var(--success);
}
.badge.warn {
  background: #fffbeb;
  border-color: #fde68a;
  color: var(--amber);
}
.badge.bad {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--danger);
}
.badge.idle {
  background: #f8fafc;
  color: var(--muted);
}
.btn {
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--surface);
  color: var(--text);
  padding: 0.35rem 0.7rem;
  font-size: 0.75rem;
  cursor: pointer;
}
.btn:hover {
  background: var(--hover);
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover {
  background: var(--accent-hover);
}
.btn.danger {
  color: var(--danger);
  border-color: #fecaca;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-link {
  border: 0;
  background: none;
  color: var(--link);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
}
.app-body {
  flex: 1;
  min-height: 0;
  display: flex;
}
.app-footer {
  flex-shrink: 0;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: 11px;
  color: #64748b;
}
.app-footer .left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.app-footer .left .dot {
  color: #cbd5e1;
}
.app-footer .right {
  flex-shrink: 0;
  color: #94a3b8;
  white-space: nowrap;
}
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-meta {
  padding: 0.75rem 0.875rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-meta .t {
  font-size: 11px;
  font-weight: 600;
  color: #334155;
}
.sidebar-meta .s {
  font-size: 10px;
  color: var(--subtle);
  margin-top: 2px;
}
.sidebar-nav {
  flex: 1;
  overflow: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-group-label {
  margin: 0.55rem 0.35rem 0.2rem;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--subtle);
  text-transform: uppercase;
}
.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  color: #475569;
  border: 1px solid transparent;
  border-left: 3px solid transparent;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.nav-btn:hover {
  background: var(--hover);
  color: var(--text);
}
.nav-btn.active {
  background: var(--active);
  color: var(--accent);
  border-left-color: var(--link);
  font-weight: 600;
}
.nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.nav-btn .ico {
  width: 1rem;
  text-align: center;
  color: var(--subtle);
  font-size: 0.7rem;
}
.nav-btn.active .ico {
  color: #0284c7;
}
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.page-toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.page-toolbar h2 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}
.page-toolbar .desc {
  font-size: 0.75rem;
  color: var(--muted);
  flex: 1;
  min-width: 12rem;
}
.page-toolbar .actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-left: auto;
}
.page-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 1rem;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}
.panel + .panel {
  margin-top: 0.75rem;
}
.panel-hd {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.875rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
  font-weight: 600;
}
.panel-bd {
  padding: 0.875rem;
}
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}
.kpi {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
  padding: 0.75rem 0.875rem;
}
.kpi .lab {
  font-size: 0.6875rem;
  color: var(--muted);
}
.kpi .val {
  margin-top: 0.25rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
}
.kpi .sub {
  margin-top: 0.15rem;
  font-size: 0.6875rem;
  color: var(--subtle);
}
.table-wrap {
  overflow: auto;
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}
table.data th,
table.data td {
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.data th {
  color: var(--muted);
  font-weight: 600;
  background: #fafbfc;
  white-space: nowrap;
}
table.data tr:hover td {
  background: #fafbfc;
}
.input,
.select,
.textarea {
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  background: #fff;
  padding: 0.35rem 0.5rem;
  font-size: 0.75rem;
  color: var(--text);
}
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--link);
  box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.15);
}
.textarea {
  width: 100%;
  min-height: 6rem;
  resize: vertical;
  font-family: inherit;
  line-height: 1.45;
}
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.65rem;
}
.form-row label {
  font-size: 0.75rem;
  color: var(--muted);
  min-width: 4.5rem;
}
.muted {
  color: var(--muted);
  font-size: 0.75rem;
}
.empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--subtle);
  font-size: 0.8125rem;
}
.tag {
  display: inline-block;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid var(--border);
  margin-right: 2px;
}
.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 40;
  display: flex;
  justify-content: flex-end;
}
.drawer {
  width: min(440px, 100%);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 24px rgba(15, 23, 42, 0.08);
}
.drawer-hd {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.875rem;
}
.drawer-bd {
  flex: 1;
  overflow: auto;
  padding: 1rem;
  font-size: 0.8125rem;
  line-height: 1.5;
}
.drawer-bd pre {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  padding: 0.65rem;
  overflow: auto;
  font-size: 0.7rem;
  white-space: pre-wrap;
}
.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 50;
  background: #0f172a;
  color: #fff;
  padding: 0.55rem 0.85rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.toast.show {
  opacity: 1;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
@media (max-width: 900px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .sidebar {
    width: 180px;
  }
}
.perm-denied {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--muted);
}
.perm-denied h3 {
  margin: 0 0 0.5rem;
  color: var(--text);
}
