@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --accent: #4338ca;
  --accent-light: #eef2ff;
  --ink: #14141f;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #fafafa;
  --ok: #16a34a;
  --warn: #b45309;
  --err: #dc2626;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

code, .mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: #fff;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 20px 20px; border-bottom: 1px solid var(--border); }
.brand-mark { width: 36px; height: 36px; border-radius: 8px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 12px; color: var(--muted); }

.nav { padding: 16px 12px; flex: 1; }
.nav a { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 14px; margin-bottom: 2px; }
.nav a:hover { background: #f4f4f6; }
.nav a.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.nav .badge { font-size: 12px; color: var(--muted); }
.nav a.active .badge { color: var(--accent); }
.nav .badge.warn { color: var(--warn); font-weight: 600; }

.sidebar-footer { padding: 14px 20px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 6px; }
.status-dot.stopped { background: #9ca3af; }

.main { flex: 1; padding: 28px 36px; max-width: 1200px; }

.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.page-header h1 { margin: 0 0 4px; font-size: 22px; }
.page-header p { margin: 0; color: var(--muted); font-size: 14px; }
.header-actions { display: flex; gap: 10px; align-items: center; }

.btn { border: 1px solid var(--border); background: #fff; padding: 9px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--ink); white-space: nowrap; text-decoration: none; display: inline-block; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-danger { background: #fff; color: var(--err); border-color: #fecaca; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.card-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 8px; }
.card-value { font-size: 30px; font-weight: 700; }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.card-value.warn { color: var(--warn); }
.card-value.err { color: var(--err); }

.panel { background: #fff; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 20px; overflow: hidden; }
.panel-title { padding: 16px 20px; font-weight: 600; border-bottom: 1px solid var(--border); font-size: 14px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 10px 20px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafafa; border-bottom: 1px solid var(--border); }
td { padding: 12px 20px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
a.po-link { color: var(--accent); font-family: 'IBM Plex Mono', monospace; font-weight: 500; text-decoration: none; }
a.po-link:hover { text-decoration: underline; }

.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.pill-fabric { background: #ecfdf5; color: #047857; }
.pill-accessories { background: #fef3c7; color: #92400e; }
.pill-unknown { background: #f3f4f6; color: var(--muted); }
.pill-completed { background: #ecfdf5; color: #047857; }
.pill-review { background: #fffbeb; color: #92400e; }
.pill-rejected { background: #fef2f2; color: #b91c1c; }
.pill-error { background: #fef2f2; color: #b91c1c; }
.pill-resolved { background: #f3f4f6; color: var(--muted); }

.empty-state { padding: 48px 20px; text-align: center; color: var(--muted); font-size: 14px; }

.review-layout { display: grid; grid-template-columns: 320px 1fr; gap: 20px; align-items: start; }
.queue-list { background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.queue-item { display: block; padding: 14px 16px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--ink); }
.queue-item:last-child { border-bottom: none; }
.queue-item:hover { background: #f9fafb; }
.queue-item.active { background: var(--accent-light); border-left: 3px solid var(--accent); }
.queue-item .qi-po { font-family: 'IBM Plex Mono', monospace; font-weight: 600; font-size: 13px; }
.queue-item .qi-time { float: right; color: var(--muted); font-size: 12px; }
.queue-item .qi-supplier { font-size: 13px; margin: 4px 0 2px; }
.queue-item .qi-reason { font-size: 12px; color: var(--muted); }

.detail-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 22px; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.detail-head h2 { margin: 0; font-size: 17px; }
.detail-head .filename { font-size: 12px; color: var(--muted); font-family: 'IBM Plex Mono', monospace; }
.detail-actions { display: flex; gap: 8px; }

.gate-note { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 8px; padding: 12px 16px; font-size: 13px; margin-bottom: 18px; }

.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin-bottom: 4px; }
.field-label { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: .03em; margin-bottom: 3px; }
.field-value { font-size: 14px; font-family: 'IBM Plex Mono', monospace; }

.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 22px 0 10px; }

.kw-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.kw-list { display: flex; flex-wrap: wrap; gap: 6px; }
.kw-chip { background: #f4f4f6; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-family: 'IBM Plex Mono', monospace; }

.dept-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.dept-row:last-child { border-bottom: none; }
.dept-name { font-weight: 600; font-size: 14px; }
.dept-email { font-size: 13px; color: var(--muted); font-family: 'IBM Plex Mono', monospace; }

.threshold-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.threshold-row:last-child { border-bottom: none; }
.threshold-label { font-size: 14px; }
.threshold-sub { font-size: 12px; color: var(--muted); }
.threshold-value { font-family: 'IBM Plex Mono', monospace; font-weight: 600; }

.nav-tabs { display: flex; gap: 6px; margin-bottom: 16px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.nav-tabs a { padding: 7px 14px; border-radius: 999px; font-size: 13px; text-decoration: none; color: var(--muted); border: 1px solid var(--border); white-space: nowrap; flex-shrink: 0; }
.nav-tabs a.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- Responsive ---------- */

.panel { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.panel table { min-width: 640px; }

.nav-toggle-input { display: none; }
.topbar { display: none; }
.nav-scrim { display: none; }

@media (max-width: 900px) {
  .layout { flex-direction: column; min-height: auto; }

  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 30;
  }
  .topbar .brand-mark { width: 30px; height: 30px; font-size: 12px; }
  .topbar .brand-name { font-size: 14px; }
  .topbar .brand-sub { display: none; }

  .hamburger { display: flex; flex-direction: column; gap: 4px; cursor: pointer; padding: 8px; margin: -8px; }
  .hamburger span { width: 22px; height: 2px; background: var(--ink); display: block; border-radius: 1px; }

  .sidebar {
    position: fixed; top: 0; left: -280px; width: 260px; height: 100%;
    z-index: 50; transition: left .2s ease; box-shadow: 2px 0 20px rgba(0,0,0,.15);
    overflow-y: auto; padding: 16px 0;
  }
  .sidebar-brand { display: block; }
  .nav-toggle-input:checked ~ .layout .sidebar { left: 0; }
  .nav-toggle-input:checked ~ .layout .nav-scrim {
    display: block; position: fixed; inset: 0; background: rgba(17,17,26,.4); z-index: 40;
  }

  .main { padding: 16px; max-width: 100%; }

  .page-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-header h1 { font-size: 19px; }
  .header-actions { width: 100%; flex-wrap: wrap; }
  .header-actions form, .header-actions .btn { flex: 1; }

  .cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card { padding: 14px; }
  .card-value { font-size: 22px; }

  .review-layout { grid-template-columns: 1fr; }
  .queue-list { max-height: 280px; overflow-y: auto; }

  .kw-cols { grid-template-columns: 1fr; gap: 16px; }

  .field-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }

  .detail-actions { flex-wrap: wrap; width: 100%; }
  .detail-actions form, .detail-actions .btn { flex: 1; }
  .detail-head { flex-direction: column; align-items: stretch; gap: 12px; }

  .dept-row, .threshold-row { flex-wrap: wrap; gap: 6px; }

  th, td { padding: 10px 14px; }
}

@media (max-width: 480px) {
  .cards { grid-template-columns: 1fr; }
  .main { padding: 12px; }
  .panel-title { padding: 14px 16px; }
  th, td { padding: 9px 12px; font-size: 12px; }
}
