:root {
  --bg: #0b0b0d;
  --surface: #141416;
  --surface-alt: #1c1c1f;
  --border: #2c2c31;
  --text: #f3f3f4;
  --text-muted: #a0a0a8;
  --accent: #ff3d3d;
  --accent-dim: #351a1b;
  --accent-rgb: 255, 61, 61;
  --accent-text: #1a0000;
  --good: #3ddc97;
  --good-rgb: 61, 220, 151;
  --bad: #ff7b72;
  --bad-rgb: 255, 123, 114;
  --warn: #f5b73b;
  --warn-rgb: 245, 183, 59;
  --radius: 14px;
  --mono: 'JetBrains Mono', monospace;
  --shadow-sm: 0 2px 10px -4px rgba(0,0,0,.4);
  --shadow-md: 0 16px 32px -14px rgba(0,0,0,.6);
}

:root[data-theme="light"] {
  --bg: #f6f5f3;
  --surface: #ffffff;
  --surface-alt: #efedea;
  --border: #dedbd7;
  --text: #161616;
  --text-muted: #66666b;
  --accent: #d10000;
  --accent-dim: #fae6e6;
  --accent-rgb: 209, 0, 0;
  --accent-text: #ffffff;
  --good: #17784f;
  --good-rgb: 23, 120, 79;
  --bad: #b3261e;
  --bad-rgb: 179, 38, 30;
  --warn: #9a5b00;
  --warn-rgb: 154, 91, 0;
  --shadow-sm: 0 2px 10px -4px rgba(20,20,20,.10);
  --shadow-md: 0 16px 32px -14px rgba(20,20,20,.16);
}

* { box-sizing: border-box; }

* { -webkit-tap-highlight-color: transparent; }

button, .icon-btn, .password-toggle, .nav-item, svg {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Tajawal', sans-serif;
  direction: rtl;
  transition: background-color .2s ease, color .2s ease;
}

::selection { background: var(--accent); color: var(--accent-text); }

a:focus-visible,
button:focus-visible,
.nav-item:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.icon-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), .45);
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--surface-alt); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--border); }
::-webkit-scrollbar-track { background: transparent; }

button, input, select {
  font-family: inherit;
}


input[type="text"], input[type="password"], input[type="number"],
input[type="date"], input[type="email"], select, textarea {
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
input[type="text"]:hover, input[type="password"]:hover, input[type="number"]:hover,
input[type="date"]:hover, input[type="email"]:hover, select:hover, textarea:hover {
  border-color: var(--text-muted);
}
input[type="text"]:focus, input[type="password"]:focus, input[type="number"]:focus,
input[type="date"]:focus, input[type="email"]:focus, select:focus, textarea:focus {
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .13);
}


.login-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 20% 15%, rgba(var(--accent-rgb), 0.08), transparent 40%),
    radial-gradient(circle at 80% 85%, rgba(var(--good-rgb), 0.06), transparent 40%),
    var(--bg);
}

.login-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.landing-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.landing-main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 24px 60px;
}
.landing-hero {
  text-align: center;
  padding: 40px 20px 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.landing-hero-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.landing-hero-icon svg { width: 34px; height: 34px; }
.landing-hero h1 {
  font-size: 28px;
  font-weight: 900;
  max-width: 680px;
  line-height: 1.4;
  margin: 0;
}
.landing-hero p {
  color: var(--text-muted);
  max-width: 620px;
  line-height: 1.9;
  font-size: 14.5px;
  margin: 0;
}
.landing-section { margin-top: 48px; }
.landing-section h2 {
  font-size: 20px;
  font-weight: 800;
  margin: 0 0 6px;
}
.landing-section-sub {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 22px;
}
.landing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.landing-grid-commands { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.landing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease;
}
.landing-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.landing-card-icon { font-size: 26px; margin-bottom: 10px; }
.landing-card h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 8px;
}
.landing-card p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.8;
  margin: 0;
}
.landing-cmd-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.landing-cmd-list li {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
}
.landing-cmd-list code {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 2px 7px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12px;
}
@media (max-width: 640px) {
  .landing-hero h1 { font-size: 22px; }
}

.login-stub {
  width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  position: relative;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,0.6);
}

.stub-perf {
  height: 0;
  border-top: 2px dashed var(--border);
  margin: 0 24px;
}
.stub-perf:first-child { display: none; }

.login-card { padding: 40px 32px 32px; }

.login-brand { text-align: center; margin-bottom: 28px; }
.brand-mark { font-size: 36px; line-height: 1; margin-bottom: 8px; display: none; align-items: center; justify-content: center; }
.brand-mark svg { width: 28px; height: 28px; }
.brand-logo { width: 48px; height: 48px; object-fit: contain; display: block; margin: 0 auto 8px; border-radius: 10px; }
.logo-light { display: none; }
[data-theme="light"] .logo-dark { display: none; }
[data-theme="light"] .logo-light { display: block; }
.login-brand h1 { font-size: 20px; margin: 0 0 4px; font-weight: 900; }
.brand-sub { color: var(--text-muted); font-size: 13px; margin: 0; }

.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-muted); }
.login-form input {
  width: 100%;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 14px;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}
.login-form input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), .14);
}
.login-form input[type="password"] { letter-spacing: 3px; }

.field { position: relative; display: flex; }
.field input { flex: 1; padding-inline-start: 42px !important; }
.field-icon {
  position: absolute;
  inset-inline-start: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  display: flex;
  pointer-events: none;
  transition: color .18s ease;
}
.field-icon svg { width: 16px; height: 16px; }
.field input:focus ~ .field-icon { color: var(--accent); }

.password-field input[type="password"],
.password-field input[type="text"] { padding-inline-end: 42px !important; }
.password-toggle,
.password-toggle:hover,
.password-toggle:focus,
.password-toggle:active,
.password-toggle:focus-visible {
  position: absolute;
  inset-inline-end: 5px;
  top: 50%;
  transform: translateY(-50%) !important;
  background: transparent !important;
  background-color: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 0;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s ease;
}
.password-toggle { color: var(--text-muted); }
.password-toggle svg { width: 18px; height: 18px; }
.password-toggle:hover,
.password-toggle:active,
.password-toggle:focus-visible { color: var(--accent) !important; }

input[type="password"]::-webkit-credentials-auto-fill-button,
input[type="password"]::-webkit-strong-password-auto-fill-button {
  display: none !important;
  visibility: hidden;
  pointer-events: none;
  position: absolute;
  right: 0;
}
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear {
  display: none;
}

.login-form button {
  margin-top: 6px;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  padding: 12px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
}
.login-form button:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 8px 20px -8px rgba(var(--accent-rgb), .5); }

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
  color: var(--text-muted);
  font-size: 12px;
}
.login-divider::before, .login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.login-discord-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  background: #5865F2;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
}
.login-discord-btn:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 8px 20px -8px rgba(88,101,242,.6); }

.login-error {
  margin: 16px 0 0;
  color: var(--bad);
  font-size: 13px;
  text-align: center;
}


:root { --header-height: 62px; }

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 60;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.page-header-left { display: flex; align-items: center; gap: 14px; }
.page-header-right { display: flex; align-items: center; gap: 20px; }
#viewTitle { margin: 0; font-size: 17px; }
.ratings-summary { display: flex; gap: 24px; padding: 2px 0 14px; color: var(--text-muted); font-size: 13px; }
.ratings-summary strong { color: var(--text); font-size: 14px; }

.viewer-banner {
  background: var(--accent-dim);
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding: 8px 20px;
  font-size: 13px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.viewer-banner[hidden] { display: none; }
.viewer-banner svg { width: 15px; height: 15px; flex-shrink: 0; }

.star-ico { width: 13px; height: 13px; vertical-align: -2px; margin-inline-start: 3px; color: var(--accent); }
body.viewer-mode .btn-primary,
body.viewer-mode .btn-danger-outline,
body.viewer-mode .btn-ghost.btn-sm,
body.viewer-mode #settingRequireReason,
body.viewer-mode #settingEnableRating,
body.viewer-mode #settingNamingScheme {
  opacity: .4;
  pointer-events: none;
  cursor: not-allowed;
}
.page-header .brand-logo { width: 30px; height: 30px; object-fit: contain; border-radius: 7px; margin: 0; }
.page-header .brand-mark { font-size: 22px; margin: 0; }
.page-header .brand-mark svg { width: 20px; height: 20px; }

.page-footer {
  flex-shrink: 0;
  padding: 14px 24px;
  text-align: center;
  border-top: 1px dashed var(--border);
  background: var(--surface);
}
.page-footer span {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
  line-height: 1.7;
}
.page-footer strong { color: var(--accent); font-weight: 600; }

.app-body {
  display: grid;
  grid-template-columns: 260px 1fr;
  flex: 1;
  transition: grid-template-columns .2s ease;
}
.app-body.sidebar-collapsed { grid-template-columns: 0 1fr; }
.app-body.sidebar-collapsed .sidebar {
  padding-left: 0;
  padding-right: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.sidebar {
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
}

.sidebar-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px 20px;
}
.sidebar .brand-mark { font-size: 26px; }
.sidebar .brand-logo { width: 32px; height: 32px; object-fit: contain; border-radius: 8px; margin: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-text strong { font-size: 15px; }
.brand-text span { font-size: 12px; color: var(--text-muted); }

.sidebar-perf {
  height: 0;
  border-top: 2px dashed var(--border);
  margin: 0 22px 16px;
}

.nav { display: flex; flex-direction: column; gap: 2px; padding: 0 12px; flex: 1; }
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 11px 12px;
  border-radius: 10px;
  font-size: 14px;
  text-align: right;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.nav-item:hover { background: var(--surface-alt); color: var(--text); }
.nav-item.active { background: var(--surface-alt); color: var(--accent); font-weight: 700; }
.nav-item[hidden] { display: none; }
.nav-item.active::before {
  content: '';
  position: absolute;
  inset-inline-start: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 55%;
  background: var(--accent);
  border-radius: 4px;
}
.nav-ico { width: 16px; text-align: center; opacity: .8; display: inline-flex; align-items: center; justify-content: center; }
.nav-ico svg { width: 16px; height: 16px; }

.sidebar-bottom { padding: 16px 22px 20px; display: flex; flex-direction: column; gap: 12px; }

.bot-chip {
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: var(--mono);
  text-align: center;
}
.server-chip {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: var(--mono);
  text-align: center;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
}
.user-chip-icon {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.user-chip-icon svg { width: 16px; height: 16px; }
.user-chip-info { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.user-chip-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-chip-role { font-size: 11px; color: var(--text-muted); }
.logout-btn {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 9px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: border-color .12s ease, color .12s ease;
}
.logout-btn:hover { border-color: var(--bad); color: var(--bad); }

.content { padding: 28px 34px; overflow-x: hidden; }

.sidebar-toggle-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s ease, border-color .12s ease;
}
.sidebar-toggle-btn svg { width: 18px; height: 18px; }
.sidebar-toggle-btn:hover { background: var(--surface-alt); border-color: var(--accent); }


.icon-btn {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s ease, border-color .12s ease;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--surface-alt); border-color: var(--accent); }

.notif-dot {
  position: absolute;
  top: 6px;
  inset-inline-end: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bad);
  border: 2px solid var(--surface);
}

.notif-wrap { position: relative; }
.notif-panel {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 10px);
  width: 320px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  z-index: 80;
  animation: modal-in .14s ease;
}
.notif-panel-head {
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  position: sticky;
  top: 0;
  background: var(--surface);
}
.notif-list { display: flex; flex-direction: column; }
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  cursor: pointer;
  transition: background-color .12s ease;
}
.notif-item:hover { background: var(--surface-alt); }
.notif-item:last-child { border-bottom: none; }
.notif-item-icon { flex-shrink: 0; display: flex; align-items: center; color: var(--text-muted); }
.notif-item-icon svg { width: 16px; height: 16px; }
.notif-item-body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.notif-item-title { color: var(--text); }
.notif-item-title strong { color: var(--accent); }
.notif-item-time { color: var(--text-muted); font-size: 11.5px; font-family: var(--mono); }
.notif-item-dismiss {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .12s ease, background-color .12s ease;
}
.notif-item-dismiss svg { width: 13px; height: 13px; }
.notif-item-dismiss:hover { color: var(--bad); background: var(--surface); }

@keyframes row-flash {
  0%, 100% { background-color: transparent; }
  15%, 85% { background-color: rgba(var(--accent-rgb), 0.22); }
}
.row-flash-highlight { animation: row-flash 2.2s ease; }


#loadingBar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 300;
  overflow: hidden;
  pointer-events: none;
}
#loadingBar::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 35%;
  background: var(--accent);
  border-radius: 4px;
  transform: translateX(-100%);
  opacity: 0;
  box-shadow: 0 0 10px rgba(var(--accent-rgb), .6);
}
#loadingBar.active::before {
  opacity: 1;
  animation: loading-slide 1s ease-in-out infinite;
}
@keyframes loading-slide {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(140%); }
  100% { transform: translateX(380%); }
}


.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 34px 0;
  color: var(--text-muted);
}
.empty-state svg { width: 34px; height: 34px; opacity: .45; }
.empty-state span { font-size: 13px; }


.tag-with-avatar { display: inline-flex; align-items: center; gap: 8px; }
.avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}
.avatar-placeholder {
  display: inline-block;
  background: var(--surface-alt);
  position: relative;
}
.avatar-placeholder::before {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: .5;
}
.notif-empty { padding: 30px 16px; text-align: center; color: var(--text-muted); font-size: 13px; }

.view { display: none; }
.view.active { display: block; animation: view-in .18s ease; }
@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}


.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .stat-grid { grid-template-columns: 1fr; }
  .notif-panel { width: min(320px, 90vw); }
}

.stat-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent-dim);
}
.stat-card::before, .stat-card::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 20px;
  height: 20px;
  background: var(--bg);
  border-radius: 50%;
  transform: translateY(-50%);
}
.stat-card::before { right: -10px; }
.stat-card::after { left: -10px; }

.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.stat-value { font-family: var(--mono); font-size: 28px; font-weight: 700; }
.stat-value.accent { color: var(--accent); }
.stat-value.good { color: var(--good); }
.stat-value.bad { color: var(--bad); }
.stat-trend { display: block; margin-top: 6px; font-size: 11px; color: var(--text-muted); }
.stat-trend.good { color: var(--good); }
.stat-trend.bad { color: var(--bad); }


.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.panel-head h3 {
  margin: 0;
  font-size: 16px;
  position: relative;
  padding-inline-start: 13px;
}
.panel-head h3::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 15px;
  background: var(--accent);
  border-radius: 4px;
}

.badge-ignored {
  display: inline-block;
  margin-inline-start: 8px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10.5px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--border);
  vertical-align: middle;
}

.actions-cell { display: flex; gap: 8px; flex-wrap: wrap; }

.count-badge {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: right;
  color: var(--text-muted);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .4px;
}
tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background-color .12s ease; }
tbody tr:hover { background: var(--surface-alt); }
.mono { font-family: var(--mono); font-size: 12px; color: var(--text-muted); }
.empty-row td { text-align: center; color: var(--text-muted); padding: 0; }

.pager { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.pager button {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: border-color .12s ease, color .12s ease, background-color .12s ease;
}
.pager button:hover:not(:disabled) { border-color: var(--accent); }
.pager button:disabled { opacity: .4; cursor: default; }
.pager button.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.pager button.pager-arrow { font-weight: 700; padding: 7px 12px; }

select {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
}


.dept-breakdown { display: flex; flex-direction: column; gap: 10px; }
.dept-row {
  display: grid;
  grid-template-columns: 160px 1fr 60px 60px;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.dept-row-label { display: flex; align-items: center; gap: 8px; }
#deptBreakdown .dept-row { grid-template-columns: 160px 1fr 60px; }
.dept-bar-track {
  height: 8px;
  background: var(--surface-alt);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
}
.dept-bar-open { background: var(--good); }
.dept-bar-closed { background: #FFD60A; }
.dept-num { font-family: var(--mono); text-align: center; }

.dept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.dept-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.dept-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent-dim);
}
.dept-card-pending-badge {
  background: #FEE75C;
  color: #3d3200;
  font-size: 11.5px;
  font-weight: 700;
  text-align: center;
  padding: 6px 10px;
}
.dept-card-banner {
  width: 100%;
  height: 110px;
  object-fit: cover;
  display: block;
  background: var(--surface);
}
.dept-card-body { padding: 16px; }
.dept-card-title { font-weight: 700; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.dept-card-id { font-family: var(--mono); font-size: 11px; color: var(--text-muted); }
.dept-card-desc { font-size: 13px; color: var(--text-muted); margin-top: 8px; line-height: 1.6; }

.dept-card-meta {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dept-card-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
}
.dept-card-meta-row span { color: var(--text-muted); }
.dept-card-meta-row strong { font-weight: 600; }
.dept-color-chip { display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 11px; }
.color-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid var(--border);
  display: inline-block;
}

.dept-card-welcome {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.dept-card-welcome span { font-size: 11px; color: var(--text-muted); }
.dept-card-welcome p {
  font-size: 12.5px;
  margin: 4px 0 0;
  line-height: 1.6;
  color: var(--text);
  max-height: 60px;
  overflow-y: auto;
}

@media (max-width: 860px) {
  .app-body { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; top: 0; }
  .dept-row { grid-template-columns: 110px 1fr 40px 40px; }
  #deptBreakdown .dept-row { grid-template-columns: 110px 1fr 40px; }
}


.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  padding: 10px 18px;
  border-radius: 9px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: filter .12s ease, transform .12s ease, box-shadow .12s ease;
}
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 10px 22px -10px rgba(var(--accent-rgb),.55); }
.btn-primary:active { transform: translateY(0); filter: brightness(.96); box-shadow: none; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 10px 18px;
  border-radius: 9px;
  font-size: 13px;
  cursor: pointer;
  transition: color .12s ease, border-color .12s ease, background-color .12s ease;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); background: var(--surface-alt); }

.btn-sm { padding: 7px 14px; font-size: 12.5px; }

.btn-danger-outline {
  background: transparent;
  border: 1px solid var(--bad);
  color: var(--bad);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: background-color .12s ease, color .12s ease, box-shadow .12s ease;
}
.btn-danger-outline:hover { background: var(--bad); color: #fff; box-shadow: 0 8px 18px -10px rgba(var(--bad-rgb),.55); }

.btn-link {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color .12s ease, transform .12s ease;
}
.btn-link svg { width: 13px; height: 13px; }
.btn-link:hover { border-color: var(--accent); transform: translateY(-1px); }


.inline-form {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.inline-form input, .inline-form select {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
}
.inline-form input { flex: 1; min-width: 180px; }

.modal-error {
  color: var(--bad);
  font-size: 13px;
  margin: -6px 0 12px;
}


.dept-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}


.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-backdrop.active { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,0.6);
  animation: modal-in .16s ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  transition: color .12s ease, background-color .12s ease;
}
.modal-close svg { width: 16px; height: 16px; }
.modal-close:hover { color: var(--bad); background: var(--surface-alt); }

.modal-form { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-muted); }
.modal-form input, .modal-form select, .modal-form textarea {
  font-family: inherit;
  resize: vertical;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
}
.modal-form input:focus, .modal-form select:focus, .modal-form textarea:focus { border-color: var(--accent); }
.scope-depts-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  background: var(--surface-alt);
}
.scope-depts-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.scope-depts-count {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
  white-space: nowrap;
}
.scope-depts-actions { display: flex; gap: 6px; }
.scope-depts-actions .btn-ghost { padding: 4px 10px; font-size: 11.5px; }
.scope-depts-list .scope-dept-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.scope-depts-list .scope-dept-item:hover { background: var(--surface); }
.scope-depts-list .scope-dept-item:has(input:checked) {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}
.scope-depts-list .scope-dept-item input {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  border-radius: 0;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.admin-scope-chip {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--accent-dim);
  color: var(--accent);
  margin-inline-end: 4px;
  margin-bottom: 2px;
}
.modal-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }


.panel-hint {
  color: var(--text-muted);
  font-size: 13px;
  margin: -6px 0 16px;
  line-height: 1.6;
}
.panel-hint code {
  font-family: var(--mono);
  background: var(--surface-alt);
  padding: 2px 6px;
  border-radius: 6px;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  vertical-align: middle;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 24px;
  transition: background .15s ease, border-color .15s ease;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 16px;
  width: 16px;
  right: 3px;
  top: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,.35);
  transition: transform .15s ease, background .15s ease;
}
.toggle-switch input:checked + .toggle-slider { background: rgba(var(--good-rgb), 0.15); border-color: var(--good); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(-18px); background: var(--good); }


.emoji-img {
  width: 18px;
  height: 18px;
  vertical-align: -4px;
  display: inline-block;
  object-fit: contain;
}


.settings-form {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 4px;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }
.settings-row-text { display: flex; flex-direction: column; gap: 4px; }
.settings-row-text strong { font-size: 14px; }
.settings-row-text span { font-size: 12.5px; color: var(--text-muted); }
.inline-save-field {
  display: flex;
  align-items: center;
  gap: 8px;
}
.inline-save-field input[type="number"],
.inline-save-field select {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
}
.inline-save-field input[type="number"]:focus,
.inline-save-field select:focus { border-color: var(--accent); }
.inline-save-field input[type="number"] {
  width: 90px;
  text-align: center;
}
.inline-save-field select { min-width: 200px; }
.settings-row select {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  min-width: 160px;
}


.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin: 14px 0 16px;
}
.config-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.config-grid input {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
}
.config-grid input:focus { border-color: var(--accent); }


.modal-wide {
  max-width: 900px;
  width: 95%;
  height: 85vh;
  display: flex;
  flex-direction: column;
}
.transcript-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff;
  border-radius: 0 0 16px 16px;
}


.daily-volume-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 160px;
  padding: 10px 4px 4px;
  overflow-x: auto;
  overflow-y: hidden;
}
.daily-volume-bar-wrap {
  flex: 0 0 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  gap: 6px;
}
.daily-volume-bar {
  width: 100%;
  max-width: 26px;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
}
.daily-volume-label {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--mono);
  white-space: nowrap;
}
.daily-volume-count {
  font-size: 11px;
  color: var(--text);
  font-family: var(--mono);
}


.ratings-distribution { display: flex; flex-direction: column; gap: 10px; }
.rating-row {
  display: grid;
  grid-template-columns: 60px 1fr 40px;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.rating-bar-track {
  height: 10px;
  background: var(--surface-alt);
  border-radius: 6px;
  overflow: hidden;
}
.rating-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 6px;
}


.toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-right: 3px solid var(--good);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  box-shadow: var(--shadow-md);
  animation: toast-in .2s ease;
  max-width: 320px;
}
.toast.toast-error { border-right-color: var(--bad); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to { opacity: 1; transform: none; }
}

/* ===== Shared site chrome (header / footer / server picker) ===== */
.page-header-left .brand-link { display: flex; align-items: center; gap: 14px; color: inherit; text-decoration: none; }
.page-header-right form { margin: 0; display: inline-flex; }
.page-header-right .btn-ghost, .page-header-right .btn-primary { white-space: nowrap; }
.site-chip {
  font-size: 12.5px; color: var(--text-muted); background: var(--surface-alt);
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px;
  max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.page-footer a { color: var(--accent); text-decoration: none; }
.page-footer a:hover { text-decoration: underline; }
.btn-danger-text { color: var(--bad) !important; }
.btn-ghost:disabled, .btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }
@media (max-width: 760px) {
  .page-header { padding: 0 12px; }
  .page-header-right { gap: 8px; }
  .page-header-left h2, .site-chip { display: none; }
}

/* toast used by the standalone pages */
#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  padding: 11px 18px; border-radius: 12px; box-shadow: var(--shadow-sm); font-size: 14px; max-width: 90vw;
}
#toast[hidden] { display: none; }
#toast.error { border-color: var(--bad); color: var(--bad); }


/* ===== Shared landing-style badges (used by landing, legal pages, etc.) ===== */
.landing-badge-row {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
  margin-top: 4px;
  }
.landing-badge {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 7px 16px; font-size: 12.5px; color: var(--text-muted);
  }
.landing-badge strong { color: var(--text); font-family: var(--mono); }
.landing-eyebrow {
  display: inline-block; font-size: 11.5px; font-weight: 700; letter-spacing: .04em;
  color: var(--accent); background: var(--accent-dim); padding: 5px 12px;
  border-radius: 999px; margin-bottom: 12px;
  }
