:root {
  --bg: #07070d;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.09);
  --text: #eef0ff;
  --muted: #9aa0c0;
  --primary: #7c5cff;
  --primary-2: #19d3ff;
  --grad: linear-gradient(135deg, #7c5cff 0%, #19d3ff 100%);
  --grad-soft: linear-gradient(135deg, rgba(124, 92, 255, 0.18), rgba(25, 211, 255, 0.18));
  --radius: 18px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', 'Segoe UI', system-ui, Consolas, monospace;
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 18% 12%, rgba(124, 92, 255, 0.16), transparent 45%),
    radial-gradient(circle at 85% 90%, rgba(25, 211, 255, 0.12), transparent 50%),
    linear-gradient(135deg, #07070d 0%, #0b0b16 60%, #07070d 100%);
  background-attachment: fixed;
}

.gradient-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ===== App shell ===== */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  display: flex; flex-direction: column; padding: 20px 14px; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 14px; border-bottom: 1px solid var(--border); }
.brand .logo {
  width: 38px; height: 38px; border-radius: 11px; background: var(--grad);
  display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 18px;
  box-shadow: 0 8px 24px rgba(124, 92, 255, 0.5);
}
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: 0.2px; }

.nav-tabs { display: flex; flex-direction: column; gap: 6px; }
.nav-tab {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 11px 14px; border-radius: 12px; background: transparent; color: var(--muted);
  border: 1px solid transparent; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .15s ease; box-shadow: none;
}
.nav-tab span { flex: 1; }
.nav-tab:hover { background: var(--surface-2); color: var(--text); transform: none; filter: none; box-shadow: none; }
.nav-tab.active { background: var(--grad-soft); color: var(--text); border-color: rgba(124, 92, 255, 0.4); }

.sidebar-actions { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
.sidebar-actions button { display: flex; align-items: center; gap: 8px; width: 100%; justify-content: flex-start; }

.sidebar-foot { padding-top: 14px; border-top: 1px solid var(--border); }

.content { flex: 1; min-width: 0; overflow-y: auto; padding: 24px 28px; }

.view { display: none; }
.view.active { display: flex; flex-direction: column; gap: 16px; animation: fade .25s ease; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ===== Buttons ===== */
button {
  padding: 9px 15px; border: none; border-radius: 999px;
  background: var(--grad); color: #fff; cursor: pointer; font-size: 13px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(124, 92, 255, 0.3);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
button:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 12px 32px rgba(124, 92, 255, 0.45); }
button:focus-visible { outline: 2px solid rgba(124, 92, 255, 0.6); outline-offset: 2px; }
button.ghost { background: var(--surface-2); border: 1px solid var(--border); box-shadow: none; color: var(--text); }
button.ghost:hover { background: var(--surface); }
button.danger { background: linear-gradient(135deg, #ff5ca8, #ff3d7f); box-shadow: 0 8px 24px rgba(255, 92, 168, 0.3); }
button.danger:hover { box-shadow: 0 12px 32px rgba(255, 92, 168, 0.45); }
button.small { padding: 9px 12px; font-size: 13px; border-radius: 12px; }
button.square { width: 40px; height: 40px; padding: 0; font-size: 18px; display: flex; align-items: center; justify-content: center; border-radius: 12px; }
button.active-toggle { background: linear-gradient(135deg, #1fbf6a, #14c173); }

/* ===== Role badge ===== */
.role-badge { font-size: 12px; padding: 5px 14px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); display: inline-block; }
.role-super { background: linear-gradient(135deg, #7b3fcf, #9a5cff); border-color: rgba(154, 92, 255, 0.5); }
.role-admin { background: linear-gradient(135deg, #c77a14, #e0962a); border-color: rgba(224, 150, 42, 0.5); }
.role-editor { background: linear-gradient(135deg, #0e9c5a, #14c173); border-color: rgba(20, 193, 115, 0.5); }
.role-viewer { background: var(--surface-2); }

/* ===== Cards / surfaces ===== */
.new-record, .record, .section, .perm-check, .inline-edit-row {
  background: var(--surface) !important; border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  backdrop-filter: blur(14px) saturate(135%); -webkit-backdrop-filter: blur(14px) saturate(135%);
  box-shadow: var(--shadow);
}
.section { padding: 14px; }
.record { padding: 14px 16px; margin-bottom: 14px; border-left: 3px solid var(--primary) !important; transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease; }
.record:hover { transform: translateY(-2px); border-color: rgba(124, 92, 255, 0.35) !important; box-shadow: 0 16px 44px rgba(0, 0, 0, 0.55); }
.new-record { padding: 14px; }

.new-record textarea, .record textarea {
  width: 100% !important; min-height: 220px !important;
  background: rgba(7, 9, 16, 0.6) !important; color: #9cdcfe;
  border: 1px solid var(--border) !important; border-radius: 12px; padding: 12px;
  font-family: Consolas, monospace; font-size: 13.5px; resize: none; overflow-y: auto;
}

.meta { color: var(--muted); font-size: 12px; margin-bottom: 8px; }

.console {
  flex: 1; min-height: 320px; background: var(--surface) !important; overflow-y: auto; padding: 16px;
  font-size: 13.5px; line-height: 1.5; border-radius: var(--radius) !important;
  border: 1px solid var(--border) !important; backdrop-filter: blur(14px); box-shadow: var(--shadow);
}
.log-line { padding: 6px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.log-time { color: #6b7790; margin-right: 12px; }

.ip-link { color: #5cc8ff; cursor: pointer; text-decoration: underline dotted; }
.ip-link:hover { color: #9fe0ff; }
.ip-masked { color: #6b7790; letter-spacing: 1px; }

.attempts {
  background: var(--surface) !important; overflow-y: auto; padding: 16px;
  border-radius: var(--radius) !important; border: 1px solid var(--border) !important;
  backdrop-filter: blur(14px) saturate(135%); box-shadow: var(--shadow);
}
.attempts h3 { margin-top: 0; }

/* ===== Tables ===== */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.07); text-align: left; }
th { color: var(--muted); font-weight: 600; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: rgba(255, 255, 255, 0.03); }

.modal-content { background: transparent; border: none; box-shadow: none; padding: 0; margin: 0; max-width: none; width: 100%; border-radius: 0; }

.hidden { display: none !important; }

/* ===== Forms ===== */
.form-row { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
.form-row input, .form-row select {
  background: rgba(7, 9, 16, 0.6); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 9px; font-family: inherit;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.form-row input:focus, .form-row select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.25); }
.form-row label { font-size: 12px; color: var(--muted); margin-right: 4px; }

.dur-input { width: 80px; }

.perm-check { display: flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 6px 12px; border-radius: 10px; }

.ip-menu {
  position: absolute; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 8px;
  z-index: 2000; display: flex; flex-direction: column; gap: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6); backdrop-filter: blur(18px);
}
.ip-menu button { text-align: left; font-size: 12px; background: rgba(255, 255, 255, 0.06); }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; width: fit-content; }
.tabs button { border-radius: 999px; }
.tabs button.active { background: var(--grad); }
.tabs button:not(.active) { background: transparent; color: var(--muted); }
.tabs button:not(.active):hover { background: var(--surface-2); color: var(--text); }

.search-box { flex: 1; min-width: 200px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: rgba(7, 9, 16, 0.6); color: var(--text); }
.search-box:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.25); }

h1, h2, h3 { font-weight: 700; }
h2 { margin-top: 0; }

/* ===== Login page ===== */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.box {
  background: var(--surface); padding: 40px; border-radius: var(--radius); width: 360px; max-width: 100%; text-align: center;
  border: 1px solid var(--border);
  backdrop-filter: blur(22px) saturate(150%); -webkit-backdrop-filter: blur(22px) saturate(150%);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.box h2 { background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; margin-top: 0; }
.box input { width: 100%; padding: 12px; margin: 8px 0; background: rgba(7, 9, 16, 0.6); border: 1px solid var(--border); color: #fff; border-radius: 12px; font-size: 16px; transition: border-color .12s ease, box-shadow .12s ease; }
.box input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.25); }
.box button { width: 100%; padding: 14px; margin-top: 15px; border-radius: 12px; font-size: 16px; font-weight: 600; }

body:has(.box) { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }

/* ===== Scrollbars ===== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.22); }

.bind-wrap { margin-top: 14px; text-align: center; font-size: 13px; color: var(--muted); }
.bind-wrap img { width: 180px; height: 180px; background: #fff; border-radius: 12px; padding: 8px; margin: 8px auto; display: block; }
.bind-wrap code { color: var(--primary-2); }
.mfa-qr { width: 200px; height: 200px; background: #fff; border-radius: 12px; padding: 8px; display: none; margin: 0 auto 10px; }
