:root {
  --bg: #0d1117;
  --bg-elev: #010409;
  --surface: #161b22;
  --surface-2: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #2f81f7;
  --success: #238636;
  --success-hover: #2ea043;
  --danger: #f85149;
  --warning: #d29922;
  --purple: #a371f7;
  --radius: 8px;
  --shadow: 0 8px 24px rgba(1, 4, 9, 0.6);
}

[data-theme='light'] {
  --bg: #ffffff;
  --bg-elev: #f6f8fa;
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --border: #d0d7de;
  --text: #1f2328;
  --text-muted: #656d76;
  --accent: #0969da;
  --success: #1f883d;
  --success-hover: #1a7f37;
  --danger: #cf222e;
  --warning: #9a6700;
  --purple: #8250df;
  --shadow: 0 8px 24px rgba(140, 149, 159, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--text-muted);
}

a {
  color: var(--accent);
  text-decoration: none;
}

h1,
h2,
h3 {
  margin: 0 0 10px;
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 16px;
}

.brand-center {
  flex-direction: column;
  text-align: center;
  gap: 4px;
  margin-bottom: 18px;
}

.brand h1 {
  margin: 0;
  font-size: 24px;
}

/* Original GitClone mark (pure CSS - no third-party branding) */
.gc-logo {
  display: inline-block;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  position: relative;
  flex-shrink: 0;
  vertical-align: middle;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18), 0 1px 3px rgba(1, 4, 9, 0.5);
  background-color: #6e40c9;
  background-image:
    radial-gradient(circle at 50% 27%, #ffffff 2.7px, rgba(255, 255, 255, 0) 3.1px),
    radial-gradient(circle at 50% 50%, #ffffff 2.7px, rgba(255, 255, 255, 0) 3.1px),
    radial-gradient(circle at 50% 73%, #ffffff 2.7px, rgba(255, 255, 255, 0) 3.1px),
    linear-gradient(#ffffff, #ffffff),
    linear-gradient(145deg, #2f81f7 0%, #7c3aed 55%, #d946ef 100%);
  background-repeat: no-repeat;
  background-size: 100% 100%, 100% 100%, 100% 100%, 3px 15px, 100% 100%;
  background-position: 0 0, 0 0, 0 0, 50% 50%, 0 0;
}

.gc-logo.sm {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background-size: 100% 100%, 100% 100%, 100% 100%, 2.5px 11px, 100% 100%;
  background-image:
    radial-gradient(circle at 50% 27%, #ffffff 2px, rgba(255, 255, 255, 0) 2.4px),
    radial-gradient(circle at 50% 50%, #ffffff 2px, rgba(255, 255, 255, 0) 2.4px),
    radial-gradient(circle at 50% 73%, #ffffff 2px, rgba(255, 255, 255, 0) 2.4px),
    linear-gradient(#ffffff, #ffffff),
    linear-gradient(145deg, #2f81f7 0%, #7c3aed 55%, #d946ef 100%);
}

.brand-logo {
  display: block;
  object-fit: contain;
  border-radius: 0;
  flex-shrink: 0;
}

.brand-logo.sm {
  width: 24px;
  height: 24px;
}

.brand-logo.lg {
  width: 68px;
  height: 68px;
  margin: 0 auto 10px;
}

/* Auth */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 0%, rgba(47, 129, 247, 0.16), transparent 60%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.auth-form label,
.modal-body label,
.ws-form label {
  display: block;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-muted);
}

input,
select,
textarea {
  width: 100%;
  margin-top: 6px;
  padding: 8px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

textarea {
  resize: vertical;
  min-height: 72px;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 129, 247, 0.3);
}

input[type='checkbox'],
input[type='radio'] {
  width: auto;
  height: auto;
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
  accent-color: var(--accent, #2f81f7);
  vertical-align: middle;
  flex: none;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

.tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 10px;
  cursor: pointer;
  font-size: 14px;
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--warning);
  font-weight: 600;
}

.claim-note {
  background: rgba(210, 153, 34, 0.12);
  border: 1px solid rgba(210, 153, 34, 0.4);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 13px;
  margin-bottom: 18px;
  line-height: 1.5;
}

/* Buttons */
.btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
}

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

a.btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-success {
  background: var(--success);
  border-color: transparent;
  color: #fff;
}

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

.btn-ghost {
  background: transparent;
}

.btn-block {
  width: 100%;
  margin-top: 6px;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 18px;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  cursor: pointer;
  line-height: 1;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

a.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.error {
  color: var(--danger);
  font-size: 13px;
  margin: 12px 0 0;
}

/* App shell */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.search {
  flex: 1;
  max-width: 360px;
  margin: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  cursor: default;
}

.layout {
  display: grid;
  grid-template-columns: 290px 1fr;
  min-height: calc(100vh - 55px);
}

.sidebar {
  border-right: 1px solid var(--border);
  padding: 16px;
  background: var(--bg);
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  margin-bottom: 10px;
}

.side-search {
  margin-bottom: 12px;
}

.repo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.repo-list li {
  padding: 7px 8px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.repo-list li:hover {
  background: var(--surface-2);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.main {
  padding: 24px 32px;
  max-width: 1100px;
}

.main-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.mtab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
}

.mtab.active {
  color: var(--text);
  border-bottom-color: var(--warning);
  font-weight: 600;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}

.hero {
  background: linear-gradient(135deg, rgba(47, 129, 247, 0.18), rgba(163, 113, 247, 0.15));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  margin-bottom: 18px;
}

.hero h2 {
  margin: 0 0 6px;
  font-size: 22px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--surface-2);
}

.badge-admin {
  background: rgba(248, 81, 73, 0.15);
  color: var(--danger);
  border-color: rgba(248, 81, 73, 0.4);
}

.badge-retired {
  background: rgba(240, 136, 62, 0.15);
  color: #f0883e;
  border-color: rgba(240, 136, 62, 0.4);
}

.badge-pro {
  background: rgba(163, 113, 247, 0.15);
  color: var(--purple);
  border-color: rgba(163, 113, 247, 0.4);
}

.badge-plus {
  background: rgba(63, 185, 80, 0.15);
  color: #3fb950;
  border-color: rgba(63, 185, 80, 0.4);
}

/* Repo cards */
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.repo-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.repo-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.repo-card h4 {
  margin: 0 0 6px;
  font-size: 15px;
  color: var(--accent);
}

.repo-card p {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 13px;
  min-height: 36px;
}

.repo-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-muted);
  font-size: 12px;
}

.explore-title {
  margin: 28px 0 14px;
}

/* Workspaces */
.create-ws-card .ws-form {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

.ws-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.ws-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.ws-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.status {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status .dot {
  width: 8px;
  height: 8px;
}

.status-running .dot {
  background: #3fb950;
  box-shadow: 0 0 6px #3fb950;
}

.status-stopped .dot {
  background: var(--text-muted);
}

.specs {
  display: flex;
  gap: 16px;
  color: var(--text-muted);
  font-size: 13px;
  margin: 10px 0 14px;
}

.ws-actions {
  display: flex;
  gap: 8px;
}

/* Admin */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.stat .num {
  font-size: 24px;
  font-weight: 700;
}

.stat .lbl {
  color: var(--text-muted);
  font-size: 12px;
}

.table-wrap {
  overflow-x: auto;
}

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

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

.users-table th {
  color: var(--text-muted);
  font-weight: 500;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(1, 4, 9, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 100;
  font-size: 13px;
}

.kv {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 10px;
}

.kv td {
  padding: 6px 8px 6px 0;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  word-break: break-all;
}

.kv td:first-child {
  width: 130px;
}

.code-block {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  overflow-x: auto;
  color: var(--text);
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
  }
  .grid-2,
  .create-ws-card .ws-form {
    grid-template-columns: 1fr;
  }
  .main {
    padding: 18px;
  }
}
