:root {
  --bg: #130f0b;
  --bg2: #21160f;
  --panel: rgba(34, 25, 17, .92);
  --panel-solid: #221911;
  --panel2: #2f2318;
  --text: #fff6e8;
  --muted: #c6aa86;
  --border: rgba(214, 157, 82, .28);
  --border-strong: rgba(243, 190, 109, .55);
  --primary: #f0a43a;
  --primary2: #b96a22;
  --accent: #1fd6a6;
  --danger: #e14f42;
  --warning: #f5bd4e;
  --success: #2fd280;
  --shadow: rgba(0, 0, 0, .42);
  --table: rgba(22, 15, 10, .94);
}

* { box-sizing: border-box; }

html { direction: rtl; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Tahoma, "Segoe UI", Arial, sans-serif;
  background:
    linear-gradient(135deg, rgba(240,164,58,.08) 0 25%, transparent 25% 50%, rgba(31,214,166,.06) 50% 75%, transparent 75%) 0 0 / 28px 28px,
    radial-gradient(circle at 85% 10%, rgba(240,164,58,.22), transparent 34%),
    radial-gradient(circle at 10% 80%, rgba(31,214,166,.14), transparent 32%),
    linear-gradient(145deg, var(--bg), var(--bg2) 52%, #090705);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(0deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 70px 70px;
  mask-image: radial-gradient(circle at center, black, transparent 78%);
}

.hidden { display: none !important; }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: min(460px, 100%);
  background: linear-gradient(180deg, rgba(47,35,24,.96), rgba(24,18,13,.96));
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  box-shadow: 0 28px 80px var(--shadow), inset 0 1px 0 rgba(255,255,255,.08);
  padding: 28px;
  position: relative;
  overflow: hidden;
}

.login-card::before,
.panel::before,
.topbar::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  width: 5px;
  height: 100%;
  background: linear-gradient(180deg, var(--primary), var(--accent));
}

.brand-row,
.brand-mini {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-row h1 {
  margin: 0;
  font-size: 27px;
  letter-spacing: -.4px;
}

.brand-row p {
  margin: 6px 0 0;
  color: var(--muted);
}

.brand-icon {
  width: 58px;
  height: 58px;
  border-radius: 16px 16px 4px 16px;
  display: grid;
  place-items: center;
  background: conic-gradient(from 230deg, #f6c56c, #c86d24, #1fd6a6, #f6c56c);
  color: #1d1007;
  font-weight: 900;
  box-shadow: 0 12px 30px rgba(240,164,58,.25);
}

.brand-icon.small {
  width: 42px;
  height: 42px;
  border-radius: 12px 12px 4px 12px;
  font-size: 13px;
}

.field-label {
  display: block;
  margin: 18px 0 7px;
  color: var(--muted);
  font-weight: 700;
}

.input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(14, 10, 7, .9);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 13px;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(240,164,58,.14), inset 0 1px 0 rgba(255,255,255,.05);
}

.hint {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  line-height: 1.6;
}


.locked-api-box {
  margin: 18px 0 4px;
  border: 1px solid rgba(31,214,166,.35);
  background: linear-gradient(135deg, rgba(31,214,166,.10), rgba(240,164,58,.08));
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  line-height: 1.7;
}

.locked-api-title {
  display: block;
  color: var(--accent);
  font-weight: 900;
  margin-bottom: 3px;
}

.locked-api-text {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.btn {
  border: 1px solid var(--border);
  border-radius: 10px 10px 3px 10px;
  padding: 10px 15px;
  cursor: pointer;
  font-weight: 800;
  color: var(--text);
  background: linear-gradient(180deg, #382a1c, #281d14);
  transition: transform .08s ease, opacity .15s ease, border .15s ease, box-shadow .15s ease;
  font-family: inherit;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  box-shadow: 0 8px 22px rgba(0,0,0,.22);
}

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

.btn.full {
  width: 100%;
  margin-top: 14px;
}

.btn-primary {
  background: linear-gradient(135deg, #f4b95d, #b8641d);
  color: #1c1008;
  border-color: rgba(255,213,140,.55);
}

.btn-secondary {
  background: linear-gradient(180deg, #30251a, #1f1711);
}

.btn-danger,
.danger {
  background: rgba(225,79,66,.15);
  color: #ffd2cc;
  border-color: rgba(225,79,66,.42);
}

.status-text {
  margin-top: 14px;
  min-height: 20px;
  color: var(--muted);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0,1fr) 270px;
}

.sidebar {
  grid-column: 2;
  grid-row: 1;
  background: linear-gradient(180deg, rgba(32,23,16,.98), rgba(14,10,7,.98));
  border-right: 1px solid var(--border);
  padding: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: -18px 0 48px rgba(0,0,0,.22);
}

.main {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  padding: 24px;
}

.brand-mini { margin-bottom: 28px; }
.brand-mini span { color: var(--muted); display: block; margin-top: 4px; }

.nav-btn {
  width: 100%;
  text-align: right;
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
  padding: 12px;
  border-radius: 12px 12px 3px 12px;
  cursor: pointer;
  margin-bottom: 8px;
  font-family: inherit;
}

.nav-btn:hover,
.nav-btn.active {
  background: rgba(240,164,58,.11);
  border-color: var(--border);
}

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px 22px;
  box-shadow: 0 18px 46px var(--shadow);
  overflow: hidden;
}

.topbar h2 { margin: 0; font-size: 26px; }
.topbar p { margin: 6px 0 0; color: var(--muted); }
.top-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.badge {
  background: rgba(31,214,166,.12);
  border: 1px solid rgba(31,214,166,.35);
  color: #a9ffe6;
  border-radius: 999px;
  padding: 8px 13px;
  white-space: nowrap;
}

.panel {
  position: relative;
  margin-top: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 17px;
  box-shadow: 0 18px 46px var(--shadow);
  overflow: hidden;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.search { max-width: 390px; }

.info-card {
  margin-bottom: 14px;
  border: 1px solid var(--border);
  background: rgba(15, 11, 8, .88);
  border-radius: 14px;
  padding: 14px;
  color: var(--muted);
  line-height: 1.8;
}

.info-card strong { color: var(--text); }

.table-wrap {
  overflow: auto;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--table);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1060px;
  background: transparent;
}

.data-table th,
.data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(214,157,82,.18);
  text-align: right;
  vertical-align: top;
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table th {
  color: #f5d5a8;
  font-size: 12px;
  background: #2a1f15;
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table tr:hover td { background: rgba(240,164,58,.08); }
.data-table tr.selected td { background: rgba(31,214,166,.12); }
.bool-yes { color: var(--success); font-weight: 900; }
.bool-no { color: var(--danger); font-weight: 900; }

.context-menu {
  position: fixed;
  z-index: 30;
  min-width: 250px;
  background: #1c140e;
  border: 1px solid var(--border-strong);
  border-radius: 14px 14px 4px 14px;
  box-shadow: 0 20px 54px var(--shadow);
  overflow: hidden;
}

.context-menu button {
  display: block;
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--text);
  text-align: right;
  padding: 12px 14px;
  cursor: pointer;
  font-family: inherit;
}

.context-menu button:hover { background: rgba(240,164,58,.12); }
.context-menu button.danger { color: #ffd2cc; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0,0,0,.66);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal {
  width: min(780px, 100%);
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #1b140e;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  box-shadow: 0 34px 90px rgba(0,0,0,.58);
}

.modal.wide { width: min(1160px, 100%); }

.modal-head,
.modal-footer {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-footer {
  border-bottom: 0;
  border-top: 1px solid var(--border);
  justify-content: flex-start;
}

.modal-head h3 { margin: 0; }

.icon-btn {
  width: 35px;
  height: 35px;
  border-radius: 10px 10px 3px 10px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.modal-body {
  padding: 16px;
  overflow: auto;
}

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

.form-grid label {
  color: var(--muted);
  font-weight: 700;
  line-height: 1.8;
}

.form-grid .wide-field { grid-column: 1 / -1; }

.notice-box {
  grid-column: 1 / -1;
  border: 1px solid rgba(241, 177, 90, .32);
  background: linear-gradient(135deg, rgba(241, 177, 90, .12), rgba(36, 23, 12, .72));
  color: #ffe9c7;
  border-radius: 14px;
  padding: 11px 12px;
  line-height: 1.7;
  font-weight: 700;
}

.notice-box strong {
  color: var(--accent);
}

.toast-host {
  position: fixed;
  left: 18px;
  top: 18px;
  z-index: 60;
  display: grid;
  gap: 10px;
}

.toast {
  background: #1c140e;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 14px 14px 4px 14px;
  padding: 12px 14px;
  box-shadow: 0 16px 44px var(--shadow);
  max-width: 390px;
  line-height: 1.6;
}

.toast.error { border-color: rgba(225,79,66,.58); }
.toast.success { border-color: rgba(47,210,128,.58); }

.pre-log {
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
  background: #0d0a07;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  color: #ffe9c7;
  max-height: 380px;
  overflow: auto;
  font-family: Consolas, "Courier New", monospace;
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    grid-column: 1;
    grid-row: 1;
    position: relative;
    height: auto;
    display: flex;
    gap: 8px;
    overflow: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .main { grid-column: 1; grid-row: 2; padding: 16px; }
  .brand-mini { margin: 0 0 0 8px; min-width: 210px; }
  .nav-btn { width: auto; white-space: nowrap; }
  .topbar { flex-direction: column; align-items: stretch; }
  .top-actions { justify-content: space-between; }
  .search { max-width: none; }
  .form-grid { grid-template-columns: 1fr; }
  .login-card { padding: 22px; }
}
