:root {
  --bg: #f3f5f7;
  --panel: #ffffff;
  --line: #d9dee4;
  --text: #1c2833;
  --muted: #6b7785;
  --accent: #1668a8;
  --accent-2: #e8f1f8;
  --warning: #8a4b00;
  --warning-bg: #fff4df;
  --error: #a12a2a;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
}
.top {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 18px; font-weight: 700; }
.top-right { display: flex; gap: 16px; align-items: center; color: var(--muted); }
.top-right a { color: var(--accent); text-decoration: none; }
.layout {
  display: grid;
  grid-template-columns: 190px 300px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  height: calc(100vh - 48px);
  min-height: 600px;
}
.companies, .orders-panel, .work-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 0;
}
.companies, .orders-panel { padding: 12px; overflow: auto; }
.work-panel { padding: 12px; display: flex; flex-direction: column; min-width: 0; }
h2 { font-size: 14px; color: var(--muted); font-weight: 600; margin: 0 0 10px; }
.company {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  padding: 10px;
  border-radius: 5px;
  margin-bottom: 6px;
  cursor: pointer;
  font-size: 14px;
}
.company.active { border-color: var(--accent); background: var(--accent-2); font-weight: 600; }
.orders-list { display: flex; flex-direction: column; gap: 6px; }
.order {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 8px;
  cursor: pointer;
  background: #fff;
}
.order.active { border-color: var(--accent); background: var(--accent-2); }
.order-title { font-weight: 600; }
.order-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.badge { display: inline-block; padding: 1px 6px; border-radius: 10px; background: #eef1f4; color: var(--muted); font-size: 11px; margin-left: 6px; }
.order-header { font-size: 15px; margin-bottom: 6px; }
.note { background: #f6f8fa; border: 1px solid var(--line); color: var(--muted); padding: 7px 9px; border-radius: 5px; margin-bottom: 8px; font-size: 12px; }
.warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #f0d7ae; padding: 7px 9px; border-radius: 5px; margin-bottom: 8px; }
.controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
.controls label { color: var(--muted); display: flex; align-items: center; gap: 5px; }
.controls select, .controls input[type=number] { padding: 4px 6px; border: 1px solid var(--line); border-radius: 4px; color: var(--text); background: #fff; }
.controls input[type=number] { width: 64px; }
.count { margin-left: auto; color: var(--muted); }
.marks-wrap { flex: 1 1 auto; min-height: 160px; overflow: auto; border: 1px solid var(--line); border-radius: 5px; }
.marks { width: 100%; border-collapse: collapse; table-layout: fixed; }
.marks th { position: sticky; top: 0; z-index: 1; background: #f8fafb; text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.marks td { padding: 5px 8px; border-bottom: 1px solid #eef1f3; vertical-align: top; }
.marks tr:hover td { background: #f8fbfd; }
.no-col { width: 70px; }
.check-col { width: 34px; }
.marks td:nth-child(3) { overflow-wrap: anywhere; }
.print-panel { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 16px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.preview-title { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
#preview { width: 320px; max-width: 100%; height: auto; border: 1px solid var(--line); background: #fff; image-rendering: pixelated; }
.muted { color: var(--muted); font-size: 12px; }
.print-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.print-button { background: var(--accent); color: #fff; border: 0; border-radius: 5px; padding: 11px 32px; font-size: 15px; font-weight: 600; cursor: pointer; }
.print-button:disabled { background: #9caab7; cursor: default; }
.status { color: var(--muted); min-height: 20px; }
.agent-status { color: var(--muted); font-size: 12px; }
.agent-status.offline { color: var(--error); }
.overlay { position: fixed; inset: 0; background: rgba(20, 35, 50, 0.35); display: flex; align-items: center; justify-content: center; z-index: 50; }
.overlay[hidden] { display: none; }
.overlay-box { background: #fff; border-radius: 8px; padding: 22px 34px; font-size: 16px; box-shadow: 0 8px 30px rgba(0,0,0,0.2); }
.login-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.login-card { width: 320px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 24px; }
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card p { margin: 0 0 14px; color: var(--muted); }
.login-card form { display: flex; flex-direction: column; gap: 10px; }
.login-card input { padding: 9px; border: 1px solid var(--line); border-radius: 5px; font-size: 14px; }
.login-card button { padding: 9px; border: 0; border-radius: 5px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
.error { background: #fff0f0; color: var(--error); padding: 8px; border-radius: 5px; margin-bottom: 10px; }
@media (max-width: 1100px) {
  .layout { grid-template-columns: 160px 260px minmax(0,1fr); }
  .print-panel { grid-template-columns: 1fr; }
}
@media (max-width: 850px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .marks-wrap { max-height: 50vh; }
}
.history-page {
  margin: 18px auto;
  max-width: 1500px;
  padding: 0 16px;
}
.history-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 12px; }
.history-head h1 { font-size: 20px; margin: 0; }
.history-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; overflow: auto; }
.history-table { width: 100%; border-collapse: collapse; }
.history-table th { background: #f8fafb; color: var(--muted); text-align: left; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.history-table td { padding: 8px 10px; border-bottom: 1px solid #eef1f3; vertical-align: top; }
.history-table tr:last-child td { border-bottom: 0; }
.history-table .nowrap { white-space: nowrap; }
.history-error { color: var(--error); max-width: 360px; overflow-wrap: anywhere; }
.status-pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; white-space: nowrap; background: #eef1f4; color: var(--muted); }
.status-done { background: #e7f6e9; color: #236b2d; }
.status-printing { background: #e8f1f8; color: var(--accent); }
.status-queued { background: #fff4df; color: var(--warning); }
.status-error { background: #fff0f0; color: var(--error); }
.history-empty { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 20px; color: var(--muted); }
.password-page { display: flex; justify-content: center; padding: 40px 16px; }
.form-card { width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 22px; }
.form-card h1 { font-size: 20px; margin: 0 0 16px; }
.form-card form { display: flex; flex-direction: column; gap: 12px; }
.form-card label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 13px; }
.form-card input { padding: 8px; border: 1px solid var(--line); border-radius: 5px; font-size: 14px; color: var(--text); background: #fff; }
.form-card button { margin-top: 4px; padding: 9px; border: 0; border-radius: 5px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
.success { background: #e7f6e9; color: #236b2d; padding: 8px; border-radius: 5px; margin-bottom: 10px; }
