:root {
  --bg: #f4f6f9;
  --surface: #fff;
  --line: #e8ecf1;
  --text: #1a2332;
  --muted: #64748b;
  --side: #12161d;
  --primary: #15803d;
  --blue: #2563eb;
  --green: #16a34a;
  --red: #dc2626;
  --orange: #d97706;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.05);
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  font: 14px/1.5 "IBM Plex Sans", "PingFang SC", "Noto Sans SC", sans-serif;
  color: var(--text);
  background: var(--bg);
}
#app {
  height: 100%;
  min-height: 100dvh;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #121418;
}
.login-card {
  width: min(400px, 92vw);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: 0 16px 40px rgba(0,0,0,.28);
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card p { margin: 0 0 16px; color: var(--muted); }
label { display: grid; gap: 6px; margin-bottom: 12px; color: var(--muted); font-size: 13px; }
input, textarea, select {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
}
.btn {
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 6px;
  padding: 7px 12px;
}
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  width: 100%;
  padding: 10px;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.err { color: var(--red); margin: 0 0 10px; }
.ok { color: var(--green); }

.shell {
  min-height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  overflow: hidden;
}
.rail {
  background: var(--side);
  color: #e8eaed;
  overflow: auto;
}
.rail-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
}
.rail-brand img { width: 28px; height: 28px; border-radius: 6px; }
.rail-brand strong { display: block; font-size: 14px; }
.rail-brand small { color: #9aa3af; font-size: 11px; }
.rail-group {
  margin: 6px 14px 8px;
  font-size: 11px;
  letter-spacing: .08em;
  color: #7b8494;
  text-transform: uppercase;
}
.nav { display: grid; padding: 0 8px 16px; }
.nav a {
  padding: 8px 11px;
  border-radius: 6px;
  color: #c5ccd6;
  font-size: 14px;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.on { background: var(--primary); color: #fff; font-weight: 600; }

.main {
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.crumb { font-weight: 600; }
.top-actions { display: flex; gap: 8px; align-items: center; color: var(--muted); }
.body {
  min-height: 0;
  overflow: hidden;
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
}
.body > .page {
  flex: 1;
  min-height: 0;
}
.page {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}
.page.page-table {
  overflow: hidden;
}
.page.page-table > .table-panel,
.page.page-table > .split-fill {
  flex: 1;
  min-height: 0;
}
.page-note { margin: 0; flex: 0 0 auto; font-size: 13px; }
.page-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 11px;
}
.kpi {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 15px;
  min-height: 76px;
  display: grid;
  align-content: space-between;
}
.kpi span { font-size: 12px; color: var(--muted); }
.kpi b { font-size: 22px; letter-spacing: -.03em; overflow-wrap: anywhere; }
.kpi.blue b { color: var(--blue); }
.kpi.green b { color: var(--green); }
.kpi.red b { color: var(--red); }
.kpi.orange b { color: var(--orange); }
.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.panel h3 { margin: 0 0 10px; font-size: 15px; }
.panel-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.panel-head h3 { margin: 0; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.split-fill {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: stretch;
  min-height: 0;
}
.split-fill > .table-panel {
  min-height: 0;
}
.stack { display: grid; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.table-wrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.table-wrap.data-scroll {
  flex: 1;
  min-height: 0;
  max-height: 100%;
}
.table-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}
.table-panel .table-wrap {
  flex: 1;
  min-height: 0;
}
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; table-layout: fixed; }
.data-table th,
.data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
}
.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  box-shadow: inset 0 -1px 0 #e8ecf1;
}
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr:last-child td { border-bottom: none; }
.col-time { width: 148px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.col-account { width: 108px; }
.col-dir { width: 72px; }
.col-status { width: 88px; }
.col-phone { width: 124px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; word-break: break-all; }
.col-body { word-break: break-word; line-height: 1.45; }
.col-actions { width: 220px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 7px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; }
.empty { text-align: center; color: #9ca3af; padding: 22px 8px !important; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.badge-ok { background: #ecfdf3; color: #15803d; }
.badge-bad { background: #fef2f2; color: #b91c1c; }
.badge-muted { background: #f1f5f9; color: #475569; }
.badge-in { background: #eff6ff; color: #1d4ed8; }
.badge-out { background: #f0fdf4; color: #15803d; }
.muted { color: var(--muted); }
.error-box {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 13px;
}
.toolbar { display: flex; gap: 10px; align-items: center; }
.row-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.check-row { display: flex; align-items: center; gap: 8px; }
code { background: #f3f4f6; padding: 1px 6px; border-radius: 4px; }
#toast {
  position: fixed; right: 20px; bottom: 20px; display: none;
  background: #111827; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 80;
}
.pwd-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: center;
}
.pwd-wrap input { margin: 0; }
.pwd-toggle {
  border: 1px solid #d1d5db;
  background: #f8fafc;
  border-radius: 6px;
  padding: 8px 10px;
  white-space: nowrap;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: grid;
  place-items: center;
  z-index: 90;
  padding: 16px;
}
.modal-card {
  width: min(460px, 96vw);
  background: #fff;
  border-radius: 10px;
  padding: 22px 20px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.22);
}
.modal-card h3 { margin: 0 0 8px; font-size: 18px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}
.modal-actions .btn-primary { width: auto; }
.cred-box {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
}
.cred-box div {
  display: grid;
  gap: 4px;
}
.cred-box span {
  font-size: 12px;
  color: var(--muted);
}
.cred-box b, .cred-box a {
  font-size: 15px;
  word-break: break-all;
}
.cred-pwd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.02em;
}
.page-err {
  margin: 0 0 12px;
}
.pwd-cell {
  min-width: 140px;
}
.cred-inline {
  display: inline-block;
  margin-right: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.btn-mini {
  padding: 2px 8px;
  font-size: 12px;
}
.supplier-panel {
  margin-bottom: 14px;
  border: 1px solid #bbf7d0;
  background: linear-gradient(180deg, #f0fdf4 0%, #fff 100%);
}
.supplier-panel h3 {
  margin: 0;
  font-size: 16px;
}
.supplier-panel .panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
@media (max-width: 1100px) {
  .kpis, .split, .grid-2 { grid-template-columns: 1fr 1fr; }
  .data-table { table-layout: auto; min-width: 860px; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .nav { display: flex; width: max-content; overflow-x: auto; }
  .nav a { white-space: nowrap; }
  .rail-group { display: none; }
  .kpis, .split, .grid-2 { grid-template-columns: 1fr; }
  .body { padding: 12px; }
}
