/* Intangles-inspired theme: dark, blue/teal accents */
:root {
  --bg-dark: #0d1117;
  --bg-card: #161b22;
  --bg-input: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-teal: #39c5cf;
  --success: #3fb950;
  --warning: #d29922;
  --error: #f85149;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-dark);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

.app { max-width: 720px; margin: 0 auto; padding: 2rem; }
.view { display: none; }
.view.active { display: block; }

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
}
.header .accent { color: var(--accent-teal); }
.logout-btn {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}
.logout-btn:hover { background: var(--border); }

/* Login */
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  margin-top: 3rem;
}
.login-card h2 {
  margin: 0 0 1.5rem;
  font-size: 1.25rem;
  color: var(--text);
}
.form-group {
  margin-bottom: 1.25rem;
}
.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.form-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
}
.form-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}
.btn-primary {
  width: 100%;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, var(--accent) 0%, #1f6feb 100%);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.5rem;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.login-error {
  margin-top: 1rem;
  padding: 0.75rem;
  background: rgba(248, 81, 73, 0.15);
  border: 1px solid var(--error);
  border-radius: 6px;
  color: var(--error);
  font-size: 0.9rem;
}

/* Main app */
.imei-section, .run-section { margin-bottom: 2rem; }
.imei-section label, .run-section label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.imei-section textarea {
  width: 100%;
  min-height: 140px;
  padding: 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: monospace;
  font-size: 0.9rem;
  resize: vertical;
}
.imei-section textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.imei-section .hint { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.25rem; }

.state-select {
  width: 100%;
  max-width: 320px;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
}
.state-select:focus {
  outline: none;
  border-color: var(--accent);
}

.acc-id-input {
  max-width: 320px;
  margin-top: 1rem;
}

.start-btn {
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, var(--accent-teal) 0%, #238636 100%);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 1rem;
}
.start-btn:hover { opacity: 0.9; }
.start-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.run-error, .run-success {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
}
.run-error { background: rgba(248, 81, 73, 0.15); border: 1px solid var(--error); color: var(--error); }
.run-success { background: rgba(63, 185, 80, 0.15); border: 1px solid var(--success); color: var(--success); }

/* Status view */
.status-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-top: 1.5rem;
}
.status-card h3 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  color: var(--text);
}
.status-meta {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.status-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
}
.status-badge.running { background: rgba(88, 166, 255, 0.2); color: var(--accent); }
.status-badge.completed { background: rgba(63, 185, 80, 0.2); color: var(--success); }
.status-badge.failed { background: rgba(248, 81, 73, 0.2); color: var(--error); }

.imei-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 320px;
  overflow-y: auto;
}
.imei-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-family: monospace;
  font-size: 0.9rem;
}
.imei-list li:last-child { border-bottom: none; }
.imei-list .completed-at { color: var(--text-muted); font-size: 0.8rem; }
.imei-list .pending { color: var(--text-muted); }

.back-link {
  display: inline-block;
  margin-top: 1rem;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}
.back-link:hover { text-decoration: underline; }

.poll-hint { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.5rem; }

/* Nav tabs */
.nav-tabs {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.nav-tab {
  padding: 0.5rem 1rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.9rem;
}
.nav-tab:hover { color: var(--text); background: var(--bg-input); }
.nav-tab.active { color: var(--accent); background: var(--bg-input); }

/* Runs tab */
.runs-info {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
}
.runs-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.runs-toolbar strong { color: var(--text); }
.btn-refresh {
  padding: 0.4rem 0.9rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}
.btn-refresh:hover {
  background: var(--border);
}

.runs-summary {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.summary-row strong { color: var(--text); }

.runs-table-wrap {
  overflow-x: auto;
  margin-bottom: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
}
.runs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.runs-table th,
.runs-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.runs-table th {
  color: var(--text-muted);
  font-weight: 600;
}
.runs-table tbody tr {
  cursor: pointer;
}
.runs-table tbody tr:hover {
  background: var(--bg-input);
}
.runs-table tbody tr:last-child td { border-bottom: none; }
.runs-hint { color: var(--text-muted); font-size: 0.85rem; }

/* Run detail */
.run-detail-wrap {
  margin-top: 1rem;
}
.run-detail-wrap .header {
  margin-bottom: 1rem;
}
.run-detail-wrap .header h2 { font-size: 1.25rem; margin: 0; }
.run-detail-wrap .status-card { margin-top: 0; }
