/* Colours, gradients and translucency follow the ESG-X desktop theme (esgx/ui/theme.py). */
:root {
  --violet: #8B6CFF; --blue: #6F9BFF; --cyan: #3CCBEF; --green: #17C9A6;
  --primary: #7057F5; --primary-dark: #5A3FE6;
  --text: #111111; --muted: #555555; --good: #11A37F; --warn: #D98A00; --bad: #E0445E;
  --surface: rgba(255, 255, 255, 0.72); --surface-strong: rgba(255, 255, 255, 0.86);
  --border: rgba(112, 87, 245, 0.20); --border-strong: rgba(112, 87, 245, 0.45);
  --app-bg: linear-gradient(135deg, #EFE9FF 0%, #E7EEFF 45%, #E2F6FF 80%, #DDFBF3 100%);
  --nav-bg: linear-gradient(170deg, #6E4EF2 0%, #4F72F0 50%, #1397A6 100%);
  --brand: linear-gradient(90deg, var(--violet) 0%, var(--blue) 55%, var(--green) 100%);
  --brand-hover: linear-gradient(90deg, #7457F0 0%, #5A86F2 55%, #10B494 100%);
  --header-bg: linear-gradient(90deg, rgba(139, 108, 255, 0.14), rgba(23, 201, 166, 0.12));
  --shadow: 0 1px 2px rgba(60, 40, 160, 0.06), 0 8px 24px rgba(80, 70, 200, 0.10);
  --shadow-hover: 0 2px 4px rgba(60, 40, 160, 0.08), 0 14px 36px rgba(80, 70, 200, 0.16);
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { color: var(--text); background: var(--app-bg) fixed; background-color: #EEF0FF;
  font: 14px/1.55 "Segoe UI", "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif; }
/* soft colour fields behind the glass panels: depth */
body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(40vw 40vw at 12% 8%, rgba(139, 108, 255, 0.22), transparent 70%),
              radial-gradient(38vw 38vw at 88% 22%, rgba(60, 203, 239, 0.18), transparent 70%),
              radial-gradient(45vw 45vw at 70% 95%, rgba(23, 201, 166, 0.18), transparent 70%); }
button, input, select { font: inherit; color: var(--text); }
a { color: var(--primary-dark); }
.boot { padding: 40px; color: var(--muted); }
.hidden { display: none !important; }
.glass { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%); box-shadow: var(--shadow); }

/* sign-in */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; position: relative; overflow: hidden; }
.auth::before, .auth::after { content: ""; position: absolute; border-radius: 50%; filter: blur(10px); pointer-events: none; }
.auth::before { width: 520px; height: 520px; left: -140px; top: -160px; background: radial-gradient(circle, rgba(110, 78, 242, 0.45), transparent 68%); }
.auth::after { width: 560px; height: 560px; right: -160px; bottom: -200px; background: radial-gradient(circle, rgba(19, 151, 166, 0.40), transparent 68%); }
.auth-card { position: relative; z-index: 1; width: 100%; max-width: 410px; padding: 30px 28px;
  background: rgba(255, 255, 255, 0.70); border: 1px solid rgba(255, 255, 255, 0.75); border-radius: 18px;
  backdrop-filter: blur(22px) saturate(150%); -webkit-backdrop-filter: blur(22px) saturate(150%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 24px 60px rgba(80, 60, 200, 0.22); }
.auth-card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; border-radius: 18px 18px 0 0; background: var(--brand); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 22px; }
.brand img { width: 34px; height: 34px; }
.auth-card .brand { background: var(--brand); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-card h1 { font-size: 18px; margin: 18px 0 4px; }
.auth-card p.sub { margin: 0 0 18px; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-weight: 600; font-size: 13px; }
.field input, .field select, .inp { padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: rgba(255, 255, 255, 0.82); min-width: 0; transition: border-color .15s, box-shadow .15s; }
.field input:focus, .inp:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(112, 87, 245, 0.18); background: #fff; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 15px; border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.35); background: var(--brand); color: #fff; cursor: pointer; font-weight: 600; white-space: nowrap;
  text-decoration: none; box-shadow: 0 4px 14px rgba(112, 87, 245, 0.25); transition: box-shadow .15s, transform .15s; }
.btn:hover { background: var(--brand-hover); box-shadow: 0 6px 20px rgba(112, 87, 245, 0.35); transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn.secondary { background: rgba(255, 255, 255, 0.78); color: var(--text); border-color: var(--border); box-shadow: none; }
.btn.secondary:hover { background: rgba(255, 255, 255, 0.95); border-color: var(--primary); }
.btn.danger { background: rgba(255, 255, 255, 0.78); color: var(--text); border-color: rgba(224, 68, 94, 0.55); box-shadow: none; }
.btn.danger:hover { background: rgba(224, 68, 94, 0.08); }
.btn.small { padding: 4px 10px; font-size: 13px; font-weight: 500; }
.btn.block { width: 100%; padding: 11px; }
.btn.big { padding: 13px 24px; font-size: 16px; }
.err { color: var(--bad); min-height: 20px; margin: 4px 0 8px; }
.links { display: flex; justify-content: space-between; margin-top: 14px; font-size: 13px; flex-wrap: wrap; gap: 8px; }
.lang-pick { display: flex; gap: 6px; }
.lang-pick button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px 4px; }
.lang-pick button.on { color: var(--text); font-weight: 700; text-decoration: underline; text-decoration-color: var(--primary); }

/* shell */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.nav { background: var(--nav-bg); color: #fff; padding: 16px 12px; display: flex; flex-direction: column; gap: 3px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; box-shadow: 4px 0 24px rgba(79, 114, 240, 0.25); }
.nav .brand { color: #fff; padding: 4px 8px 14px; font-size: 20px; }
.nav .grp { color: #fff; opacity: .78; font-size: 12px; margin: 14px 8px 4px; letter-spacing: .04em; font-weight: 600; }
.nav a { color: #fff; text-decoration: none; padding: 8px 10px; border-radius: 8px; display: block; transition: background .15s; }
.nav a:hover { background: rgba(255, 255, 255, 0.13); }
.nav a.on { background: rgba(255, 255, 255, 0.24); font-weight: 600; box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset; }
.nav .spacer { flex: 1; }
.nav .me { color: #fff; font-size: 13px; padding: 10px; margin-top: 8px; border-radius: 10px; background: rgba(255, 255, 255, 0.10); }
.nav .me .lang-pick button { color: #fff; opacity: .8; }
.nav .me .lang-pick button.on { color: #fff; opacity: 1; text-decoration-color: #fff; }
.main { padding: 26px 30px 40px; min-width: 0; }
.main h1 { font-size: 22px; margin: 0 0 4px; }
.main .lead { color: var(--muted); margin: 0 0 20px; max-width: 900px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 20px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; min-width: 0;
  backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%); box-shadow: var(--shadow);
  position: relative; transition: box-shadow .2s, border-color .2s, background .2s; }
.cards .card::before { content: ""; position: absolute; left: 14px; right: 14px; top: 0; height: 3px; border-radius: 0 0 3px 3px; background: var(--brand); opacity: .85; }
.cards .card:hover { border-color: var(--border-strong); background: var(--surface-strong); box-shadow: var(--shadow-hover); }
.card h2 { font-size: 16px; margin: 0 0 8px; }
.card .num { font-size: 26px; font-weight: 700; }
.hero { display: flex; gap: 20px; align-items: center; justify-content: space-between; flex-wrap: wrap; overflow: hidden;
  background: linear-gradient(120deg, rgba(139, 108, 255, 0.16) 0%, rgba(111, 155, 255, 0.12) 50%, rgba(23, 201, 166, 0.14) 100%), var(--surface-strong); }
.hero::after { content: ""; position: absolute; right: -60px; top: -80px; width: 260px; height: 260px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(60, 203, 239, 0.25), transparent 70%); }
.hero > * { position: relative; z-index: 1; }
.hero p { margin: 4px 0 0; color: var(--muted); max-width: 640px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }
.tbl-wrap { overflow-x: auto; background: rgba(255, 255, 255, 0.80); border: 1px solid var(--border); border-radius: var(--radius);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid rgba(112, 87, 245, 0.08); vertical-align: middle; }
th { background: var(--header-bg); font-weight: 600; font-size: 13px; white-space: nowrap; border-bottom: 1px solid var(--border); }
tr:nth-child(even) td { background: rgba(111, 155, 255, 0.05); }
tr:hover td { background: rgba(112, 87, 245, 0.07); }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; display: flex; gap: 6px; flex-wrap: wrap; }
.tag { display: inline-block; white-space: nowrap; padding: 1px 9px; border-radius: 999px; font-size: 12px; background: rgba(112, 87, 245, 0.10); color: var(--text); border: 1px solid rgba(112, 87, 245, 0.18); }
.tag.ok { background: rgba(17, 163, 127, 0.14); border-color: rgba(17, 163, 127, 0.35); }
.tag.warn { background: rgba(217, 138, 0, 0.14); border-color: rgba(217, 138, 0, 0.40); }
.tag.bad { background: rgba(224, 68, 94, 0.12); border-color: rgba(224, 68, 94, 0.40); }
.tag.admin { background: var(--brand); color: #fff; border-color: transparent; }
.muted { color: var(--muted); }
.grid-perm td, .grid-perm th { text-align: center; } .grid-perm td:first-child, .grid-perm th:first-child { text-align: left; }
input[type=checkbox] { accent-color: var(--primary); width: 16px; height: 16px; }
.note { background: linear-gradient(90deg, rgba(139, 108, 255, 0.10), rgba(23, 201, 166, 0.10)); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
.code { font: 700 26px/1.3 Consolas, "Courier New", monospace; letter-spacing: .08em; background: rgba(255, 255, 255, 0.85); border: 1px dashed var(--primary);
  border-radius: 10px; padding: 12px; text-align: center; margin: 10px 0; user-select: all; }

/* modal + toast */
.modal { position: fixed; inset: 0; background: rgba(42, 35, 80, 0.35); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal-box { background: rgba(255, 255, 255, 0.88); border: 1px solid rgba(255, 255, 255, 0.8); border-radius: 16px; padding: 22px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); box-shadow: 0 24px 60px rgba(60, 40, 160, 0.25); }
.modal-box h2 { margin: 0 0 12px; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toast { position: fixed; right: 18px; bottom: 18px; background: #2A2350; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 60; max-width: 420px;
  border: 1px solid var(--violet); box-shadow: 0 10px 30px rgba(42, 35, 80, 0.3); }
.toast.bad { background: var(--bad); border-color: var(--bad); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .nav { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; position: static; height: auto; }
  .nav .brand { padding: 0 8px 0 0; font-size: 18px; } .nav .grp, .nav .spacer { display: none; }
  .nav a { padding: 6px 8px; } .nav .me { width: 100%; padding: 6px 8px; }
  .main { padding: 18px 16px 30px; }
}
