:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #f9fafc;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #d9dee8;
  --brand: #1f6feb;
  --brand-2: #144ea6;
  --green: #14804a;
  --yellow: #b7791f;
  --red: #c2410c;
  --blue: #1d4ed8;
  --shadow: 0 10px 30px rgba(17, 24, 39, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

button, input, select, textarea {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #eef4ff 0%, #f7fafc 45%, #edf7f4 100%);
}

.login-card {
  width: min(460px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 8px;
  padding: 28px;
}

.login-logo {
  display: block;
  width: min(320px, 100%);
  height: auto;
  margin: 0 auto 20px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.login-card p {
  margin: 0 0 22px;
  color: var(--muted);
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
}

.sidebar {
  background: #101827;
  color: #dbe4f0;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 8px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 14px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: var(--brand);
  display: grid;
  place-items: center;
  color: white;
  font-weight: 800;
}

.brand-logo-box {
  width: 64px;
  height: 34px;
  border-radius: 7px;
  background: #fff;
  border: 1px solid rgba(255,255,255,0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  flex: 0 0 auto;
}

.brand-logo-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.brand strong { display: block; color: white; }
.brand span { display: block; color: #9aa8bd; font-size: 12px; }

.nav-section {
  margin: 18px 0 6px;
  padding: 0 10px;
  color: #8090a8;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 10px;
  border-radius: 7px;
  color: #cdd6e3;
}

.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,0.08);
  color: white;
}

.main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  height: 66px;
  background: rgba(255,255,255,0.88);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 3;
  backdrop-filter: blur(12px);
}

.page {
  padding: 24px;
}

.page-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.page-title h1 {
  margin: 0;
  font-size: 24px;
}

.page-title p {
  margin: 5px 0 0;
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 14px;
}

.cards {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.card, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(17,24,39,0.03);
}

.card {
  padding: 16px;
}

.card .label {
  color: var(--muted);
  font-size: 12px;
}

.card .value {
  margin-top: 8px;
  font-size: 25px;
  font-weight: 750;
}

.panel {
  padding: 16px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 16px;
}

.split {
  display: grid;
  grid-template-columns: 1.35fr 0.9fr;
  gap: 14px;
  margin-top: 14px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.input, .select, textarea {
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  border-radius: 7px;
  padding: 9px 10px;
  min-height: 38px;
  outline: none;
}

textarea { width: 100%; min-height: 80px; resize: vertical; }
.input:focus, .select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31,111,235,0.12); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  min-height: 38px;
  padding: 9px 12px;
  background: white;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { border-color: #a8b3c5; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: white; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--red); border-color: #f2c3ad; }
.btn.small { min-height: 30px; padding: 6px 9px; font-size: 12px; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 840px;
  background: white;
}

th, td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

tr:hover td { background: #fbfdff; }

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: #465367;
  font-size: 12px;
  white-space: nowrap;
}

.tag.green { background: #e8f6ee; color: var(--green); }
.tag.yellow { background: #fff7e6; color: var(--yellow); }
.tag.red { background: #fff0ea; color: var(--red); }
.tag.blue { background: #edf4ff; color: var(--blue); }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.field {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
}

.field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  color: #374151;
  font-size: 12px;
}

.form-grid .full { grid-column: 1 / -1; }

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  border-left: 3px solid var(--brand);
  padding: 2px 0 2px 12px;
}

.timeline-item strong { display: block; }
.timeline-item span { color: var(--muted); font-size: 12px; }

.muted { color: var(--muted); }
.right { text-align: right; }
.hidden { display: none !important; }
.notice {
  padding: 10px 12px;
  border-radius: 7px;
  background: #fff7e6;
  color: #7c4a03;
  border: 1px solid #f5d38a;
}

.factory-shell .sidebar { background: #15202f; }
.factory-shell .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .cards, .split, .detail-grid, .form-grid { grid-template-columns: 1fr; }
  .topbar { position: relative; padding: 0 14px; }
  .page { padding: 16px; }
}
