/* Design system: Instrument Sans + Newsreader + IBM Plex Mono, warm
   paper background, green accent, pill status badges, sidebar shell. */

:root {
  --bg: #FAF9F5;
  --ink: #1C1B18;
  --muted: #8A867C;
  --muted2: #9A968B;
  --faint: #B4B0A6;
  --accent: #2F5233;
  --ok: #3E7C4B;
  --warn: #C1A244;
  --err: #A2402B;
  --err-dot: #C0553C;
  --card: #fff;
  --border: rgba(28, 27, 24, .09);
  --border-soft: rgba(28, 27, 24, .06);
  --border-strong: rgba(28, 27, 24, .16);
  --sb-bg: #242B22;
  --sb-ink: #F2F1EC;
  --sb-muted: rgba(242, 241, 236, .55);
  --sb-border: rgba(255, 255, 255, .12);
  --sb-hover: rgba(255, 255, 255, .07);
  --serif: 'Newsreader', Georgia, serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  font-family: 'Instrument Sans', system-ui, sans-serif;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; }
input::placeholder { color: var(--faint); }
a { color: inherit; }

@keyframes ypulse { 0% { opacity: 1 } 50% { opacity: .25 } 100% { opacity: 1 } }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 228px;
  flex: none;
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  padding: 22px 14px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .menu-toggle { display: none; }
.sidebar-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.sidebar .brand { margin: 0 10px 6px; color: var(--sb-ink); }
.sidebar .brand .logo-svg { height: 22px; width: auto; display: block; }
.sidebar .brand-sub {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--sb-muted);
  margin: 0 10px 22px;
}
.sidebar .section-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--sb-muted);
  margin: 26px 10px 8px;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--sb-ink);
  text-decoration: none;
}
.sidebar nav a:hover { background: var(--sb-hover); }
.sidebar nav a.active { background: rgba(255, 255, 255, .12); color: #fff; font-weight: 600; }
.sidebar nav a .nav-badge { font-family: var(--mono); font-size: 11px; color: var(--sb-muted); }
.sidebar .user {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-top: 1px solid var(--sb-border);
}
.sidebar .user .avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
  text-transform: uppercase;
}
.sidebar .user .name { font-size: 13px; font-weight: 600; display: block; color: var(--sb-ink); }
.sidebar .user a { font-size: 11px; color: var(--sb-muted); text-decoration: none; }
.sidebar .user a:hover { color: #fff; }

.content { flex: 1; min-width: 0; padding: 36px 44px 80px; max-width: 1160px; }

/* ---------- Page header ---------- */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}
.page-head h1 {
  font-family: var(--serif);
  font-size: 31px;
  font-weight: 500;
  letter-spacing: -.01em;
  margin: 0 0 4px;
}
.page-head .subtitle { color: var(--muted); font-size: 13.5px; }
.worker-pill {
  display: flex; align-items: center; gap: 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 7px 14px;
  font-size: 12.5px; font-weight: 500;
  flex: none; margin-top: 6px;
  white-space: nowrap;
}
.worker-pill .mono-hint { font-family: var(--mono); color: var(--muted2); font-size: 11.5px; }
.page-head-tools { display: flex; align-items: flex-start; gap: 8px; flex: none; }
.help-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted2);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  flex: none;
}
.help-btn:hover { border-color: var(--accent); color: var(--accent); }
.help-body { font-size: 13.5px; color: #3E3C36; }
.help-body p { margin: 0 0 10px; }
.help-body ul { margin: 0 0 10px; padding-left: 1.2rem; }
.help-body li { margin-bottom: 4px; }
.help-body h3 {
  font-size: 11.5px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted2);
  margin: 16px 0 6px;
}
.help-body pre {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.6;
  overflow-x: auto;
  margin: 0 0 10px;
}
.help-body code { font-family: var(--mono); font-size: 12px; background: var(--bg); border-radius: 4px; padding: 1px 5px; }
.help-body pre code { background: none; padding: 0; }
.help-body .status { vertical-align: 1px; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot-ok { background: var(--ok); }
.dot-err { background: var(--err-dot); }
.dot-warn { background: var(--warn); }
.dot-idle { background: #C9C5BB; }
.pulse { animation: ypulse 2.4s infinite; }

/* ---------- Cards & tables ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
.card-pad { padding: 20px 22px; }
.card-label {
  font-size: 12px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted2);
}
.kv { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #5F5C54; }
.kv > div { display: flex; justify-content: space-between; gap: 12px; }
.kv .v { font-family: var(--mono); font-size: 12px; color: var(--ink); }

.table-card { overflow: hidden; }
.table-scroll { overflow-x: auto; }
.trow, .thead {
  display: grid;
  gap: 14px;
  align-items: center;
  padding: 13px 22px;
  font-size: 13.5px;
}
.thead {
  padding-top: 12px; padding-bottom: 12px;
  font-size: 11px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted2);
}
.trow { border-top: 1px solid var(--border-soft); }
.trow:hover { background: var(--bg); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.mono-dim { font-family: var(--mono); font-size: 12px; color: #5F5C54; }
.mono-faint { font-family: var(--mono); font-size: 11.5px; color: var(--muted2); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-right { text-align: right; }
.dim { color: #5F5C54; }
.faint { color: var(--faint); }

/* ---------- Status pills ---------- */
.status {
  display: inline-flex; align-items: center; gap: 6px;
  justify-self: start;
  border-radius: 99px;
  padding: 3px 10px;
  font-size: 11.5px; font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}
.status .sdot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: ypulse 1.4s infinite; }
.status-received  { background: #ECEAE3; color: #5F5C54; }
.status-queued    { background: #F1EAD3; color: #7A631E; }
.status-processing{ background: #E1E9E0; color: var(--accent); }
.status-sent      { background: #E3EDE2; color: #2F5233; }
.status-error     { background: #F6E5E0; color: var(--err); }
.pill {
  display: inline-block;
  justify-self: start;
  width: fit-content;
  border-radius: 99px; padding: 3px 10px;
  font-size: 11.5px; font-weight: 600;
}
.pill-on  { background: #E3EDE2; color: #2F5233; }
.pill-off { background: #ECEAE3; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 7px 13px;
  font-size: 12.5px; font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 7px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.12); color: #fff; }
.btn-danger { color: var(--err); }
.btn-danger:hover { border-color: var(--err); color: var(--err); }
.btn-cta { padding: 9px 16px; font-size: 13px; }

.toolbar { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 16px; }

/* ---------- Filter chips ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid rgba(28, 27, 24, .14);
  background: #fff; color: #5F5C54;
  border-radius: 99px;
  padding: 6px 14px;
  font-size: 12.5px; font-weight: 600;
  cursor: pointer; text-decoration: none;
}
.chip:hover { border-color: rgba(28, 27, 24, .3); }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .count { font-family: var(--mono); font-size: 11px; opacity: .65; }

/* ---------- Dashboard ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 12px; }
.stat-card {
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 18px;
  text-decoration: none; color: inherit; display: block;
}
.stat-card:hover { border-color: rgba(28, 27, 24, .22); }
.stat-card .label { font-size: 12px; font-weight: 600; color: #5F5C54; display: flex; align-items: center; gap: 7px; text-transform: capitalize; }
.stat-card .label .dot { width: 7px; height: 7px; }
.stat-card .num { font-family: var(--serif); font-size: 34px; font-weight: 500; margin-top: 6px; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 28px; }

.laser-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--border-soft); }
.laser-row .lname { font-weight: 600; font-size: 13.5px; }
.laser-row .lmodel { font-size: 12px; color: var(--muted); }
.card-head-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-toplink { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px 12px; }
.accent-link { font-size: 12.5px; font-weight: 600; color: var(--accent); text-decoration: none; cursor: pointer; }

/* ---------- Laser / template cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.card-grid-sm { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.entity-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 22px; }
.entity-card .title { font-family: var(--serif); font-size: 20px; font-weight: 500; }
.entity-card .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.entity-card .head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; }
.entity-card .kv { border-top: 1px solid rgba(28, 27, 24, .07); padding-top: 14px; }
.entity-card .actions { display: flex; gap: 8px; margin-top: 18px; }

.tpl-frame {
  background: var(--bg); border: 1px solid rgba(28, 27, 24, .07); border-radius: 8px;
  height: 130px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px; padding: 12px;
}
.tpl-frame img { max-width: 100%; max-height: 100%; }

/* ---------- Forms ---------- */
.form-card { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 32px; max-width: 560px; }
.form-card label { display: block; font-size: 12.5px; font-weight: 600; color: #5F5C54; margin-bottom: 6px; }
.form-card .form-row, .form-card > div { margin-bottom: 16px; }
.form-card input[type=text], .form-card input[type=number], .form-card input[type=password],
.form-card select, .form-card textarea {
  width: 100%;
  border: 1px solid rgba(28, 27, 24, .14);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  outline-color: var(--accent);
}
.form-card textarea { font-family: var(--mono); font-size: 12.5px; }
.form-card input[type=checkbox] { width: auto; }
.form-card .help { font-size: 12px; color: var(--muted2); margin-top: 4px; display: block; font-weight: 400; }
.form-card ul { color: var(--err); margin: 4px 0; padding-left: 1.2rem; font-size: 12.5px; }
.form-actions { display: flex; gap: 10px; margin-top: 24px; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 28px; padding: 40px;
}
.login-logo { color: var(--ink); opacity: .92; }
.login-logo .logo-svg { height: 34px; width: auto; display: block; }
.login-card {
  width: 380px; max-width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 40px -18px rgba(28, 27, 24, .18);
  padding: 32px;
}
.login-card h1 { font-family: var(--serif); font-size: 26px; font-weight: 500; letter-spacing: -.01em; margin: 0 0 4px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: #5F5C54; }
.login-card input {
  border: 1px solid rgba(28, 27, 24, .14);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px; font-weight: 400;
  color: var(--ink);
  outline-color: var(--accent);
}
.login-card button {
  margin-top: 8px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 8px;
  padding: 11px 14px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.login-card button:hover { filter: brightness(1.12); }
.login-foot { font-family: var(--mono); font-size: 11px; color: var(--faint); }

/* ---------- Modals ---------- */
dialog.modal {
  border: none;
  border-radius: 14px;
  box-shadow: 0 24px 60px -20px rgba(28, 27, 24, .35);
  padding: 26px;
  width: 440px; max-width: 92vw;
  color: var(--ink);
}
dialog.modal::backdrop { background: rgba(28, 27, 24, .32); backdrop-filter: blur(2px); }
dialog.modal.modal-wide { width: 560px; }
.modal h2 { font-family: var(--serif); font-size: 22px; font-weight: 500; margin: 0 0 2px; }
.modal .sub { font-size: 13px; color: var(--muted); margin-bottom: 20px; }
.modal .modal-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 18px; }
.modal .close-x { font-size: 13px; color: var(--muted2); cursor: pointer; background: none; border: none; padding: 0; }
.modal .close-x:hover { color: var(--ink); }
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

.laser-options { display: flex; flex-direction: column; gap: 8px; }
.laser-option {
  display: flex; align-items: center; gap: 12px;
  border: 1.5px solid rgba(28, 27, 24, .12);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
}
.laser-option .radio {
  width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid rgba(28, 27, 24, .25);
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.laser-option input { display: none; }
.laser-option .radio::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: transparent; }
.laser-option:has(input:checked) { border-color: var(--accent); background: #F4F7F4; }
.laser-option:has(input:checked) .radio { border-color: var(--accent); }
.laser-option:has(input:checked) .radio::after { background: var(--accent); }
.laser-option .oname { font-weight: 600; font-size: 13.5px; }
.laser-option .ohint { font-size: 12px; color: var(--muted); }

.preview-stage {
  background: var(--bg);
  border: 1px solid rgba(28, 27, 24, .07);
  border-radius: 10px;
  padding: 36px;
  display: flex; align-items: center; justify-content: center;
}
.preview-stage img { max-width: 100%; max-height: 260px; background: #fff; border: 1px solid rgba(28, 27, 24, .18); border-radius: 6px; }
.preview-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }

.error-banner {
  margin: 0 22px 12px;
  padding: 8px 12px;
  background: #F9EFEB;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--err);
}

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--ink); color: #F5F4F0;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 13px; font-weight: 500;
  box-shadow: 0 12px 30px -10px rgba(28, 27, 24, .4);
  display: flex; align-items: center; gap: 9px;
  transition: opacity .4s;
}
.toast .dot { width: 7px; height: 7px; }

/* ---------- API docs ---------- */
.copy-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.copy-value {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 8px 12px;
  word-break: break-all;
  flex: 1;
  min-width: 200px;
}
.method-tag {
  display: inline-block;
  background: var(--accent); color: #fff;
  border-radius: 5px;
  padding: 1px 7px;
  font-size: 10.5px; font-weight: 600;
  letter-spacing: .05em;
  margin-right: 6px;
  vertical-align: 1px;
}
.hint { font-size: 12.5px; color: var(--muted); margin: 10px 0 0; }
.hint code { font-family: var(--mono); font-size: 11.5px; background: var(--bg); border-radius: 4px; padding: 1px 5px; }
.code-block {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.6;
  overflow-x: auto;
  margin: 0;
}

/* ---------- Column layouts ---------- */
.cols-jobs      { grid-template-columns: 80px 130px 1.2fr 1fr 120px 105px 70px 150px; min-width: 940px; }
.cols-orders    { grid-template-columns: 150px 100px 1.2fr 70px 1fr 130px; min-width: 760px; }
.cols-products  { grid-template-columns: 1.4fr 100px 130px 1fr 90px 110px; min-width: 780px; }
.cols-settings  { grid-template-columns: 1.4fr 1fr 90px 90px 110px 80px 110px; min-width: 800px; }
.cols-recent    { grid-template-columns: 70px 1.3fr 1fr 110px 90px; min-width: 620px; }
.table-inner { min-width: min-content; }

@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 12px 16px;
  }
  .sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .sidebar .brand { margin: 0; }
  .sidebar .brand .logo-svg { height: 20px; }
  .sidebar .brand-sub { margin: 2px 0 0; }
  .sidebar .menu-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px;
    background: none;
    border: 1px solid var(--sb-border);
    border-radius: 8px;
    color: var(--sb-ink);
    cursor: pointer;
    flex: none;
  }
  .sidebar-body { display: none; }
  .sidebar.open .sidebar-body { display: flex; flex-direction: column; padding-top: 16px; }
  .sidebar .section-label { margin: 18px 10px 8px; }
  .sidebar .user { margin-top: 16px; }
  .content { padding: 24px 18px 60px; }
  .page-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .page-head-tools { align-items: center; justify-content: space-between; }
  .worker-pill, .help-btn { margin-top: 0; }
}
