:root {
  color-scheme: dark;
  --bg: #101214;
  --panel: #171a1d;
  --line: #2a2f34;
  --text: #f4f6f7;
  --muted: #9aa4ad;
  --blue: #0a84ff;
  --green: #00c853;
  --red: #ff3b30;
  --orange: #ff9800;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 "Segoe UI", Arial, sans-serif;
}

button, input, select {
  font: inherit;
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: #0c0e10;
}

.brand-block { min-width: 180px; }

.vps-stats {
  flex: 1;
  min-width: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #d7dde2;
  font-size: 12px;
  white-space: nowrap;
}

.vps-stats span {
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #15191d;
}

.top-actions,
.cap-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cap-form label,
.cap-form span {
  color: var(--muted);
  white-space: nowrap;
}

.cap-form input {
  width: 78px;
  height: 32px;
  padding: 5px 8px;
}

h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
.subtle { color: var(--muted); }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 14px;
  padding: 14px;
}

.table-pane, .form-pane, .login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.table-pane { min-width: 0; }
.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.stream-table-wrap {
  overflow: auto;
  max-height: calc(100vh - 112px);
}

.stream-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
  table-layout: fixed;
}

.col-dot { width: 28px; }
.col-name { width: 150px; }
.col-key { width: 92px; }
.col-type { width: 54px; }
.col-source { width: 108px; }
.col-codec { width: 90px; }
.col-action { width: 36px; }
.col-status { width: 420px; }
.col-lived { width: 76px; }
.col-speed { width: 58px; }

.stream-table th,
.stream-table td {
  height: 38px;
  padding: 0 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  text-align: left;
}

.stream-table th {
  position: sticky;
  top: 0;
  background: #202429;
  z-index: 1;
  color: #d7dde2;
  font-size: 12px;
  font-weight: 600;
}

.stream-table tr.claim-row .status-cell {
  background: #ff0000;
  color: #fff;
  font-weight: 700;
}

.stream-table tr.error-row .status-cell {
  color: #fff;
  background: #8b1d1d;
  font-weight: 700;
}

.stream-table tr.drive-row .status-cell {
  color: #fff;
  background: #12375d;
}

.stream-table tr.review-row .status-cell {
  color: #fff;
  background: #17314f;
}

.status-cell {
  width: 420px;
}

.status-text {
  display: block;
  position: relative;
  z-index: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drive-progress {
  display: block;
  position: relative;
  width: 100%;
  height: 6px;
  margin-top: 4px;
  border-radius: 999px;
  background: #0c1d31;
  overflow: hidden;
}

.drive-progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #0a84ff, #48c7ff);
  transition: width 180ms ease;
}

.dot-cell { width: 32px; text-align: center; }
.dot { color: #fff; font-size: 16px; }
.name-cell { font-weight: 600; }
.source-cell {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.empty {
  color: var(--muted);
  text-align: center;
}

form { margin: 0; }
.icon-btn, .icon-link {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #23282d;
  color: #fff;
  text-decoration: none;
  cursor: pointer;
}
.icon-btn.run { color: var(--green); }
.icon-btn.stop { color: var(--orange); }
.icon-btn.danger { color: var(--red); }
.icon-btn.forever { color: #4dd4ff; }

.ghost, .ghost-link, .file-btn {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #202429;
  color: var(--text);
  text-decoration: none;
  padding: 8px 12px;
  cursor: pointer;
}
.file-btn input { display: none; }
.cookie-form {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cookie-state { color: var(--muted); }
.table-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.62);
}

.modal-panel {
  width: min(520px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #171a1d;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
}

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

.modal-body {
  display: grid;
  gap: 10px;
  padding: 14px;
  color: #d7dde2;
}

.modal-body p { margin: 0; }

.modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.form-pane {
  padding: 14px;
  position: sticky;
  top: 78px;
  height: calc(100vh - 92px);
  overflow: auto;
}

.stream-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

label {
  display: grid;
  gap: 5px;
  color: #cfd6dc;
}

input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #0f1114;
  color: var(--text);
}

.paste-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.field-paste {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #202429;
  color: var(--text);
  padding: 0 10px;
  opacity: 0.38;
  cursor: pointer;
  transition: opacity 140ms ease, border-color 140ms ease;
}

.paste-wrap:hover .field-paste,
.paste-wrap:focus-within .field-paste,
.field-paste:hover {
  opacity: 1;
  border-color: #4a8fd8;
}

.schedule-input {
  cursor: pointer;
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
}
.checkline input {
  width: 18px;
  height: 18px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}
.form-actions button,
.login-form button {
  border: 0;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
}

.login-body {
  display: grid;
  place-items: center;
}
.login-panel {
  width: min(380px, calc(100vw - 28px));
  padding: 22px;
}
.login-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}
.form-error {
  color: #fff;
  background: #8b1d1d;
  border-radius: 6px;
  padding: 8px 10px;
}

@media (max-width: 960px) {
  .topbar { flex-wrap: wrap; padding: 10px 14px; }
  .vps-stats { order: 3; width: 100%; justify-content: flex-start; overflow-x: auto; }
  .top-actions { flex-wrap: wrap; }
  .layout { grid-template-columns: 1fr; }
  .form-pane {
    position: static;
    height: auto;
  }
}
