:root {
  --bg: #0b0d10;
  --panel: #14181f;
  --panel-2: #191f28;
  --ink: #f3f5f8;
  --muted: #9aa4b2;
  --line: #2a313d;
  --blue: #f97316;
  --green: #21a67a;
  --red: #d84b45;
  --yellow: #f59e0b;
  --dark: #090b0e;
  --gold: #f97316;
  --orange: #f97316;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(5,7,10,.76), rgba(9,11,14,.94)),
    url("/assets/wt-banner.gif") center / cover fixed no-repeat,
    radial-gradient(circle at 14% 0%, rgba(249,115,22,.22), transparent 30%),
    radial-gradient(circle at 90% 12%, rgba(249,115,22,.10), transparent 28%),
    linear-gradient(135deg, #090b0e 0%, #10151d 48%, #0b0d10 100%);
  background-color: #090b0e;
}
button, input, select, textarea { font: inherit; }
button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 6px;
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
}
button:hover { border-color: #9fb3d1; }
.hidden { display: none !important; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 280px 1fr; direction: ltr; align-items: start; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #07090c 0%, #11161d 56%, #07090c 100%);
  color: #e7edf8;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  direction: rtl;
}
.brand { display: flex; align-items: center; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid #2a2018; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 8px;
  object-fit: cover;
  border: 1px solid rgba(249,115,22,.58);
  background: #090b0e;
  box-shadow: 0 0 0 2px rgba(249,115,22,.08), 0 10px 24px rgba(0,0,0,.28);
}
.brand small { display: block; color: #c0cad8; margin-top: 3px; }
nav { display: grid; gap: 6px; }
.nav-btn {
  border: 0;
  color: #dce7f7;
  background: transparent;
  text-align: right;
  justify-content: flex-start;
  width: 100%;
}
.nav-btn.active, .nav-btn:hover { background: rgba(249,115,22,.16); color: #fff; border: 1px solid rgba(249,115,22,.42); }
.full { width: 100%; }
.main { direction: rtl; min-width: 0; }
.topbar {
  min-height: 86px;
  background: rgba(14,18,24,.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.topbar h2 { margin: 0 0 5px; font-size: 24px; }
.topbar p { margin: 0; color: var(--muted); }
.content { padding: 22px; display: grid; gap: 18px; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card {
  background: rgba(20,24,31,.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 34px rgba(0,0,0,.22);
  padding: 16px;
}
.metric { display: grid; gap: 6px; }
.metric span { color: var(--muted); }
.metric strong { font-size: 28px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
input, select, textarea {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #10151d;
  color: var(--ink);
}
textarea { min-height: 80px; width: 100%; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
th, td { text-align: right; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: #f6c393; background: #1b2029; font-weight: 700; }
tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.compact-actions { flex-wrap: nowrap; justify-content: flex-start; }
.icon-btn {
  width: 36px;
  min-width: 36px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-weight: 800;
}
.primary, .primary-link { background: var(--blue); color: white; border-color: var(--blue); }
.danger { background: var(--red); color: white; border-color: var(--red); }
.warn { background: var(--yellow); color: #201400; border-color: var(--yellow); }
.success { background: var(--green); color: white; border-color: var(--green); }
.ghost { background: transparent; color: inherit; }
.tag { display: inline-flex; align-items: center; min-height: 26px; padding: 0 8px; border-radius: 999px; background: rgba(249,115,22,.14); color: #fdba74; font-size: 13px; }
.tag.status-active { background: rgba(33,166,122,.16); color: #86efac; }
.store-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.store-form label { display: grid; gap: 6px; color: var(--muted); font-weight: 700; }
.store-form .wide { grid-column: span 2; }
.store-form button { align-self: end; }
.store-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.store-card {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 12px;
  align-items: center;
  background: linear-gradient(135deg, rgba(20,24,31,.96), rgba(16,21,29,.92));
  border: 1px solid rgba(249,115,22,.24);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 18px 34px rgba(0,0,0,.22);
}
.store-card h4 { margin: 0 0 3px; }
.store-card small { color: var(--muted); }
.store-icon {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(249,115,22,.16);
  border: 1px solid rgba(249,115,22,.44);
  color: #fdba74;
  font-weight: 900;
}
.store-grades {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.store-grades span {
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #10151d;
  border: 1px solid var(--line);
  color: #d8dee9;
  font-size: 12px;
}
.monitor-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  align-items: start;
}
.monitor-list {
  position: sticky;
  top: 96px;
  display: grid;
  gap: 12px;
  max-height: calc(100vh - 120px);
  overflow: auto;
}
.monitor-player {
  width: 100%;
  min-height: 58px;
  display: grid;
  gap: 4px;
  text-align: right;
  background: #10151d;
}
.monitor-player strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.monitor-player small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.monitor-stage { display: grid; gap: 14px; min-width: 0; }
.monitor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.monitor-card {
  background: rgba(20,24,31,.96);
  border: 1px solid rgba(249,115,22,.22);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 18px 34px rgba(0,0,0,.22);
}
.monitor-head {
  min-height: 44px;
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: rgba(9,11,14,.72);
}
.monitor-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.monitor-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  background: #05070a;
}
.monitor-empty {
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: #05070a;
}
.monitor-meta {
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
}
.data-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.data-field {
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10151d;
  padding: 10px 12px;
  display: grid;
  align-content: center;
  gap: 5px;
}
.data-field span { color: var(--muted); font-size: 13px; }
.data-field strong { color: var(--ink); overflow-wrap: anywhere; }
.god { color: var(--red); font-weight: 800; }
.tabs { display: flex; gap: 8px; }
.tab.active { background: var(--dark); color: #fff; border-color: var(--dark); }
.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: 90px 1fr 52px; gap: 8px; align-items: center; }
.bar-track { height: 10px; background: #232a35; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--orange); }
.login-screen { min-height: 100vh; display: grid; place-items: center; background: transparent; color: white; padding: 20px; }
.login-panel {
  width: min(440px, calc(100vw - 30px));
  background: rgba(12,15,20,.88);
  border: 1px solid rgba(249,115,22,.28);
  border-radius: 8px;
  padding: 28px;
  text-align: center;
  box-shadow: 0 24px 90px rgba(0,0,0,.48);
  backdrop-filter: blur(10px);
}
.login-logo {
  width: 132px;
  height: 132px;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid rgba(249,115,22,.56);
  box-shadow: 0 14px 42px rgba(0,0,0,.38);
  margin-bottom: 14px;
}
.primary-link { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 18px; border-radius: 6px; text-decoration: none; margin-top: 10px; }
.modal { position: fixed; inset: 0; background: rgba(10, 18, 31, .55); display: grid; place-items: center; z-index: 20; }
.modal-box { width: min(620px, calc(100vw - 28px)); max-height: calc(100vh - 40px); overflow: auto; background: #14181f; border: 1px solid var(--line); border-radius: 8px; padding: 18px; box-shadow: 0 24px 80px rgba(0, 0, 0, .45); }
.modal-actions { display: flex; justify-content: flex-start; gap: 10px; margin-top: 16px; }
.modal-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.modal-form label { display: grid; gap: 6px; color: var(--muted); font-weight: 700; }
.modal-form .modal-wide { grid-column: 1 / -1; }
.modal-form textarea { min-height: 260px; direction: ltr; text-align: left; font-family: Consolas, "Courier New", monospace; }
.modal-choice { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.modal-choice.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.soft-divider { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.role-list { display: grid; gap: 8px; }
.role-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10151d;
  padding: 10px;
}
.role-row small { display: block; color: var(--muted); margin-top: 3px; }
.admin-actions { display: grid; gap: 12px; }
.action-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10151d;
  padding: 12px;
}
.action-group h4 { margin: 0 0 10px; color: #fdba74; }
.action-group.danger-zone { border-color: rgba(216,75,69,.46); background: rgba(216,75,69,.08); }
.nested-panel { margin-top: 12px; box-shadow: none; }
.storage-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10151d;
  margin-top: 10px;
  overflow: hidden;
}
.storage-details summary {
  min-height: 46px;
  padding: 12px 14px;
  cursor: pointer;
  color: #fdba74;
  font-weight: 800;
}
.storage-details[open] summary { border-bottom: 1px solid var(--line); }
.storage-body { padding: 12px; display: grid; gap: 12px; }
.toast {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translate(-50%, -16px);
  opacity: 0;
  pointer-events: none;
  z-index: 30;
  min-width: min(420px, calc(100vw - 32px));
  background: #101722;
  color: #fff;
  border: 1px solid rgba(216,180,90,.42);
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: 0 20px 50px rgba(16,24,39,.22);
  text-align: center;
  transition: .18s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--red); border-color: var(--red); }
.toast.success { background: var(--green); border-color: var(--green); }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.section-title h3 { margin: 0; }
.permission-builder { display: grid; gap: 22px; margin: 14px 0; }
.permission-section { display: grid; gap: 10px; padding-top: 16px; border-top: 1px solid var(--line); }
.permission-section:first-child { border-top: 0; padding-top: 0; }
.permission-section h4 { margin: 0; color: #fdba74; font-size: 16px; }
.permission-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.permission-option {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10151d;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.permission-option span { color: var(--ink); line-height: 1.35; }
.empty { padding: 24px; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 8px; background: #10151d; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  .monitor-layout { grid-template-columns: 1fr; }
  .monitor-list { position: static; max-height: none; }
  .monitor-grid { grid-template-columns: 1fr; }
  .store-grid, .store-form { grid-template-columns: 1fr; }
  .store-form .wide { grid-column: auto; }
  .data-grid { grid-template-columns: 1fr; }
  .modal-form { grid-template-columns: 1fr; }
  .permission-grid { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
}
