:root {
  --gold: #ffbe3d;
  --gold-soft: #ffd370;
  --dark: #141414;
  --glass-bg: rgba(20, 20, 20, 0.55);
  --glass-bg-light: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.14);
  --text-light: #fdf6e3;
  --text-dim: rgba(253, 246, 227, 0.6);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.35);
  --danger: #ff5d5d;
  --success: #4ade80;
  --warn: #ffb020;
  --info: #4dabf7;
}
* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body {
  background: radial-gradient(circle at 20% 0%, #262218 0%, var(--dark) 55%);
  color: var(--text-light);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
}
a { color: var(--gold); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-glass);
}

.btn { background: var(--gold); color: #1a1400; border: none; border-radius: var(--radius-sm); padding: 10px 18px; font-weight: 600; font-size: 13px; }
.btn:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-outline { background: transparent; color: var(--text-light); border: 1px solid var(--glass-border); border-radius: var(--radius-sm); padding: 8px 14px; font-size: 12.5px; }
.btn-outline:hover { background: var(--glass-bg-light); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #06280f; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.field, select.field, textarea.field {
  width: 100%; background: var(--glass-bg-light); border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm); color: var(--text-light); padding: 10px 12px; font-size: 13px; outline: none;
}
.field::placeholder { color: var(--text-dim); }
.field:focus { border-color: var(--gold); }

#login-screen { display: flex; align-items: center; justify-content: center; height: 100%; padding: 20px; }
.login-card { width: 380px; max-width: 100%; padding: 36px 32px; display: flex; flex-direction: column; gap: 14px; }
.login-title { font-size: 22px; font-weight: 700; color: var(--gold); text-align: center; }
.login-sub { font-size: 12.5px; color: var(--text-dim); text-align: center; margin-bottom: 6px; }
.login-error { color: var(--danger); font-size: 13px; text-align: center; min-height: 18px; }

#app-screen { display: none; height: 100%; }
.layout { display: flex; height: 100%; }
.sidebar { width: 230px; flex-shrink: 0; display: flex; flex-direction: column; padding: 20px 14px; gap: 4px; border-right: 1px solid var(--glass-border); overflow-y: auto; }
.sidebar-logo { color: var(--gold); font-weight: 800; font-size: 19px; padding: 0 10px 16px; }
.sidebar-user { font-size: 12px; color: var(--text-dim); padding: 0 10px 14px; border-bottom: 1px solid var(--glass-border); margin-bottom: 10px; }
.sidebar-user b { color: var(--text-light); display: block; font-size: 13px; }
.role-badge { display: inline-block; margin-top: 4px; font-size: 10.5px; padding: 2px 8px; border-radius: 20px; background: rgba(255,190,61,0.15); color: var(--gold); }

.nav-item { display: flex; align-items: center; gap: 9px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text-dim); font-size: 13px; font-weight: 500; background: transparent; border: none; text-align: left; width: 100%; }
.nav-item:hover { background: var(--glass-bg-light); color: var(--text-light); }
.nav-item.active { background: rgba(255, 190, 61, 0.15); color: var(--gold); }
.sidebar-footer { margin-top: auto; font-size: 12px; color: var(--text-dim); padding: 0 10px; }

.main { flex: 1; overflow-y: auto; padding: 24px 32px 60px; }
.page-title { font-size: 22px; font-weight: 700; margin: 0 0 6px; }
.page-sub { font-size: 12.5px; color: var(--text-dim); margin: 0 0 18px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { padding: 16px; }
.stat-label { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--gold); }

.chart-card { padding: 20px; margin-bottom: 20px; }
.chart-title { font-size: 14px; font-weight: 600; margin-bottom: 14px; color: var(--text-dim); }

.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.toolbar .field { max-width: 260px; }
.toolbar-spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
thead th { text-align: left; color: var(--text-dim); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--glass-border); white-space: nowrap; cursor: default; }
thead th.sortable { cursor: pointer; }
thead th.sortable:hover { color: var(--gold); }
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--glass-border); vertical-align: top; }
tbody tr:hover { background: var(--glass-bg-light); }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 10.5px; font-weight: 600; white-space: nowrap; }
.badge-online { background: rgba(74, 222, 128, 0.15); color: var(--success); }
.badge-offline { background: rgba(255, 255, 255, 0.08); color: var(--text-dim); }
.badge-banned { background: rgba(255, 93, 93, 0.15); color: var(--danger); }
.badge-warn { background: rgba(255, 176, 32, 0.15); color: var(--warn); }
.badge-info { background: rgba(77, 171, 247, 0.15); color: var(--info); }
.badge-status-new { background: rgba(77,171,247,0.15); color: var(--info); }
.badge-status-in_progress { background: rgba(255,176,32,0.15); color: var(--warn); }
.badge-status-pending { background: rgba(255,190,61,0.15); color: var(--gold); }
.badge-status-closed { background: rgba(74,222,128,0.15); color: var(--success); }
.badge-status-rejected { background: rgba(255,93,93,0.15); color: var(--danger); }

.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; font-size: 12.5px; color: var(--text-dim); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-card { width: 480px; max-width: 100%; max-height: 88vh; overflow-y: auto; padding: 26px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-title { font-size: 17px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 20px; }
.modal-row { margin-bottom: 12px; }
.modal-row label { display: block; font-size: 11.5px; color: var(--text-dim); margin-bottom: 5px; }
.modal-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 16px; }
.modal-stat { background: var(--glass-bg-light); border-radius: var(--radius-sm); padding: 10px; }
.modal-stat-value { font-size: 16px; font-weight: 700; color: var(--gold); }
.modal-stat-label { font-size: 10.5px; color: var(--text-dim); }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }

.empty-state { text-align: center; color: var(--text-dim); padding: 36px 0; font-size: 13px; }
.loading { text-align: center; color: var(--text-dim); padding: 36px 0; }
.msg-content { max-width: 300px; white-space: pre-wrap; word-break: break-word; }
.e2ee-locked { color: var(--text-dim); font-style: italic; display: flex; align-items: center; gap: 6px; }

.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tab-btn { background: transparent; border: 1px solid var(--glass-border); color: var(--text-dim); border-radius: 20px; padding: 6px 14px; font-size: 12.5px; }
.tab-btn.active { background: rgba(255,190,61,0.15); color: var(--gold); border-color: transparent; }

.perm-table { font-size: 12px; }
.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.perm-yes { color: var(--success); }
.perm-no { color: var(--text-dim); opacity: 0.4; }

.toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; max-width: 320px; }
.toast-success { background: rgba(74,222,128,0.9); color: #06280f; }
.toast-error { background: rgba(255,93,93,0.9); color: #fff; }

@media (max-width: 1000px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar { width: 64px; }
  .sidebar-logo, .sidebar-user, .nav-item span, .sidebar-footer { display: none; }
  .nav-item { justify-content: center; }
}
