:root {
  color-scheme: light;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  --bg: #f1f4f8;
  --card: #ffffff;
  --line: #d4dce8;
  --ink: #13253f;
  --muted: #53617a;
  --brand: #0f4aa8;
  --ok: #167f39;
  --warn: #b86f00;
  --danger: #b42424;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }

.topbar {
  background: linear-gradient(135deg, #0f2f66, #0d58c8);
  color: #fff;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar h1 { margin: 0 0 4px; font-size: 22px; }
.topbar p { margin: 0; opacity: 0.9; font-size: 13px; }

.layout { max-width: 1550px; margin: 18px auto; padding: 0 16px 28px; }
body.auth-mode .layout {
  max-width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: min(360px, 94vw);
  margin: 0;
  display: grid;
  gap: 10px;
}
.login-logo {
  width: min(200px, 70%);
  max-height: 64px;
  object-fit: contain;
  margin: 0 auto 2px;
}
.login-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 4px 12px rgba(18, 47, 96, 0.08);
}
.muted { color: var(--muted); margin: 4px 0 0; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.stat { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #fff; }
.stat h3 { margin: 0 0 8px; color: #315485; font-size: 13px; }
.stat p { margin: 0; font-size: 29px; font-weight: 700; color: #11336a; }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
label { display: block; font-size: 12px; color: #2e4a76; }
input, select {
  width: 100%;
  margin-top: 6px;
  border: 1px solid #b8c7dd;
  border-radius: 8px;
  padding: 9px 10px;
  background: #fbfdff;
}

.actions, .gate-row, .top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btn {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-secondary { background: #e9effa; color: #1b3d77; }
.btn-success { background: var(--ok); color: #fff; }
.btn-warning { background: #f3bd5d; color: #352300; }
.btn-danger { background: var(--danger); color: #fff; }

.workbench {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 14px;
}
.sidebar { min-height: 520px; }
.company-list { margin-top: 10px; display: grid; gap: 8px; max-height: 620px; overflow: auto; }
.company-item {
  text-align: left;
  border: 1px solid #c7d6f0;
  border-radius: 8px;
  background: #f6f9ff;
  color: #1c3f78;
  padding: 9px 10px;
  cursor: pointer;
}
.company-item.active { background: #0f4aa8; color: #fff; border-color: #0f4aa8; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { border-bottom: 1px solid #e8eef8; padding: 9px 8px; text-align: left; vertical-align: top; }
th { background: #f1f6ff; color: #274c84; }
code {
  display: inline-block;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.small-status { font-size: 11px; color: #4f607d; margin-top: 6px; }
.msg { margin: 8px 0 0; color: #1d427c; font-size: 13px; }
.msg-error { color: #b42424; font-weight: 600; }
.label-critical { color: #b00020; font-weight: 800; }
.upload-progress {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid #d8e2f3;
  border-radius: 10px;
  background: #f7fbff;
}
.upload-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: #24497d;
}
.upload-progress-bar {
  margin-top: 8px;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #d7e2f5;
  overflow: hidden;
}
.upload-progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0f4aa8, #1e7ed6);
  transition: width 120ms linear;
}
.hidden { display: none !important; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(9, 18, 34, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 80;
}

.modal-card {
  width: min(680px, 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(11, 31, 65, 0.25);
}

.modal-card h2 {
  margin: 0 0 6px;
  color: #123d7b;
}

.modal-value {
  margin: 8px 0 0;
  padding: 9px 10px;
  border: 1px solid #c7d6f0;
  border-radius: 8px;
  background: #f7fbff;
  color: #163560;
}

@media (max-width: 1180px) {
  .stats, .grid4, .grid2, .workbench { grid-template-columns: 1fr; }
}
