:root {
  --bg: #0b0e13;
  --sidebar: #10141b;
  --card: #151a22;
  --border: #1f2733;
  --text: #e6e9ee;
  --muted: #8b95a5;
  --accent: #3ecf8e;
  --accent-dim: rgba(62, 207, 142, 0.10);
  --blue: #4f9dfa;
  --orange: #f2a93c;
  --red: #f2637a;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: "Segoe UI", Arial, sans-serif; font-size: 14px; }
a { text-decoration: none; color: inherit; }
.app { display: flex; min-height: 100vh; position: relative; z-index: 1; }
@keyframes sidebar-logo-glow {
  0%, 100% { box-shadow: 0 6px 16px rgba(62, 207, 142, .22); }
  50% { box-shadow: 0 6px 22px rgba(62, 207, 142, .45), 0 0 0 4px rgba(62, 207, 142, .06); }
}
@keyframes nav-dot-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(62, 207, 142, .45); }
  70% { box-shadow: 0 0 0 5px rgba(62, 207, 142, 0); }
}
.sidebar {
  width: 236px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: radial-gradient(circle at 15% 0%, rgba(62, 207, 142, .07), transparent 42%), var(--sidebar);
  border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px 20px; border-bottom: 1px solid var(--border); }
.brand .logo {
  height: 34px; width: 34px; flex-shrink: 0; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  display: flex; align-items: center; justify-content: center;
  animation: sidebar-logo-glow 3.2s ease-in-out infinite;
}
.brand .logo img { height: 20px; width: 20px; object-fit: contain; }
.brand b {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: .01em;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.brand span { color: var(--muted); font-size: 12px; margin-left: 4px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding-top: 18px; }
.nav-group { margin-bottom: 20px; }
.nav-label { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--muted); letter-spacing: .06em; padding: 0 20px 9px; text-transform: uppercase; }
.nav-label-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--dot, var(--muted)); flex-shrink: 0; }
.nav-item {
  display: flex; align-items: center; gap: 11px; margin: 2px 10px; padding: 8px 12px; border-radius: 8px;
  color: #aeb6c4; font-size: 13.5px; position: relative;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; color: #6b7686; transition: color .16s ease, transform .16s ease; }
.nav-item:hover { background: #171d27; color: var(--text); transform: translateX(2px); }
.nav-item:hover .nav-icon { color: var(--text); }
.nav-item.active { background: linear-gradient(90deg, var(--accent-dim), rgba(79, 157, 250, .05)); color: var(--accent); font-weight: 600; }
.nav-item.active .nav-icon { color: var(--accent); transform: scale(1.05); }
.nav-item.active::before {
  content: ""; position: absolute; left: -10px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 16px; border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--accent), var(--blue));
  animation: nav-dot-pulse 2.2s ease-in-out infinite;
}
.sidebar-footer { flex-shrink: 0; border-top: 1px solid var(--border); padding: 12px 14px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #08150e;
}
.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--muted); }
.user-chip form { margin: 0; }
.user-chip .btn-icon { width: 28px; height: 28px; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 56px; background: var(--sidebar); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 24px; justify-content: space-between; }
.topbar h1 { font-size: 15px; font-weight: 600; margin: 0; }
.topbar .right { color: var(--muted); font-size: 13px; display: flex; gap: 18px; align-items: center; }

.auth-body {
  --auth-blue: #3b5bfd;
  --auth-purple: #8b5cf6;
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px) 0 0 / 42px 42px,
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px) 0 0 / 42px 42px,
    var(--bg);
}
.auth-body::before, .auth-body::after {
  content: ""; position: fixed; width: 60vmax; height: 60vmax; border-radius: 50%;
  filter: blur(60px); pointer-events: none; z-index: 0;
}
.auth-body::before { top: -20%; left: -15%; background: radial-gradient(circle, rgba(59,91,253,.35), transparent 70%); animation: auth-blob-a 14s ease-in-out infinite; }
.auth-body::after { bottom: -20%; right: -15%; background: radial-gradient(circle, rgba(139,92,246,.35), transparent 70%); animation: auth-blob-b 16s ease-in-out infinite; }
@keyframes auth-blob-a { 0%, 100% { transform: translate(0, 0) scale(1); opacity: .8; } 50% { transform: translate(3vw, 2vh) scale(1.08); opacity: 1; } }
@keyframes auth-blob-b { 0%, 100% { transform: translate(0, 0) scale(1); opacity: .8; } 50% { transform: translate(-3vw, -2vh) scale(1.1); opacity: 1; } }

.auth-shell {
  position: relative; z-index: 1; width: 100%; max-width: 400px; padding: 24px;
  display: flex; flex-direction: column; align-items: center;
  animation: auth-rise .55s cubic-bezier(.2, .7, .3, 1) both;
}
@keyframes auth-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

.auth-fireflies { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.firefly {
  position: absolute; left: var(--x); top: var(--y);
  width: 5px; height: 5px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,236,175,1) 0%, rgba(255,214,120,.7) 45%, transparent 75%);
  box-shadow: 0 0 6px 2px rgba(255,214,120,.55);
  opacity: 0;
  animation: firefly-fly var(--dur) ease-in-out infinite, firefly-glow var(--glow-dur) ease-in-out infinite;
  animation-delay: var(--delay), var(--delay);
}
@keyframes firefly-fly {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(var(--dx1), var(--dy1)); }
  50% { transform: translate(var(--dx2), var(--dy2)); }
  75% { transform: translate(var(--dx3), var(--dy3)); }
}
@keyframes firefly-glow { 0%, 100% { opacity: .1; } 50% { opacity: .95; } }

.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 26px; text-align: center; }
.auth-logo-tile {
  width: 68px; height: 68px; border-radius: 18px;
  background: linear-gradient(135deg, var(--auth-blue), var(--auth-purple));
  display: flex; align-items: center; justify-content: center;
  animation: auth-logo-pulse 2.8s ease-in-out infinite;
}
@keyframes auth-logo-pulse {
  0%, 100% { box-shadow: 0 0 24px rgba(139,92,246,.35), 0 12px 30px rgba(59,91,253,.25); }
  50% { box-shadow: 0 0 42px rgba(139,92,246,.55), 0 12px 34px rgba(59,91,253,.4); }
}
.auth-logo-tile img { width: 40px; height: 40px; object-fit: contain; }
.auth-brand b {
  font-size: 22px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--auth-blue), var(--auth-purple));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.auth-tagline { color: var(--muted); font-size: 12.5px; }
.auth-card { width: 100%; background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 30px 28px; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.auth-card .field { margin-bottom: 18px; }
.auth-card .field label { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.input-icon { position: relative; display: flex; align-items: center; }
.input-icon .input-icon-glyph { position: absolute; left: 12px; width: 15px; height: 15px; color: var(--muted); pointer-events: none; transition: color .15s ease; }
.field .input-icon input { width: 100%; padding: 10px 12px 10px 38px; background: #0f141b; border: 1px solid #2a3441; color: var(--text); border-radius: 9px; font-size: 13.5px; transition: border-color .15s ease, box-shadow .15s ease; }
.field .input-icon input:focus { outline: none; border-color: var(--auth-blue); box-shadow: 0 0 0 3px rgba(59,91,253,.15); }
.input-icon:has(input:focus) .input-icon-glyph { color: var(--auth-blue); }
.field .input-icon input[data-has-toggle] { padding-right: 38px; }
.input-icon-toggle { position: absolute; right: 8px; background: transparent; border: none; color: var(--muted); cursor: pointer; padding: 6px; display: flex; border-radius: 6px; transition: color .15s ease, background .15s ease; }
.input-icon-toggle:hover { color: var(--text); background: #1a212c; }
.auth-card .auth-submit {
  width: 100%; padding: 11px; font-size: 13.5px; font-weight: 700;
  background: linear-gradient(135deg, var(--auth-blue), var(--auth-purple)); color: #fff; margin-top: 6px;
  box-shadow: 0 10px 26px -8px rgba(139,92,246,.55);
  transition: transform .15s ease, box-shadow .15s ease;
}
.auth-card .auth-submit:hover { transform: translateY(-1px); box-shadow: 0 14px 32px -8px rgba(139,92,246,.7); }
.auth-card .auth-submit:active { transform: translateY(0); }
.auth-footer { margin-top: 24px; color: var(--muted); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.content { padding: 28px 32px 60px/*; max-width: 1180px*/; margin: 0 auto; width: 100%; }
.intro { color: #aeb6c2; line-height: 1.7; font-size: 13.5px; margin: 0 0 20px; }
.btn { background: var(--accent); color: #08150e; border: none; padding: 8px 16px; border-radius: 8px; font-size: 12.5px; font-weight: 700; cursor: pointer; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn.small { padding: 5px 12px; font-size: 11.5px; }
.toolbar-end { display: flex; justify-content: flex-end; margin-bottom: 16px; gap: 10px; }
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
th, td { text-align: left; padding: 12px 16px; font-size: 13px; border-bottom: 1px solid #1a2029; }
th { background: #171d27; color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }
.status-pill { font-size: 11px; padding: 3px 10px; border-radius: 999px; font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.status-pill.active { background: rgba(62, 207, 142, .12); color: var(--accent); }
.status-pill.paused { background: rgba(139, 149, 165, .15); color: var(--muted); }
.status-pill.error { background: rgba(242, 99, 122, .12); color: var(--red); }
.status-pill.warn { background: rgba(242, 169, 60, .12); color: var(--orange); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; background: #0f141b; border: 1px solid #2a3441; color: var(--text); padding: 9px 12px; border-radius: 8px; font-size: 13px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.alert-card { background: var(--card); border: 1px solid var(--border); border-left: 3px solid var(--red); border-radius: 10px; padding: 16px 18px; margin-bottom: 12px; display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.alert-card.warn { border-left-color: var(--orange); }
.alert-card.resolved { border-left-color: var(--accent); opacity: .6; }
.alert-tag { font-size: 10.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px; margin-right: 8px; text-transform: uppercase; }
.alert-tag.mapping { background: rgba(242,99,122,.12); color: var(--red); }
.alert-tag.timeout { background: rgba(242,169,60,.12); color: var(--orange); }
.alert-tag.duplicate { background: rgba(79,157,250,.12); color: var(--blue); }
.alert-tag.readerror { background: rgba(242,99,122,.12); color: var(--red); }
.alert-content-cell { max-width: 420px; white-space: normal; word-break: break-word; overflow-wrap: break-word; }

.toast-container { position: fixed; top: 16px; right: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; max-width: 360px; pointer-events: none; }
.toast { background: var(--card); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 10px; padding: 12px 16px; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,.25); opacity: 0; transform: translateY(-8px); transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { border-left-color: var(--red); }

.inline-message { margin-top: 10px; padding: 8px 12px; border-radius: 8px; font-size: 12.5px; background: rgba(62,207,142,.08); border: 1px solid rgba(62,207,142,.3); color: var(--text); }
.inline-message.inline-message-error { background: rgba(242,99,122,.08); border-color: rgba(242,99,122,.3); }
.btn-sm { font-size: 11.5px; padding: 6px 14px; border-radius: 7px; border: 1px solid var(--border); background: transparent; color: var(--text); cursor: pointer; }
.btn-sm.primary { background: var(--accent); color: #08150e; border: none; font-weight: 700; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-row.cols-2 { grid-template-columns: repeat(2, 1fr); }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; min-width: 0; }
.stat-card .label { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.stat-card .value { font-size: 24px; font-weight: 700; }
.stat-card .value.ok { color: var(--accent); }
.stat-card .value.warn { color: var(--orange); }
.stat-card .sub { color: var(--muted); font-size: 11.5px; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-card-icon { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.stat-card-icon svg { width: 17px; height: 17px; }
.stat-card-icon.blue { background: rgba(79, 157, 250, .12); color: var(--blue); }
.stat-card-icon.green { background: var(--accent-dim); color: var(--accent); }
.stat-card-icon.orange { background: rgba(242, 169, 60, .12); color: var(--orange); }
.stat-card-icon.red { background: rgba(242, 99, 122, .12); color: var(--red); }

.dash-section { margin-bottom: 28px; }
.dash-section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.dash-section-head h3 { font-size: 13.5px; font-weight: 700; margin: 0; }
.dash-section-head a { color: var(--accent); font-size: 12px; }

.chart-row { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; margin-bottom: 28px; }
.chart-col { display: flex; flex-direction: column; gap: 16px; }
.chart-panel { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; }
.chart-panel h3 { font-size: 13.5px; font-weight: 700; margin: 0 0 14px; }
.chart-panel .chart-canvas-wrap { position: relative; height: 220px; }
.chart-panel.short .chart-canvas-wrap { height: 150px; }
.chart-empty { color: var(--muted); font-size: 12.5px; padding: 20px 0; text-align: center; }
@media (max-width: 980px) { .chart-row { grid-template-columns: 1fr; } }

.run-list { display: flex; flex-direction: column; gap: 8px; }
.run-row { display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; transition: border-color .12s ease; }
.run-row:hover { border-color: #2a3441; }
.run-row .run-row-main { flex: 1; min-width: 0; }
.run-row .run-row-name { font-size: 13px; font-weight: 600; }
.run-row .run-row-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.type-tag { font-size: 10.5px; color: var(--muted); border: 1px solid #2a3441; padding: 1px 8px; border-radius: 999px; }
.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
select { background: #151a22; border: 1px solid var(--border); color: var(--text); padding: 7px 12px; border-radius: 8px; font-size: 12.5px; }

/* Connections page: card layout for systems / connection methods / fields */
.conn-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px 22px; margin-bottom: 22px; }
.conn-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.conn-card-head input[type=text] { font-size: 15.5px; font-weight: 700; background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--text); padding: 6px 8px; flex: 1; min-width: 0; }
.conn-card-head input[type=text]:hover { border-color: var(--border); }
.conn-card-head input[type=text]:focus { border-color: var(--accent); outline: none; background: #0f141b; }
.conn-card-head select { flex: 0 0 160px; }
.conn-card-head-form { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.method-block { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; background: #12161d; }
.method-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.method-head-form { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 220px; }
.method-head-form input[type=text] { font-weight: 600; font-size: 13px; background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--text); padding: 5px 8px; flex: 1; min-width: 0; }
.method-head-form input[type=text]:hover { border-color: var(--border); }
.method-head-form input[type=text]:focus { border-color: var(--accent); outline: none; background: #0f141b; }
.field-line { display: grid; grid-template-columns: 170px 1fr 92px auto auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.field-line input[type=text], .field-line input[type=password] { padding: 7px 10px; font-size: 12.5px; width: 100%; background: #0f141b; border: 1px solid #2a3441; color: var(--text); border-radius: 7px; }
.field-line.new-row input[type=text] { background: transparent; border-style: dashed; }
.field-line .secret-toggle { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.btn-icon { background: transparent; border: 1px solid var(--border); color: var(--muted); width: 30px; height: 30px; border-radius: 7px; cursor: pointer; font-size: 13px; line-height: 1; flex-shrink: 0; }
.btn-icon:hover { background: #1a212c; color: var(--text); }
.btn-icon.danger { color: var(--red); border-color: rgba(242,99,122,.3); }
.btn-icon.danger:hover { background: rgba(242,99,122,.1); }
/* Feedback for the button that just triggered a form submit — see ajax-forms.js. Every submit here
   is a real full-page round trip, some (VD "Chạy ngay") taking several seconds, so without this a
   click looked like it did nothing until the next page finally rendered. */
.is-submitting { position: relative; cursor: wait !important; opacity: .7; pointer-events: none; }
.is-submitting::after {
  content: ""; display: inline-block; width: 11px; height: 11px; margin-left: 7px; vertical-align: -2px;
  border: 2px solid rgba(255,255,255,.35); border-top-color: currentColor; border-radius: 50%;
  animation: btn-spin .6s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

.status-pill-btn { border: none; cursor: pointer; }
.conn-card-footer { display: flex; justify-content: space-between; align-items: center; padding-top: 14px; border-top: 1px solid var(--border); }
.subtable-block { margin: 8px 0 10px 4px; padding: 10px 12px; border-left: 2px solid var(--border); background: #0f141b; border-radius: 0 8px 8px 0; }
.entity-section-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 12px 0 6px; }
.entity-block { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; background: #12161d; }
.entity-block > summary { cursor: pointer; padding: 9px 12px; font-size: 11.5px; font-weight: 700; color: var(--text); list-style: none; display: flex; align-items: center; gap: 8px; text-transform: uppercase; letter-spacing: .04em; }
.entity-block > summary::-webkit-details-marker { display: none; }
.entity-block > summary::before { content: "▸"; color: var(--accent); transition: transform .15s; font-size: 11px; }
.entity-block[open] > summary::before { transform: rotate(90deg); }
.entity-block > summary .type-tag { text-transform: none; letter-spacing: normal; font-weight: 400; }
.entity-block > summary .entity-block-warn { color: var(--red); text-transform: none; font-weight: 600; letter-spacing: normal; }
.entity-block-body { padding: 0 12px 12px; }
.entity-fields-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; align-items: start; }
@media (max-width: 760px) { .entity-fields-cols { grid-template-columns: 1fr; } }
.level-key-tag { font-family: monospace; font-size: 11px; color: var(--accent); background: var(--accent-dim); padding: 2px 8px; border-radius: 6px; flex-shrink: 0; }

.collapse-toggle { background: transparent; border: none; color: var(--muted); cursor: pointer; padding: 2px 4px; line-height: 1; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.collapse-toggle:hover { color: var(--accent); }
.collapse-toggle::before { content: "▸"; display: inline-block; font-size: 13px; transition: transform .15s; }
.collapse-toggle:not(.collapsed)::before { transform: rotate(90deg); }

.help-panel { background: var(--card); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 20px; }
.help-panel > summary { cursor: pointer; padding: 14px 18px; font-weight: 600; font-size: 13.5px; list-style: none; display: flex; align-items: center; gap: 8px; }
.help-panel > summary::-webkit-details-marker { display: none; }
.help-panel > summary::before { content: "▸"; color: var(--accent); transition: transform .15s; }
.help-panel[open] > summary::before { transform: rotate(90deg); }
.help-panel-body { padding: 0 20px 18px; color: #cbd2dc; font-size: 13px; line-height: 1.7; }
.help-panel-body h4 { color: var(--text); font-size: 13px; margin: 16px 0 6px; }
.help-panel-body h4:first-child { margin-top: 0; }
.help-panel-body code { background: #0f141b; border: 1px solid #2a3441; border-radius: 4px; padding: 1px 6px; font-size: 12px; }
.help-panel-body table { margin-top: 8px; font-size: 12.5px; }
.help-panel-body ol, .help-panel-body ul { margin: 4px 0 10px; padding-left: 20px; }
.help-panel-body li { margin-bottom: 4px; }
.btn-sm.danger-text { border-color: transparent; color: var(--red); }
.btn-sm.danger-text:hover { background: rgba(242,99,122,.1); }

/* Routing page: flow-style route cards */
.route-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px 22px; margin-bottom: 18px; }
.route-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.route-card-head .entity-name { font-size: 15.5px; font-weight: 700; flex: 1; }
.route-flow { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 18px 20px; background: #0f141b; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 4px; }
.route-node { display: flex; flex-direction: column; gap: 6px; }
.route-node .sys-name { font-size: 14.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.route-node .sys-name .sys-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); flex-shrink: 0; }
.route-node .method-tag { font-size: 11px; color: var(--muted); border: 1px solid #2a3441; padding: 2px 9px; border-radius: 999px; display: inline-block; width: fit-content; }
.route-arrow { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--accent); flex-shrink: 0; }
.route-arrow .arrow-symbol { font-size: 22px; line-height: 1; }
.route-arrow .dir-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.route-edit-toggle { cursor: pointer; font-size: 12px; color: var(--muted); user-select: none; list-style: none; display: inline-flex; align-items: center; gap: 6px; margin-top: 14px; padding: 4px 0; }
.route-edit-toggle::-webkit-details-marker { display: none; }
.route-edit-toggle::before { content: "▸"; color: var(--accent); transition: transform .15s; font-size: 11px; }
.route-details[open] > .route-edit-toggle::before { transform: rotate(90deg); }
.route-edit-toggle:hover { color: var(--text); }
.route-edit-body { padding-top: 16px; border-top: 1px solid var(--border); margin-top: 10px; }
.route-empty-state { background: var(--card); border: 1px dashed var(--border); border-radius: 12px; padding: 22px; text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.route-add-card { border-style: dashed; }
.route-section-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 10px; }

/* Lookups + Mapping pages: card-nested mini tables and mapping rows */
.mini-table { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin: 4px 0 16px; background: #0f141b; width: 100%; border-collapse: collapse; }
.mini-table th, .mini-table td { padding: 9px 14px; font-size: 12.5px; border-bottom: 1px solid #1a2029; text-align: left; }
.mini-table thead th { background: #12161d; color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.mini-table tr:last-child td { border-bottom: none; }
.lookup-add-row { align-items: flex-end; margin: 0; padding-top: 14px; border-top: 1px dashed var(--border); }
.mapping-list { margin-bottom: 4px; }
.mapping-row { display: grid; grid-template-columns: 1fr 20px 1fr 130px 84px 36px; gap: 10px; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--border); }
.mapping-row:last-child { border-bottom: none; }
.mapping-row .field-name { font-weight: 600; font-size: 13px; }
.mapping-row .arrow { color: var(--muted); text-align: center; }
.mapping-note { font-size: 11.5px; color: var(--muted); padding: 0 2px 10px; margin-top: -6px; }
.th-label-input { background: transparent; border: 1px solid transparent; border-radius: 4px; color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit; padding: 2px 4px; width: 100%; }
.th-label-input:hover { border-color: var(--border); }
.th-label-input:focus { border-color: var(--accent); outline: none; background: #0f141b; color: var(--text); }

/* Mapping page: drag-and-drop board (mirrors Hermes_MappingUI.html mockup) */
.map-toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.map-toolbar label { font-size: 12.5px; color: var(--muted); }
.board { position: relative; display: grid; grid-template-columns: 1fr 140px 1fr; gap: 0; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 22px 26px 26px; margin-bottom: 24px; }
.board svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.board .col { position: relative; z-index: 1; }
.board .col-title { font-size: 11.5px; font-weight: 700; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; margin-bottom: 12px; }
.board .col-title.source { color: var(--blue); }
.board .col-title.target { color: var(--accent); }
.board .col.center { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 30px; gap: 10px; }
.board .center-badge { font-size: 11px; color: var(--muted); text-align: center; line-height: 1.5; }
.board .center-arrow { color: #2a3441; font-size: 20px; }
.field-item { background: #1a212c; border: 1px solid #2a3441; border-radius: 9px; padding: 10px 14px; margin-bottom: 10px; font-size: 13px; display: flex; justify-content: space-between; align-items: center; gap: 10px; cursor: grab; user-select: none; transition: border-color .15s, background .15s; }
.field-item[draggable="true"]:active { cursor: grabbing; }
.field-item .type { font-size: 10.5px; color: var(--muted); border: 1px solid #2a3441; padding: 1px 7px; border-radius: 999px; flex-shrink: 0; }
.field-item.mapped { border-color: var(--accent); }
.field-item.dragover { border-color: var(--orange); background: rgba(242,169,60,0.08); }
.map-table-wrap h3 { font-size: 13.5px; margin: 0 0 12px; color: var(--text); }
.mini-table input[type="text"] { background: #0f141b; border: 1px solid #2a3441; color: var(--text); padding: 6px 10px; border-radius: 6px; font-size: 12.5px; width: 100%; }
.mini-table select { width: 100%; min-width: 0; padding: 6px 10px; font-size: 12.5px; }
.mini-table td.field-tag { color: var(--text); font-weight: 600; }
.mini-table td.field-tag .arrow { color: var(--muted); margin: 0 6px; }
.map-empty-row td { text-align: center; color: var(--muted); padding: 22px; font-style: italic; }

/* SyncProcess page: pipeline phase list + vertical block diagram */
.sp-phase { border: 1px solid var(--border); border-radius: 12px; background: var(--card); margin-bottom: 14px; overflow: hidden; }
.sp-phase-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; background: #171d27; border-bottom: 1px solid var(--border); }
.sp-phase-num { font-size: 11px; font-weight: 700; color: var(--bg); background: var(--accent); padding: 3px 9px; border-radius: 999px; flex-shrink: 0; letter-spacing: .02em; }
.sp-phase-name { font-size: 14px; font-weight: 600; color: var(--text); }
.sp-phase-tag { margin-left: auto; font-size: 11px; color: var(--muted); border: 1px solid var(--border); padding: 2px 10px; border-radius: 999px; flex-shrink: 0; }
.sp-task-list { list-style: none; margin: 0; padding: 14px 20px 18px; }
.sp-task-list li { position: relative; padding: 8px 0 8px 22px; font-size: 13px; line-height: 1.65; color: #cbd2dc; border-bottom: 1px solid #1a2029; }
.sp-task-list li:last-child { border-bottom: none; }
.sp-task-list li::before { content: ''; position: absolute; left: 0; top: 15px; width: 8px; height: 8px; border-radius: 2px; background: var(--accent); opacity: .85; }
.sp-task-list li b { color: var(--text); }

/* SyncProcess page: block diagram figure (static image) */
.sp-figure { margin: 4px 0 30px; }
.sp-figure figcaption { color: var(--muted); font-size: 12px; text-align: center; margin-top: 10px; line-height: 1.6; }

/* Monitor page: run cards + stat chips + pagination */
.run-stats { display: flex; gap: 28px; padding: 14px 4px; flex-wrap: wrap; }
.run-stats .stat { display: flex; flex-direction: column; gap: 4px; }
.run-stats .stat .value { font-size: 20px; font-weight: 700; }
.run-stats .stat .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }

/* Grid of run cards instead of one full-width stacked column — same .route-card markup, just
   arranged responsively (auto-fill: as many ~300px columns as fit, 1 column on narrow viewports)
   so a page of runs takes far less vertical scroll. */
.monitor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin-bottom: 18px; }
.monitor-grid .run-card { margin-bottom: 0; }

/* Schedule page: one row per entity instead of stacked cards. Reuses the generic table/th/td rules
   above; only the cron preset+input pair need explicit styling since they're not wrapped in .field
   here (a .field would force full label/margin spacing that doesn't fit a table cell). */
.schedule-table td { vertical-align: top; }
.schedule-table select,
.schedule-table input[type=text] { width: 100%; background: #0f141b; border: 1px solid #2a3441; color: var(--text); padding: 7px 10px; border-radius: 7px; font-size: 12.5px; }

/* Cyberpunk-lite run card: no left border — a clipped top-right corner (angular HUD-panel
   silhouette instead of a plain rectangle), a glowing status-colored top edge, a small corner
   bracket, and a neon halo on hover. --status-color drives all three so adding a new status only
   ever means setting one variable. */
.run-card {
  --status-color: var(--border);
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  padding: 18px 20px 16px;
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 2px solid var(--status-color);
  border-radius: 10px;
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 0 100%);
  transition: box-shadow .2s ease, transform .15s ease, border-color .15s ease;
}
.run-card::before {
  content: "";
  position: absolute; left: -1px; bottom: -1px;
  width: 18px; height: 18px;
  border-left: 2px solid var(--status-color);
  border-bottom: 2px solid var(--status-color);
  border-radius: 0 0 0 8px;
  opacity: .85;
  pointer-events: none;
}
.run-card.active { --status-color: var(--accent); }
.run-card.warn { --status-color: var(--orange); }
.run-card.error { --status-color: var(--red); }
.run-card.paused { --status-color: var(--muted); }
.run-card:hover {
  border-color: var(--status-color);
  box-shadow: 0 0 0 1px var(--status-color), 0 0 26px -6px var(--status-color);
  transform: translateY(-2px);
}

.run-card .route-card-head { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.run-card-entity { font-size: 15px; font-weight: 700; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.run-card-meta { color: var(--muted); font-size: 11.5px; margin-top: 3px; font-family: Consolas, monospace; }
.run-card .status-pill { font-family: Consolas, monospace; letter-spacing: .05em; text-transform: uppercase; }
.run-card.paused .status-pill::before {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; margin-right: 5px; vertical-align: 1px;
  animation: run-pulse 1.4s ease-in-out infinite;
}
@keyframes run-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

.run-card .run-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0;
}
.run-card .run-stats .stat {
  align-items: center;
  text-align: center;
  gap: 3px;
  background: #0f141b;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 6px;
}
.run-card .run-stats .stat .value { font-size: 18px; font-family: Consolas, monospace; text-shadow: 0 0 12px currentColor; }
.run-card .run-stats .stat .label { font-size: 10px; }

.run-watermark {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding: 8px 10px;
  background: #0f141b;
  border: 1px solid var(--border);
  border-left: 2px solid var(--status-color, var(--border));
  border-radius: 0 6px 6px 0;
  font-size: 11px;
}
.run-watermark .label { color: var(--muted); text-transform: uppercase; letter-spacing: .03em; flex-shrink: 0; }
.run-watermark .value { font-family: Consolas, monospace; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.run-detail-link {
  display: block;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-weight: 600;
  font-family: Consolas, monospace;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: 11px;
  transition: color .15s ease;
}
.run-card:hover .run-detail-link { color: var(--status-color); }
.monitor-grid .run-stats .stat .value { font-size: 17px; }
.pagination { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12.5px; }
.pagination .page-links { display: flex; align-items: center; gap: 8px; }
.pagination .page-links label { color: var(--muted); font-size: 12.5px; }
.pagination .page-links select { padding: 5px 8px; font-size: 12.5px; }
.pagination a.btn-sm { text-decoration: none; }
.pagination .btn-sm.disabled { opacity: .35; pointer-events: none; }

/* RunDetail page: request/response diagnostics — replaces the old ad-hoc inline-styled dump */
.http-diag { margin-top: 10px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #0f141b; }
.http-diag + .http-diag { margin-top: 8px; }
.http-diag > summary { cursor: pointer; list-style: none; padding: 9px 12px; display: flex; align-items: center; gap: 10px; }
.http-diag > summary::-webkit-details-marker { display: none; }
.http-diag > summary::before { content: "▸"; color: var(--accent); transition: transform .15s; flex-shrink: 0; font-size: 11px; }
.http-diag[open] > summary::before { transform: rotate(90deg); }
.http-diag-method { font-family: Consolas, monospace; font-weight: 700; font-size: 10.5px; padding: 2px 8px; border-radius: 999px; flex-shrink: 0; text-transform: uppercase; letter-spacing: .03em; }
.http-diag-method.get { background: rgba(79, 157, 250, .12); color: var(--blue); }
.http-diag-method.post { background: var(--accent-dim); color: var(--accent); }
.http-diag-method.patch, .http-diag-method.put { background: rgba(242, 169, 60, .12); color: var(--orange); }
.http-diag-method.delete { background: rgba(242, 99, 122, .12); color: var(--red); }
.http-diag-url { flex: 1; min-width: 0; overflow-wrap: anywhere; word-break: break-all; color: var(--text); font-family: Consolas, monospace; font-size: 11.5px; }
.http-diag-status { font-family: Consolas, monospace; font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; flex-shrink: 0; }
.http-diag-status.ok { background: var(--accent-dim); color: var(--accent); }
.http-diag-status.err { background: rgba(242, 99, 122, .12); color: var(--red); }
.http-diag-duration { font-family: Consolas, monospace; font-size: 10.5px; color: var(--muted); flex-shrink: 0; }
.http-diag-body { padding: 12px; border-top: 1px solid var(--border); }
.http-diag-section { margin-bottom: 10px; }
.http-diag-section:last-child { margin-bottom: 0; }
.http-diag-section .label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 5px; }
.http-diag-section pre { margin: 0; font-family: Consolas, monospace; font-size: 11px; line-height: 1.5; color: #cbd2dc; background: #0b0e13; border: 1px solid #1f2733; border-radius: 6px; padding: 10px; white-space: pre-wrap; word-break: break-all; max-height: 280px; overflow: auto; }
.http-diag.compact > summary { padding: 7px 10px; font-size: 11px; }
.http-diag.compact .http-diag-body { padding: 10px; }
.http-diag-label { color: var(--muted); font-size: 11px; }
.http-diag-list { max-height: 420px; overflow-y: auto; padding-right: 4px; }

.http-diag-section pre, .http-diag-list {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.http-diag-section pre::-webkit-scrollbar, .http-diag-list::-webkit-scrollbar { width: 8px; height: 8px; }
.http-diag-section pre::-webkit-scrollbar-track, .http-diag-list::-webkit-scrollbar-track { background: transparent; }
.http-diag-section pre::-webkit-scrollbar-thumb, .http-diag-list::-webkit-scrollbar-thumb { background-color: var(--border); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
.http-diag-section pre::-webkit-scrollbar-thumb:hover, .http-diag-list::-webkit-scrollbar-thumb:hover { background-color: var(--muted); background-clip: padding-box; }
.run-detail-top-row { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 20px; }
.run-detail-top-row > .run-card { flex: 1; min-width: 0; margin-bottom: 0; }
@media (max-width: 900px) { .run-detail-top-row { flex-direction: column; } }

/* "Đồng bộ toàn bộ" live progress popup — see wwwroot/js/bulk-init-progress.js */
.bulk-init-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 2000; display: none; align-items: center; justify-content: center; padding: 16px; }
.bulk-init-overlay.open { display: flex; }
.bulk-init-modal { background: var(--card); border: 1px solid var(--border); border-radius: 12px; width: 100%; max-width: 480px; max-height: 80vh; display: flex; flex-direction: column; box-shadow: 0 16px 48px rgba(0,0,0,.4); }
.bulk-init-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.bulk-init-title { font-size: 14.5px; }
.bulk-init-close { background: none; border: none; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; padding: 2px 6px; }
.bulk-init-close:hover { color: var(--text); }
.bulk-init-status { padding: 10px 18px 0; font-size: 13px; font-weight: 600; }
.bulk-init-status-Running { color: var(--orange); }
.bulk-init-status-Success { color: var(--accent); }
.bulk-init-status-Failed { color: var(--red); }
.bulk-init-stats { display: flex; gap: 24px; padding: 10px 18px; }
.bulk-init-stats .stat { display: flex; flex-direction: column; }
.bulk-init-stats .value { font-size: 20px; font-weight: 700; }
.bulk-init-stats .label { font-size: 11px; color: var(--muted); }
.bulk-init-watermark { padding: 0 18px 8px; font-size: 12px; color: var(--muted); word-break: break-all; }
.bulk-init-log { flex: 1; overflow-y: auto; padding: 10px 18px 16px; border-top: 1px solid var(--border); font-family: Consolas, monospace; font-size: 12px; color: var(--muted); }
.bulk-init-log-line { padding: 2px 0; }
