@import url("https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800;900&display=swap");
@import url("https://fonts.cdnfonts.com/css/montserrat");

:root {
  --bg: #0d0d0f;
  --bg-soft: #151516;
  --panel: rgba(17, 17, 17, 0.56);
  --panel-strong: rgba(21, 21, 22, 0.78);
  --control: rgba(60, 60, 60, 0.56);
  --control-hover: rgba(76, 76, 76, 0.82);
  --line: #272727;
  --line-soft: rgba(255, 255, 255, 0.08);
  --text: rgba(255, 255, 255, 0.9);
  --muted: rgba(255, 255, 255, 0.52);
  --faint: rgba(255, 255, 255, 0.2);
  --accent: #a038e1;
  --accent-soft: rgba(160, 56, 225, 0.58);
  --accent-line: rgba(199, 104, 247, 0.75);
  --accent-text: #d7b2ff;
  --green: #1eff00;
  --danger: #fb2d2d;
  --warning: #ffd166;
  --shadow: 0 0 6px 1px #272727;
  --glow: 0 0 8px 2px rgba(143, 60, 177, 0.7);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(30, 30, 30, 0.95), rgba(10, 10, 11, 0.98)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 140px),
    var(--bg);
  color: var(--text);
  font-family: "Tajawal", Tahoma, Arial, sans-serif;
  letter-spacing: 0;
}

body::before {
  position: fixed;
  inset: 0;
  content: "";
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.24), transparent 28%, transparent 72%, rgba(0, 0, 0, 0.24)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent 22%, rgba(0, 0, 0, 0.42));
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.login-view {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(470px, 100%);
  position: relative;
  display: grid;
  gap: 22px;
  padding: 30px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.login-panel::before,
.topbar::before,
.section-head::before {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  border-radius: inherit;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.login-logo {
  width: 78px;
  height: 78px;
  object-fit: contain;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--control);
  box-shadow: var(--glow);
}

.login-panel h1,
.topbar h1,
.section-head h2,
.section-head h3 {
  margin: 0;
}

.login-panel h1 {
  font-size: 32px;
  font-weight: 900;
  color: var(--text);
}

.muted,
.section-head p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.8;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 800;
}

.primary-link,
.primary-btn,
.secondary-btn,
.danger-btn {
  border-radius: var(--radius);
  min-height: 42px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  text-decoration: none;
  font-weight: 800;
  white-space: nowrap;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, color 0.18s ease;
}

.primary-link,
.primary-btn {
  color: rgba(255, 255, 255, 0.94);
  background: var(--accent-soft);
  border-color: var(--accent-line);
  box-shadow: var(--glow);
}

.primary-link:hover,
.primary-btn:hover {
  background: rgba(184, 71, 255, 0.7);
}

.secondary-btn {
  color: var(--text);
  background: var(--control);
  border-color: var(--line);
}

.secondary-btn:hover {
  background: var(--control-hover);
  border-color: rgba(255, 255, 255, 0.14);
}

.danger-btn {
  color: rgba(255, 190, 190, 0.95);
  background: rgba(80, 28, 28, 0.62);
  border-color: rgba(251, 45, 45, 0.45);
}

.danger-btn:hover {
  color: #fff;
  background: rgba(190, 45, 45, 0.72);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  padding: 16px;
}

.sidebar {
  min-height: calc(100vh - 32px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 22px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-soft);
}

.brand img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  padding: 6px;
  border-radius: var(--radius);
  background: var(--control);
  border: 1px solid var(--line);
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 18px;
  font-weight: 900;
}

.brand span {
  max-width: 170px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.uptime-bar {
  width: min(190px, 100%);
  min-height: 42px;
  margin-top: 10px;
  display: grid;
  grid-template-columns: 20px 1fr;
  grid-template-areas:
    "icon label"
    "icon time";
  align-items: center;
  column-gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(199, 104, 247, 0.54);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(160, 56, 225, 0.22), rgba(60, 60, 60, 0.38)),
    rgba(20, 20, 21, 0.74);
  box-shadow:
    0 0 12px rgba(160, 56, 225, 0.34),
    inset 0 0 12px rgba(255, 255, 255, 0.035);
}

.uptime-bar .icon {
  grid-area: icon;
  width: 20px;
  height: 20px;
  color: var(--accent-text);
  filter: drop-shadow(0 0 6px rgba(215, 178, 255, 0.68));
}

.brand .uptime-bar span {
  grid-area: label;
  max-width: none;
  margin: 0;
  color: rgba(255, 255, 255, 0.54);
  font-size: 10px;
  font-weight: 800;
  overflow: visible;
}

.uptime-bar b {
  grid-area: time;
  min-width: 0;
  color: rgba(255, 255, 255, 0.94);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.35;
  text-shadow: 0 0 9px rgba(199, 104, 247, 0.75);
}

nav {
  display: grid;
  align-content: start;
  gap: 10px;
}

.nav-item {
  width: 100%;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  text-align: right;
  padding: 0 10px;
  font-weight: 800;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.nav-item .icon-box {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--control);
  color: rgba(255, 255, 255, 0.7);
  border: 1px solid transparent;
}

.nav-item.active,
.nav-item:hover {
  color: #fff;
  background: rgba(60, 60, 60, 0.35);
}

.nav-item.active .icon-box {
  color: #fff;
  background: var(--accent-soft);
  border-color: var(--accent-line);
  box-shadow: var(--glow);
}

.logout {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: rgba(255, 210, 204, 0.92);
  text-decoration: none;
  padding: 0 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(251, 45, 45, 0.18);
  background: rgba(60, 60, 60, 0.24);
}

.logout:hover {
  background: rgba(80, 28, 28, 0.55);
}

.workspace {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 16px;
}

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.topbar h1 {
  font-size: 30px;
  font-weight: 900;
}

.userbox {
  display: flex;
  align-items: center;
  gap: 12px;
}

#saveState {
  min-width: 70px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.page {
  display: none;
}

.page.active {
  display: grid;
  gap: 16px;
}

.section-head {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.section-head h2,
.section-head h3 {
  color: rgba(255, 255, 255, 0.86);
  font-weight: 900;
}

.section-head.split,
.section-head.compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-head.compact {
  padding: 0 0 10px;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.section-head.compact::before {
  display: none;
}

.top-space {
  margin-top: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 12px;
}

.field,
.list-panel,
.table-wrap,
.map-list {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.field {
  padding: 12px;
  display: grid;
  gap: 8px;
}

.field span,
.list-panel strong {
  color: rgba(255, 255, 255, 0.78);
  font-weight: 800;
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: var(--radius);
  background: rgba(60, 60, 60, 0.42);
  color: var(--text);
  padding: 9px 11px;
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.7;
}

input::placeholder,
textarea::placeholder {
  color: rgba(255, 255, 255, 0.24);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px rgba(160, 56, 225, 0.18);
}

select option {
  color: #fff;
  background: #161616;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  min-height: 18px;
}

.stack {
  display: grid;
  gap: 12px;
}

.list-panel {
  padding: 12px;
  display: grid;
  gap: 10px;
}

.list-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.map-list {
  padding: 10px;
  display: grid;
  gap: 8px;
}

.map-row {
  display: grid;
  grid-template-columns: minmax(150px, 0.9fr) minmax(180px, 1.1fr) auto;
  gap: 8px;
  align-items: center;
}

.map-row.array-row {
  grid-template-columns: minmax(150px, 0.8fr) minmax(200px, 1.2fr) minmax(150px, 0.8fr) auto;
}

.wide .map-row {
  grid-template-columns: minmax(150px, 0.8fr) minmax(220px, 1.2fr) auto;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: right;
  vertical-align: middle;
}

th {
  background: rgba(60, 60, 60, 0.32);
  color: rgba(255, 255, 255, 0.62);
  font-size: 13px;
  font-weight: 900;
}

td input {
  min-width: 92px;
}

.small-input {
  max-width: 90px;
}

.block-field {
  align-content: start;
}

.action-strip {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
}

.restart-btn {
  min-width: 170px;
}

.role-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 22px;
}

.role-chip {
  display: grid;
  grid-template-columns: minmax(90px, auto);
  gap: 4px;
  max-width: 100%;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  background: rgba(60, 60, 60, 0.38);
}

.role-color {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.18);
}

.role-name,
.role-id {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-name {
  color: rgba(255, 255, 255, 0.86);
  font-size: 12px;
  font-weight: 800;
}

.role-id {
  color: rgba(255, 255, 255, 0.42);
  font-family: "Montserrat", Tahoma, Arial, sans-serif;
  font-size: 10px;
}

.role-empty {
  color: rgba(255, 255, 255, 0.35);
  font-size: 12px;
}

.map-row .role-preview {
  grid-column: 1 / -1;
}

.role-select-menu {
  position: fixed;
  z-index: 1000;
  max-height: 330px;
  overflow: auto;
  display: grid;
  gap: 6px;
  padding: 8px;
  background: rgba(17, 17, 17, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.42), var(--shadow);
  backdrop-filter: blur(10px);
}

.role-select-menu[hidden] {
  display: none !important;
}

.role-option {
  width: 100%;
  display: grid;
  gap: 6px;
  min-height: 58px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  background: rgba(60, 60, 60, 0.34);
  color: var(--text);
  text-align: right;
}

.role-option:hover {
  background: rgba(76, 76, 76, 0.72);
  border-color: rgba(255, 255, 255, 0.16);
}

.role-option-main {
  display: grid;
  gap: 2px;
}

.role-option-main strong,
.role-option-main code {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-option-main strong {
  font-size: 13px;
  font-weight: 900;
}

.role-option-main code {
  direction: ltr;
  color: rgba(255, 255, 255, 0.5);
  font-family: "Montserrat", Tahoma, Arial, sans-serif;
  font-size: 11px;
  text-align: right;
}

.role-option-color {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.16);
}

.role-option-empty {
  padding: 14px;
  color: var(--muted);
  text-align: center;
}

.audit-log {
  display: grid;
  gap: 10px;
}

.audit-item,
.empty-log {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
}

.audit-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}

.audit-main strong,
.audit-main span,
.audit-actor b,
.audit-actor span,
.audit-actor code {
  display: block;
}

.audit-main strong {
  color: rgba(255, 255, 255, 0.9);
  font-weight: 900;
}

.audit-main span,
.empty-log {
  color: var(--muted);
  font-size: 12px;
}

.audit-actor {
  min-width: 210px;
  text-align: left;
}

.audit-actor b {
  color: var(--accent-text);
  font-size: 13px;
}

.audit-actor code {
  color: rgba(255, 255, 255, 0.46);
  font-family: "Montserrat", Tahoma, Arial, sans-serif;
  font-size: 11px;
}

.audit-changes {
  display: grid;
  gap: 7px;
  padding-top: 10px;
}

.audit-change {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(120px, 0.8fr) 22px minmax(120px, 0.8fr);
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: var(--radius);
  background: rgba(60, 60, 60, 0.28);
}

.audit-label {
  color: rgba(255, 255, 255, 0.78);
  font-weight: 800;
}

.audit-from,
.audit-to {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.58);
  font-family: "Montserrat", "Tajawal", sans-serif;
  font-size: 12px;
}

.audit-to {
  color: rgba(30, 255, 0, 0.72);
}

.audit-arrow {
  color: var(--accent-text);
  text-align: center;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(217, 217, 217, 0.12);
  border-radius: 6px;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.62);
  border-radius: 6px;
}

@media (max-width: 1050px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .uptime-bar {
    width: 100%;
  }

  nav {
    grid-template-columns: repeat(3, 1fr);
  }

  .nav-item {
    min-width: 0;
  }

  .form-grid,
  .two-col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 10px;
  }

  .topbar,
  .section-head.split,
  .section-head.compact,
  .userbox {
    align-items: stretch;
    flex-direction: column;
  }

  nav {
    grid-template-columns: 1fr 1fr;
  }

  .nav-item {
    justify-content: flex-start;
  }

  .map-row,
  .map-row.array-row,
  .wide .map-row,
  .list-actions,
  .audit-change {
    grid-template-columns: 1fr;
  }

  .audit-main {
    display: grid;
  }

  .audit-actor {
    min-width: 0;
    text-align: right;
  }
}
