:root {
  --bg: #07111f;
  --bg-accent: #0b1f37;
  --card: rgba(8, 20, 37, 0.78);
  --text: #e5f0ff;
  --muted: #8ea5c5;
  --line: rgba(110, 160, 255, 0.18);
  --primary: #1890ff;
  --primary-strong: #0f5fd7;
  --primary-soft: rgba(24, 144, 255, 0.16);
  --success: #35d39a;
  --danger: #ff6b7c;
  --shadow: 0 30px 80px rgba(0, 12, 30, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(24, 144, 255, 0.28), transparent 30%),
    radial-gradient(circle at top right, rgba(45, 118, 255, 0.2), transparent 24%),
    radial-gradient(circle at bottom right, rgba(55, 211, 154, 0.12), transparent 18%),
    linear-gradient(180deg, var(--bg-accent), var(--bg));
  overflow-x: hidden;
}

.app {
  width: 100vw;
  min-height: 100vh;
  margin: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 20px 22px;
  background: linear-gradient(135deg, rgba(11, 31, 55, 0.92), rgba(12, 45, 84, 0.72));
  border: 1px solid rgba(125, 180, 255, 0.16);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.topbar h1 {
  margin: 0;
  min-width: 0;
  font-size: clamp(1.8rem, 3vw, 2.7rem);
  letter-spacing: -0.04em;
}

.auth-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

#roleBadge {
  display: inline-flex;
  align-items: center;
  background: linear-gradient(135deg, var(--primary-strong), var(--primary));
  color: #fff;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  min-height: 40px;
}

input,
textarea,
select,
button {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 13px;
  background: rgba(13, 31, 55, 0.78);
  color: var(--text);
}

input::placeholder,
textarea::placeholder {
  color: rgba(188, 208, 235, 0.58);
}

button {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #fff;
  cursor: pointer;
  border: 0;
  box-shadow: 0 18px 35px rgba(15, 95, 215, 0.28);
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 22px 40px rgba(15, 95, 215, 0.34);
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 18px 0;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tab {
  background: rgba(13, 31, 55, 0.64);
  color: var(--text);
  box-shadow: none;
  border: 1px solid rgba(125, 180, 255, 0.16);
}

.tab.active {
  background: linear-gradient(135deg, #1890ff, #0f5fd7);
  color: #fff;
}

.panel {
  display: none;
  background: var(--card);
  border: 1px solid rgba(125, 180, 255, 0.14);
  border-radius: 24px;
  padding: 20px;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.panel.active {
  display: block;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 12px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(9, 26, 48, 0.7);
  border-radius: 18px;
  overflow: hidden;
}

#requisitesTable,
#ordersTable,
#nonIssTable,
#reqLogsTable,
#cbLogsTable,
#cbJobsTable {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

th,
td {
  border: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  background: rgba(24, 144, 255, 0.12);
}

.actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.hidden {
  display: none !important;
}

.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.login-box {
  background: var(--card);
  border-radius: 24px;
  padding: 40px 36px;
  width: 340px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-box h2 {
  margin: 0;
  font-size: 1.4rem;
}

.login-box p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.login-box form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.login-box label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  font-weight: 500;
}

.login-box input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
}

.login-box input:focus {
  border-color: var(--primary);
}

.login-box button[type="submit"] {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 11px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
}

.login-box button[type="submit"]:hover {
  opacity: 0.9;
}

.login-error {
  color: #dc2626;
  font-size: 0.85rem;
  text-align: center;
}

#requisiteEditForm {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #091427;
  color: #e2e8f0;
  border-radius: 16px;
  padding: 14px;
  overflow-x: auto;
  max-width: 100%;
}

#ordersMeta,
#incomingLogsMeta,
#callbackLogsMeta {
  margin: 8px 0;
  color: var(--muted);
  font-size: 13px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
}

.hero-chip {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: #91c9ff;
  font-weight: 600;
}

.log-list {
  display: grid;
  gap: 14px;
}

.log-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  background: linear-gradient(180deg, rgba(10, 27, 50, 0.95), rgba(9, 20, 39, 0.92));
}

.log-card-compact {
  padding: 18px;
}

.log-card-top {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.log-card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.log-chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.log-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(110, 160, 255, 0.12);
  color: #d9ebff;
  font-size: 12px;
  font-weight: 600;
}

.log-chip.success {
  background: rgba(53, 211, 154, 0.12);
  color: var(--success);
}

.log-chip.danger {
  background: rgba(255, 107, 124, 0.12);
  color: var(--danger);
}

.log-preview {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.log-card-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-detail {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.inline-detail-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.inline-detail-top h4 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.raw-record-box {
  margin-top: 14px;
}

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

.log-block {
  min-width: 0;
}

.log-block strong {
  display: block;
  margin-bottom: 6px;
}

.json-box {
  margin: 0;
  min-height: 72px;
  max-height: 260px;
}

.empty-state {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
  background: rgba(10, 27, 50, 0.56);
}

.detail-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

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

.detail-block {
  min-width: 0;
}

.detail-block strong {
  display: block;
  margin-bottom: 8px;
}

.detail-json {
  min-height: 220px;
  max-height: none;
}

@media (max-width: 900px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .app {
    padding: 14px;
  }

  .topbar,
  .auth-row,
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-head,
  .log-card-top,
  .inline-detail-top {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .detail-sections {
    display: grid;
    grid-template-columns: 1fr;
  }
}
