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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0a0a0f;
  color: #e0e0e0;
  min-height: 100vh;
}

/* Login */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0a0a0f 0%, #1a1a2e 100%);
}

.login-box {
  background: #16161a;
  border: 1px solid #2a2a3e;
  border-radius: 16px;
  padding: 48px;
  width: 380px;
  text-align: center;
}

.login-box h1 { font-size: 28px; color: #00d4aa; margin-bottom: 8px; }
.login-box p { color: #888; margin-bottom: 32px; }

.login-box input {
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: #0a0a0f;
  border: 1px solid #2a2a3e;
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 15px;
  outline: none;
}

.login-box input:focus { border-color: #00d4aa; }

.login-box button {
  width: 100%;
  padding: 14px;
  background: #00d4aa;
  color: #0a0a0f;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}

.login-box button:hover { background: #00b894; }
.error { color: #ff6b6b; margin-top: 12px; font-size: 14px; }

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  background: #16161a;
  border-bottom: 1px solid #2a2a3e;
}

.header-left h1 { font-size: 20px; color: #00d4aa; }

.header-right { display: flex; align-items: center; gap: 24px; }

.stats { display: flex; gap: 12px; font-size: 13px; color: #888; }

.stats span {
  background: #0a0a0f;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid #2a2a3e;
}

.btn-logout {
  background: transparent;
  border: 1px solid #ff6b6b;
  color: #ff6b6b;
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.btn-logout:hover { background: #ff6b6b; color: #0a0a0f; }

/* Toolbar */
.toolbar {
  padding: 20px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-right {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar-right select, .toolbar-right input {
  padding: 8px 12px;
  background: #16161a;
  border: 1px solid #2a2a3e;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 13px;
  outline: none;
}

.toolbar-right input { width: 160px; }
.toolbar-right select:focus, .toolbar-right input:focus { border-color: #00d4aa; }

.btn-create {
  background: #00d4aa;
  color: #0a0a0f;
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-create:hover { background: #00b894; }

.btn-batch, .btn-refresh {
  background: transparent;
  border: 1px solid #2a2a3e;
  color: #888;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.btn-batch:hover { border-color: #00d4aa; color: #00d4aa; }
.btn-batch-stop:hover { border-color: #ffa502; color: #ffa502; }
.btn-refresh:hover { border-color: #00d4aa; color: #00d4aa; }

.select-all-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: #888;
  cursor: pointer;
}

/* Grid */
.instances-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  padding: 0 32px 32px;
}

.instance-card {
  background: #16161a;
  border: 1px solid #2a2a3e;
  border-radius: 12px;
  padding: 20px;
  position: relative;
  transition: border-color 0.2s;
}

.instance-card:hover { border-color: #3a3a4e; }

.card-select {
  position: absolute;
  top: 12px;
  right: 12px;
}

.card-select input { cursor: pointer; width: 16px; height: 16px; accent-color: #00d4aa; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
  padding-right: 28px;
}

.card-title { display: flex; flex-direction: column; gap: 2px; }
.card-name { font-size: 16px; font-weight: 600; }
.card-device { font-size: 12px; color: #666; }

.card-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-running .status-dot { background: #00d4aa; }
.status-running { color: #00d4aa; }
.status-stopped .status-dot { background: #ff6b6b; }
.status-stopped { color: #ff6b6b; }

.card-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 12px;
}

.card-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid #1a1a2e;
}

.info-label { color: #666; font-weight: 500; }
.card-info-row span:last-child { color: #aaa; font-family: 'SF Mono', monospace; font-size: 11px; }
.mono { font-family: 'SF Mono', Consolas, monospace; }

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 6px;
}

.card-actions button {
  padding: 7px 0;
  border-radius: 6px;
  border: 1px solid #2a2a3e;
  background: transparent;
  color: #e0e0e0;
  cursor: pointer;
  font-size: 12px;
}

.card-actions button:hover { border-color: #00d4aa; color: #00d4aa; }
.card-actions .btn-start { border-color: #00d4aa; color: #00d4aa; }
.card-actions .btn-stop { border-color: #ffa502; color: #ffa502; }
.card-actions .btn-delete { border-color: #ff6b6b; color: #ff6b6b; }
.card-actions .btn-delete:hover { background: #ff6b6b; color: #0a0a0f; }

/* Modal */
.modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: #16161a;
  border: 1px solid #2a2a3e;
  border-radius: 16px;
  width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-wide { width: 680px; }
.modal-viewer { width: 560px; }
.modal-screen { width: 420px; height: 90vh; max-height: 95vh; display: flex; flex-direction: column; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #2a2a3e;
}

.modal-header h2 { font-size: 18px; }

.modal-close {
  background: none;
  border: none;
  color: #888;
  font-size: 24px;
  cursor: pointer;
}

.modal-body { padding: 0 24px 24px; }

.modal-body label {
  display: block;
  font-size: 13px;
  color: #888;
  margin-bottom: 6px;
  margin-top: 12px;
}

.modal-body input, .modal-body select {
  width: 100%;
  padding: 10px 12px;
  background: #0a0a0f;
  border: 1px solid #2a2a3e;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 14px;
  outline: none;
}

.modal-body input:focus, .modal-body select:focus { border-color: #00d4aa; }
.modal-body input[readonly] { color: #999; cursor: default; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid #2a2a3e;
}

.btn-cancel {
  padding: 10px 20px;
  background: transparent;
  border: 1px solid #2a2a3e;
  color: #888;
  border-radius: 8px;
  cursor: pointer;
}

.btn-save {
  padding: 10px 24px;
  background: #00d4aa;
  color: #0a0a0f;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

.btn-save:hover { background: #00b894; }

/* Tabs */
.modal-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid #2a2a3e;
  margin: 0 -24px;
  padding: 0 24px;
  padding-top: 16px;
}

.tab {
  padding: 10px 20px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: #888;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab:hover { color: #e0e0e0; }
.tab.active { color: #00d4aa; border-bottom-color: #00d4aa; }

.tab-content { display: none; padding-top: 16px; }
.tab-content.active { display: block; }

/* Proxy */
.proxy-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.span-full { grid-column: 1 / -1; }

.proxy-test-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
  background: #0d0d12;
  border-radius: 8px;
  border: 1px solid #2a2a3e;
}

.btn-test-proxy {
  padding: 8px 16px;
  background: #2a2a3e;
  border: 1px solid #3a3a4e;
  color: #e0e0e0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}

.btn-test-proxy:hover { border-color: #00d4aa; color: #00d4aa; }

#proxyTestResult { font-size: 13px; }
.test-ok { color: #00d4aa !important; }
.test-fail { color: #ff6b6b !important; }
.test-loading { color: #ffa502 !important; }

/* Fingerprint */
.fp-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.btn-regenerate {
  padding: 8px 16px;
  background: #2a2a3e;
  border: 1px solid #3a3a4e;
  color: #e0e0e0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.btn-regenerate:hover { border-color: #00d4aa; color: #00d4aa; }
.fp-hint { font-size: 12px; color: #666; }

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

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

.fp-section h4 {
  font-size: 13px;
  color: #00d4aa;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #2a2a3e;
}

.fp-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 6px;
}

.fp-row label {
  font-size: 11px;
  color: #666;
  margin-bottom: 2px;
  margin-top: 0;
}

.fp-row input {
  padding: 6px 8px;
  font-size: 12px;
  font-family: 'SF Mono', Consolas, monospace;
  background: #0d0d12;
  border: 1px solid #1a1a2e;
}

.fp-raw {
  margin-top: 16px;
}

.fp-raw summary {
  font-size: 12px;
  color: #666;
  cursor: pointer;
  padding: 8px 0;
}

.fp-raw code {
  display: block;
  background: #0a0a0f;
  padding: 12px;
  border-radius: 6px;
  font-size: 11px;
  color: #00d4aa;
  border: 1px solid #2a2a3e;
  word-break: break-all;
  margin-top: 8px;
}

/* Viewer */
.viewer-body { padding-top: 0; flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.viewer-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.viewer-info-grid > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px;
  background: #0d0d12;
  border-radius: 6px;
  border: 1px solid #1a1a2e;
}

.viewer-info-grid strong { font-size: 11px; color: #666; text-transform: uppercase; }
.viewer-info-grid span, .viewer-info-grid code {
  font-size: 13px;
  color: #e0e0e0;
  font-family: 'SF Mono', Consolas, monospace;
}

.viewer-cmd {
  margin-top: 16px;
  padding: 12px;
  background: #0d0d12;
  border-radius: 8px;
  border: 1px solid #1a1a2e;
}

.viewer-cmd p { font-size: 12px; color: #888; margin-bottom: 8px; }

.viewer-cmd code {
  display: block;
  background: #0a0a0f;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: #00d4aa;
  border: 1px solid #2a2a3e;
}

/* Screen Viewer */
.viewer-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.viewer-fps {
  font-size: 11px;
  color: #666;
  font-family: 'SF Mono', monospace;
}

.btn-viewer-info {
  padding: 4px 10px;
  background: transparent;
  border: 1px solid #2a2a3e;
  color: #888;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.btn-viewer-info:hover { border-color: #00d4aa; color: #00d4aa; }

.screen-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  height: 100%;
}

.screen-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid #2a2a3e;
  flex: 1;
}

.screen-wrapper img {
  width: 100%;
  display: block;
  cursor: pointer;
  min-height: 300px;
  user-select: none;
  -webkit-user-select: none;
}

.screen-loading {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.8);
  color: #888;
  font-size: 14px;
}

.screen-controls {
  display: flex;
  gap: 6px;
  padding: 10px 0 0;
  width: 100%;
  justify-content: center;
  align-items: center;
}

.screen-controls button {
  padding: 8px 14px;
  background: #16161a;
  border: 1px solid #2a2a3e;
  color: #e0e0e0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

.screen-controls button:hover {
  border-color: #00d4aa;
  color: #00d4aa;
}

.screen-refresh {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.screen-refresh label {
  font-size: 12px;
  color: #888;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  margin-top: 0;
}

.screen-refresh input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: #00d4aa;
}

.viewer-info-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #2a2a3e;
}

/* Multi-Screen Viewer */
.multi-viewer {
  padding: 0 32px 32px;
}

.multi-viewer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid #2a2a3e;
  margin-bottom: 16px;
}

.multi-viewer-header h2 { font-size: 18px; color: #00d4aa; }

.multi-viewer-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.multi-viewer-controls select {
  padding: 6px 10px;
  background: #16161a;
  border: 1px solid #2a2a3e;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 13px;
  outline: none;
}

.multi-viewer-controls label {
  font-size: 13px;
  color: #888;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.multi-viewer-controls input[type="checkbox"] {
  accent-color: #00d4aa;
}

.btn-multi-close {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid #ff6b6b;
  color: #ff6b6b;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.btn-multi-close:hover { background: #ff6b6b; color: #0a0a0f; }

.multi-screen-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.multi-screen-card {
  background: #16161a;
  border: 1px solid #2a2a3e;
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.multi-screen-card:hover { border-color: #00d4aa; }

.multi-screen-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid #1a1a2e;
}

.multi-screen-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.multi-screen-model {
  font-size: 11px;
  color: #666;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.multi-screen-close {
  background: none;
  border: none;
  color: #666;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.multi-screen-close:hover { color: #ff6b6b; }

.multi-screen-wrapper {
  position: relative;
  background: #000;
  min-height: 180px;
}

.multi-screen-wrapper img {
  width: 100%;
  display: block;
  cursor: pointer;
}

.multi-screen-loading {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.8);
  color: #666;
  font-size: 12px;
}

.multi-screen-footer {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  border-top: 1px solid #1a1a2e;
}

.multi-screen-footer button {
  flex: 1;
  padding: 5px 0;
  background: #0d0d12;
  border: 1px solid #1a1a2e;
  color: #888;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.multi-screen-footer button:hover { border-color: #00d4aa; color: #00d4aa; }

.btn-expand { color: #00d4aa !important; border-color: #00d4aa !important; }

.btn-multi { border-color: #00d4aa !important; color: #00d4aa !important; }

.card-actions-5 { grid-template-columns: 1fr 1fr 1fr 1fr 1fr; }

.card-actions .btn-screen { border-color: #00d4aa; color: #00d4aa; }

/* Empty state */
.empty-state { text-align: center; padding: 80px 32px; color: #555; }
.empty-state h3 { font-size: 20px; margin-bottom: 8px; color: #888; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #0a0a0f; }
::-webkit-scrollbar-thumb { background: #2a2a3e; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a4e; }
