/* ==========================================================================
   Factory Analytics Dashboard - design tokens
   Industrial / technical-drawing inspired: cool steel-gray surfaces,
   hairline blueprint borders, IBM Plex for a spec-sheet feel, and a
   segmented "shift-strip" motif (one tick per shift code) used
   structurally throughout - not decoration, it's literally the same
   structure that organizes the factory floor.
   ========================================================================== */

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

:root {
  --bg: #F1F2F3;
  --surface: #FFFFFF;
  --ink: #14181B;
  --ink-muted: #5B6368;
  --line: #D9DCDE;
  --accent: #C97A1F;
  --accent-ink: #7A4A12;
  --success: #3F7D58;
  --success-bg: #E8F1EB;
  --danger: #B23A48;
  --danger-bg: #F6E7E8;
  --warning: #C97A1F;
  --warning-bg: #FBF0DF;

  --font-display: 'IBM Plex Sans', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SF Mono', monospace;

  /* Shift-code colors - used consistently for the strip motif and any
     shift-code badge anywhere in the UI. */
  --shift-a: #4C7A9E;
  --shift-b: #6B8F5C;
  --shift-c: #8B5FA3;
  --shift-d: #C97A1F;
  --shift-n: #3E4C6B;
  --shift-g: #A3A14C;
  --shift-o: #B8BCBF;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* -------------------------------------------------------------------- */
/* Shift strip - the signature element. A thin segmented bar, one tick
   per shift code, used as a structural divider / freshness indicator. */
/* -------------------------------------------------------------------- */
.shift-strip {
  display: flex;
  height: 4px;
  width: 100%;
  border-radius: 2px;
  overflow: hidden;
}
.shift-strip span { flex: 1; }
.shift-strip .a { background: var(--shift-a); }
.shift-strip .b { background: var(--shift-b); }
.shift-strip .c { background: var(--shift-c); }
.shift-strip .d { background: var(--shift-d); }
.shift-strip .n { background: var(--shift-n); }
.shift-strip .g { background: var(--shift-g); }

.shift-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: #fff;
}
.shift-badge.a { background: var(--shift-a); }
.shift-badge.b { background: var(--shift-b); }
.shift-badge.c { background: var(--shift-c); }
.shift-badge.d { background: var(--shift-d); }
.shift-badge.n { background: var(--shift-n); }
.shift-badge.g { background: var(--shift-g); }
.shift-badge.o { background: var(--shift-o); color: var(--ink-muted); }

/* -------------------------------------------------------------------- */
/* Layout                                                                */
/* -------------------------------------------------------------------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.brand small {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 11px;
  color: var(--ink-muted);
  text-transform: none;
  letter-spacing: 0;
}
.nav { display: flex; gap: 4px; padding-bottom: 12px; }
.nav a {
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  color: var(--ink-muted);
  padding: 7px 12px;
  border-radius: 6px;
}
.nav a:hover { color: var(--ink); background: var(--bg); }
.nav a.active { color: var(--ink); background: var(--bg); }
.topbar .shift-strip { margin-top: 12px; }
.user-chip {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
}
.user-chip a { color: var(--ink-muted); text-decoration: underline; }

.page { max-width: 1180px; margin: 0 auto; padding: 28px 24px 64px; }

.page-header { margin-bottom: 22px; }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-ink);
  margin-bottom: 4px;
}
h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  margin: 0;
}
.page-header p { color: var(--ink-muted); margin: 6px 0 0; font-size: 14px; }

/* -------------------------------------------------------------------- */
/* Cards                                                                 */
/* -------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 20px;
}
.card-header {
  padding: 16px 20px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.card-header h2 { font-family: var(--font-display); font-size: 15px; font-weight: 600; margin: 0; }
.card-header .freshness { font-family: var(--font-mono); font-size: 11px; color: var(--ink-muted); }
.card-body { padding: 4px 20px 20px; }
.card-body.tight { padding: 0; }
.card-empty { padding: 32px 20px; text-align: center; color: var(--ink-muted); font-size: 13px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

/* -------------------------------------------------------------------- */
/* Tables                                                                */
/* -------------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  padding: 8px 20px;
  border-bottom: 1px solid var(--line);
}
td { padding: 9px 20px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: none; }
td.num, th.num { font-family: var(--font-mono); text-align: right; }

.pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
}
.pill.ok { background: var(--success-bg); color: var(--success); }
.pill.bad { background: var(--danger-bg); color: var(--danger); }
.pill.warn { background: var(--warning-bg); color: var(--warning); }
.pill.muted { background: var(--bg); color: var(--ink-muted); }

/* -------------------------------------------------------------------- */
/* Forms                                                                 */
/* -------------------------------------------------------------------- */
label { display: block; font-size: 12px; font-weight: 500; margin-bottom: 4px; color: var(--ink-muted); }
input, select, textarea {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.field { margin-bottom: 14px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

button, .btn {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, .btn:hover { opacity: 0.92; }
.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}

.flash {
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
}
.flash.error { background: var(--danger-bg); color: var(--danger); }
.flash.success { background: var(--success-bg); color: var(--success); }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 340px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
}
.login-card .shift-strip { margin-bottom: 20px; }

.log-line {
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  padding: 3px 20px;
  border-bottom: 1px solid var(--line);
}
.log-line.level-ERROR { color: var(--danger); background: var(--danger-bg); }
.log-line.level-WARNING { color: var(--accent-ink); background: var(--warning-bg); }
