:root {
  --bg: #0f1225;
  --bg-2: #171a33;
  --card: rgba(255, 255, 255, 0.06);
  --card-solid: #1c2140;
  --stroke: rgba(255, 255, 255, 0.10);
  --stroke-strong: rgba(255, 255, 255, 0.18);
  --text: #eef1ff;
  --muted: #9aa3c7;
  --primary: #6c5ce7;
  --primary-2: #8b7bff;
  --accent: #22d3ee;
  --success: #34d399;
  --danger: #f87171;
  --radius: 16px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  --ring: 0 0 0 3px rgba(108, 92, 231, 0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 600px at 12% -10%, rgba(108, 92, 231, 0.35), transparent 60%),
    radial-gradient(900px 600px at 100% 0%, rgba(34, 211, 238, 0.20), transparent 55%),
    radial-gradient(800px 700px at 80% 110%, rgba(139, 123, 255, 0.18), transparent 60%),
    var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

.glass {
  background: var(--card);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--stroke);
}

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .2s ease, background .2s ease, border-color .2s;
  color: var(--text);
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 8px 20px rgba(108, 92, 231, 0.45);
}
.btn-primary:hover { box-shadow: 0 12px 26px rgba(108, 92, 231, 0.6); }
.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--stroke);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.12); }
.btn-block { width: 100%; }
.btn-danger {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.4);
  color: #ffb4b4;
}
.btn-danger:hover { background: rgba(248, 113, 113, 0.22); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 10px; }

.icon-btn {
  background: transparent; border: none; color: var(--muted);
  font-size: 26px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.icon-btn:hover { color: var(--text); }

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
input, select {
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  width: 100%;
}
input::placeholder { color: #6b73a0; }
input:focus, select:focus { border-color: var(--primary-2); box-shadow: var(--ring); }
select option { background: var(--card-solid); }
.grid-2 { display: grid; grid-template-columns: 1fr 120px; gap: 14px; }

.alert { border-radius: 12px; padding: 10px 14px; font-size: 14px; margin-bottom: 12px; }
.alert.error { background: rgba(248, 113, 113, 0.14); border: 1px solid rgba(248, 113, 113, 0.4); color: #ffc2c2; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 400px;
  border-radius: 22px; padding: 38px 34px;
  box-shadow: var(--shadow);
  text-align: center;
  animation: pop .5s cubic-bezier(.2,.8,.2,1);
}
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.login-logo {
  width: 64px; height: 64px; margin: 0 auto 18px;
  display: grid; place-items: center; border-radius: 18px; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 12px 30px rgba(108, 92, 231, 0.5);
}
.login-card h1 { margin: 0 0 4px; font-size: 26px; font-weight: 800; }
.login-card p { margin: 0 0 22px; }
.login-card form { text-align: left; }
.hint { text-align: center; margin: 16px 0 0; font-size: 13px; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  padding: 12px 22px; border-bottom: 1px solid var(--stroke);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 42px; height: 42px; flex: none; border-radius: 12px; color: #fff;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 8px 20px rgba(108, 92, 231, 0.5);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.brand-text small { font-size: 12px; }

.tabs { display: flex; gap: 6px; margin: 0 auto; background: rgba(0,0,0,0.2); padding: 5px; border-radius: 14px; border: 1px solid var(--stroke); }
.tab {
  border: none; background: transparent; color: var(--muted);
  font: inherit; font-weight: 600; padding: 9px 18px; border-radius: 10px; cursor: pointer;
  transition: .2s;
}
.tab:hover { color: var(--text); }
.tab.active { color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-2)); box-shadow: 0 6px 16px rgba(108,92,231,.45); }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--muted);
  background: rgba(255,255,255,0.05); border: 1px solid var(--stroke);
  padding: 7px 12px; border-radius: 999px;
}
.user-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 10px var(--success); }

/* ---------- Content ---------- */
.content { padding: 26px 28px 60px; max-width: 1300px; margin: 0 auto; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.panel-head h2 { margin: 0 0 4px; font-size: 22px; font-weight: 800; }
.panel-head p { margin: 0; font-size: 14px; }
.panel-actions { display: flex; align-items: center; gap: 10px; }
.zoom-label { font-size: 13px; color: var(--muted); min-width: 44px; text-align: center; }

/* ---------- Org chart ---------- */
.chart-scroll {
  overflow: auto; border-radius: var(--radius);
  border: 1px solid var(--stroke); background:
    linear-gradient(rgba(255,255,255,.02), rgba(255,255,255,.02)),
    radial-gradient(circle at 20px 20px, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: auto, 26px 26px;
  padding: 40px; min-height: 60vh;
}
.orgchart { display: inline-block; transform-origin: top center; transition: transform .2s ease; }

.orgchart ul { position: relative; padding-top: 26px; display: flex; justify-content: center; margin: 0; list-style: none; }
.orgchart li { position: relative; padding: 26px 12px 0; display: flex; flex-direction: column; align-items: center; }

/* connectors */
.orgchart li::before, .orgchart li::after {
  content: ""; position: absolute; top: 0; width: 50%; height: 26px;
  border-top: 2px solid var(--stroke-strong);
}
.orgchart li::before { right: 50%; border-right: 2px solid var(--stroke-strong); }
.orgchart li::after  { left: 50%; }
.orgchart li:only-child::before, .orgchart li:only-child::after { display: none; }
.orgchart li:first-child::before, .orgchart li:last-child::after { border: 0; }
.orgchart li:last-child::before { border-right: 2px solid var(--stroke-strong); border-radius: 0 6px 0 0; }
.orgchart li:first-child::after { border-radius: 6px 0 0 0; }

.orgchart ul ul::before {
  content: ""; position: absolute; top: 0; left: 50%;
  height: 26px; border-left: 2px solid var(--stroke-strong);
}
.orgchart > .node-wrap > ul::before { display: none; }

/* node card */
.node {
  position: relative;
  width: 210px;
  background: linear-gradient(180deg, rgba(255,255,255,0.09), rgba(255,255,255,0.04));
  border: 1px solid var(--stroke-strong);
  border-radius: 16px; padding: 16px 14px 14px; text-align: center;
  box-shadow: 0 12px 28px rgba(0,0,0,0.35);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s;
}
.node:hover { transform: translateY(-4px); border-color: var(--primary-2); box-shadow: 0 18px 40px rgba(108,92,231,0.45); }
.node .avatar {
  width: 58px; height: 58px; border-radius: 50%; margin: 0 auto 10px;
  display: grid; place-items: center; font-weight: 800; font-size: 20px; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 6px 16px rgba(0,0,0,0.4); overflow: hidden;
  border: 2px solid rgba(255,255,255,0.25);
}
.node .avatar img { width: 100%; height: 100%; object-fit: cover; }
.node .n-name { font-weight: 700; font-size: 15px; }
.node .n-pos {
  margin-top: 5px; font-size: 12px; font-weight: 600; color: #cdd3f5;
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  background: rgba(108,92,231,0.22); border: 1px solid rgba(139,123,255,0.4);
}
/* accent for root */
.orgchart > .node-wrap > .node { width: 240px; }
.orgchart > .node-wrap > .node .avatar { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.orgchart > .node-wrap > .node .n-pos { background: rgba(245,158,11,0.2); border-color: rgba(245,158,11,0.45); color: #ffd8a8; }

.node-wrap { display: flex; flex-direction: column; align-items: center; }

/* ---------- Table ---------- */
.table-card { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 12px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); padding: 14px 18px; background: rgba(0,0,0,0.25);
  border-bottom: 1px solid var(--stroke);
}
tbody td { padding: 14px 18px; border-bottom: 1px solid var(--stroke); font-size: 14px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: rgba(255,255,255,0.04); }
.cell-name { display: flex; align-items: center; gap: 12px; }
.cell-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent)); overflow: hidden;
}
.cell-avatar img { width: 100%; height: 100%; object-fit: cover; }
.badge {
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: rgba(108,92,231,0.2); border: 1px solid rgba(139,123,255,0.4); color: #cdd3f5;
}
.row-actions { display: flex; gap: 8px; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(6, 8, 20, 0.6); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 20px;
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 480px; border-radius: 20px; padding: 24px;
  box-shadow: var(--shadow); background: var(--card-solid);
  border: 1px solid var(--stroke-strong);
  animation: pop .28s cubic-bezier(.2,.8,.2,1);
}
.modal.sm { max-width: 400px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-head h3 { margin: 0; font-size: 19px; font-weight: 800; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--card-solid); border: 1px solid var(--stroke-strong);
  color: var(--text); padding: 12px 20px; border-radius: 12px; z-index: 80;
  box-shadow: var(--shadow); font-weight: 600; font-size: 14px;
  animation: toastIn .3s cubic-bezier(.2,.8,.2,1);
}
.toast.success { border-color: rgba(52,211,153,0.5); }
.toast.error { border-color: rgba(248,113,113,0.5); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .tabs { order: 3; width: 100%; margin: 8px 0 0; }
  .topbar { flex-wrap: wrap; }
  .brand-text strong { max-width: 160px; }
  .grid-2 { grid-template-columns: 1fr; }
  .content { padding: 18px 14px 50px; }
}
