@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0d0f18;
  --surface: #141720;
  --surface2: #1c2030;
  --border: #252a3d;
  --accent: #6366f1;
  --accent-hover: #4f52d6;
  --accent-glow: rgba(99, 102, 241, 0.15);
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.1);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --warning: #f59e0b;
  --orange: #f97316;
  --orange-hover: #ea6d0e;
  --text: #e2e8f0;
  --text-muted: #64748b;
  --text-secondary: #94a3b8;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ========== LOGIN ========== */
.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 50%);
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 24px;
}

.login-box {
  background: var(--surface);
  padding: 44px 40px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-align: center;
}

.login-box h1 {
  margin-bottom: 8px;
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.login-box h1::before {
  content: '◆ ';
  color: var(--accent);
  font-size: 16px;
}

.login-subtitle {
  color: var(--text);
  font-size: 13px;
  margin-bottom: 32px;
}

/* ========== HEADER ========== */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 60px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.header h1 {
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header h1::before {
  content: '◆';
  color: var(--accent);
  font-size: 14px;
}

.header-info {
  display: flex;
  align-items: center;
  gap: 20px;
}

.header-info span {
  color: var(--text);
  font-size: 12px;
  background: var(--surface2);
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* ========== CONTAINER ========== */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ========== APP SELECTION ========== */
.app-selection {
  background: var(--surface);
  padding: 28px 32px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.app-selection h2 {
  margin-bottom: 20px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.app-buttons {
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 10px;
}

.app-btn {
  background: var(--surface2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.1px;
}

.app-btn:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--text);
  transform: none;
}

.app-btn.active {
  background: var(--accent-glow);
  color: #a5b4fc;
  border-color: var(--accent);
  font-weight: 600;
}

/* ========== APP CONTENT WRAPPER ========== */
#app-content-wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

#current-app-title {
  grid-column: 1 / -1;
  text-align: left;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

#current-app-title::before {
  content: '▸ ';
  color: var(--accent);
}

.hidden {
  display: none !important;
}

/* ========== SECTIONS ========== */
.section {
  background: var(--surface);
  padding: 28px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section h3 {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

/* ========== FORM ELEMENTS ========== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  padding: 11px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input::placeholder,
textarea::placeholder {
  color: var(--text);
  font-size: 12px;
}

textarea {
  min-height: 200px;
  resize: vertical;
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.7;
}

/* ========== BUTTONS ========== */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  letter-spacing: 0.1px;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
  color: var(--text);
  transform: none;
}

.btn-success {
  background: transparent;
  color: var(--success);
  border: 1px solid var(--success);
}

.btn-success:hover {
  background: var(--success-bg);
  transform: none;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid transparent;
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 6px;
}

.btn-danger:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
}

.btn-edit {
  background: transparent;
  color: var(--warning);
  border: 1px solid transparent;
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 6px;
  margin-right: 4px;
}

.btn-edit:hover {
  background: rgba(245, 158, 11, 0.1);
  border-color: var(--warning);
}

.operations-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.btn-24hrs {
  background: transparent;
  color: var(--orange);
  border: 1px solid var(--orange);
}

.btn-24hrs:hover {
  background: rgba(249, 115, 22, 0.1);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.2);
}

/* ========== TABLE ========== */
.signals-container {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface2);
}

th {
  background: var(--surface);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(99, 102, 241, 0.04);
}

/* ========== MODAL ========== */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  margin: 8% auto;
  padding: 32px;
  border-radius: var(--radius);
  width: 90%;
  max-width: 460px;
  position: relative;
  box-shadow: var(--shadow);
}

.modal-content h3 {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 24px;
  text-transform: none;
  letter-spacing: -0.2px;
  border: none;
  padding: 0;
}

.close {
  position: absolute;
  right: 20px;
  top: 16px;
  font-size: 22px;
  font-weight: 400;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  transition: color 0.2s;
}

.close:hover {
  color: var(--text);
}

.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ========== ALERTS ========== */
.alert {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  min-width: 300px;
  max-width: 480px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  border: 1px solid;
}

.alert-error {
  background: var(--danger-bg);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}

.alert-success {
  background: var(--success-bg);
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.3);
}

/* ========== LOGIN FORM (inside box) ========== */
.login-box .form-group {
  text-align: left;
  margin-bottom: 16px;
}

.login-box .btn-primary {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  margin-top: 8px;
}

.login-box .alert {
  position: static;
  transform: none;
  left: auto;
  top: auto;
  width: 100%;
  margin-bottom: 16px;
  min-width: auto;
}

/* ========== LOADING ========== */
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.loading {
  position: relative;
}

.loading::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  margin: auto;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  top: 0; left: 0; bottom: 0; right: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========== RESPONSIVE ========== */
@media (max-width: 992px) {
  #app-content-wrapper {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 20px 16px;
    gap: 16px;
  }

  .header {
    padding: 0 20px;
  }

  .header h1 {
    font-size: 15px;
  }

  .app-selection,
  .section {
    padding: 20px;
  }

  .login-box {
    padding: 32px 24px;
  }

  .modal-content {
    margin: 15% auto;
    padding: 24px;
  }
}
