* { box-sizing: border-box; }
:root {
  --bg-deep: #07090f;
  --bg-mid: #0d1018;
  --surface: rgba(18, 22, 34, 0.92);
  --surface-elevated: rgba(24, 29, 44, 0.98);
  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.2);
  --text: #f0f3fa;
  --text-muted: #8b95ab;
  --accent: #5b8cff;
  --accent-dim: rgba(91, 140, 255, 0.22);
  --input-bg: #111520;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --radius: 14px;
  --radius-sm: 10px;
  --bottom-safe: max(12px, env(safe-area-inset-bottom, 0px));
}

body {
  margin: 0;
  background: var(--bg-deep);
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -20%, rgba(91, 140, 255, 0.12), transparent 50%),
    radial-gradient(circle at 100% 50%, rgba(0, 255, 136, 0.04), transparent 40%);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: "JetBrains Mono", ui-monospace, monospace; }

.container {
  padding: 16px 16px calc(88px + var(--bottom-safe));
  display: grid;
  gap: 16px;
  max-width: 1100px;
  margin: 0 auto;
}

.card {
  background: var(--surface);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  animation: fadeIn 0.3s ease;
}

.section-title {
  margin: 0 0 16px 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
}

h2:not(.section-title) {
  margin: 0 0 14px 0;
  font-size: 15px;
  font-weight: 600;
}

.label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10px;
  color: var(--text-muted);
}

.meta-updated {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.value { font-size: 22px; margin-top: 8px; font-weight: 600; }
.green { color: #3ee6a8; }
.red { color: #ff6b86; }
.blue { color: var(--accent); }

.navbar {
  margin: 12px 16px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand { font-weight: 700; font-size: 20px; letter-spacing: 0.04em; }

.content-section { display: none; gap: 16px; }
.content-section.is-active { display: grid; }

.metric { min-height: 104px; }

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

.status-dot {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.status-dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  animation: pulse 1.4s infinite;
}

.status-dot.green::before { background: #3ee6a8; box-shadow: 0 0 10px rgba(62, 230, 168, 0.6); }
.status-dot.red::before { background: #ff6b86; box-shadow: 0 0 10px rgba(255, 107, 134, 0.5); }

.grid.four {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.table-wrap {
  margin: 0 -4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-mid);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
}

.data-table thead th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  font-weight: 600;
  background: rgba(0, 0, 0, 0.25);
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(255, 255, 255, 0.04); }

table:not(.data-table) { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { border-bottom: 1px solid var(--border); padding: 8px; text-align: left; }

.btn {
  border: 1px solid var(--border-strong);
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn:active { transform: scale(0.98); }

.btn.small { padding: 8px 12px; font-size: 12px; }
.btn.green {
  border-color: rgba(62, 230, 168, 0.55);
  color: #3ee6a8;
  background: rgba(62, 230, 168, 0.08);
}
.btn.red {
  border-color: rgba(255, 107, 134, 0.55);
  color: #ff8a9a;
  background: rgba(255, 107, 134, 0.08);
}
.btn.orange {
  border-color: rgba(255, 180, 90, 0.55);
  color: #ffc46b;
  background: rgba(255, 180, 90, 0.08);
}

.btn-primary {
  width: 100%;
  margin-top: 20px;
  padding: 14px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(180deg, #6b9cff 0%, var(--accent) 100%);
  box-shadow: 0 4px 16px rgba(91, 140, 255, 0.35);
  transition: filter 0.15s ease, transform 0.1s ease;
}

.btn-primary:active {
  filter: brightness(0.95);
  transform: scale(0.995);
}

.badge { padding: 4px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.badge.gray { background: #444; }
.badge.red { background: #ff4466; }
.badge.blue { background: #4488ff; }

.grid-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.grid-meta .mono { color: var(--text); }

.grid-levels {
  margin-top: 14px;
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
}

.grid-level {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  background: var(--bg-mid);
}

.grid-level.buy-zone { background: rgba(255, 107, 134, 0.1); }
.grid-level.sell-zone { background: rgba(62, 230, 168, 0.1); }
.grid-level.current-price { border-color: rgba(255, 255, 255, 0.35); }

.table-controls { display: flex; gap: 10px; margin-top: 10px; align-items: center; }

.controls-row {
  display: flex;
  gap: 10px;
  margin-bottom: 0;
  flex-wrap: wrap;
}

.actions-row {
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.config-panel {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px 16px;
}

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

.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

input,
select {
  width: 100%;
  min-height: 44px;
  background: var(--input-bg);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder { color: var(--text-muted); opacity: 0.7; }

input:focus,
select:focus {
  border-color: rgba(91, 140, 255, 0.65);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b95ab' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%238b95ab' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.bottom-menu {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: var(--bottom-safe);
  width: min(96vw, 860px);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 8px;
  z-index: 20;
  background: rgba(10, 12, 18, 0.92);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
}

.menu-item {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  border-radius: 12px;
  padding: 10px 6px;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.menu-item.is-active {
  background: var(--accent-dim);
  color: var(--text);
  border-color: rgba(91, 140, 255, 0.35);
}

.menu-item:active:not(.is-active) {
  background: rgba(255, 255, 255, 0.05);
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-card {
  width: min(90vw, 420px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

.login-card h1 { margin: 0 0 6px 0; }
.login-card form { display: grid; gap: 10px; margin-top: 16px; }
.error { color: #ff4466; margin-top: 10px; }
.shake { animation: shake 0.25s linear 2; }

@keyframes pulse { 0% { opacity: .35; } 50% { opacity: 1; } 100% { opacity: .35; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes shake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-5px); }
  100% { transform: translateX(0); }
}

@media (max-width: 768px) {
  .grid.four { grid-template-columns: 1fr 1fr; }
  .grid-meta { grid-template-columns: 1fr; }
  .config-grid { grid-template-columns: 1fr; }
  .navbar { flex-direction: column; align-items: stretch; text-align: center; }
  .controls-row { flex-wrap: wrap; }
  .bottom-menu { width: calc(100vw - 20px); }
}

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