:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-card-hover: #222633;
  --border: #2a2e3d;
  --text: #e4e4e7;
  --text-dim: #9ca3af;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --green: #22c55e;
  --green-bg: rgba(34,197,94,0.12);
  --yellow: #eab308;
  --yellow-bg: rgba(234,179,8,0.12);
  --red: #ef4444;
  --red-bg: rgba(239,68,68,0.12);
  --blue: #3b82f6;
  --blue-bg: rgba(59,130,246,0.12);
  --purple: #a855f7;
  --purple-bg: rgba(168,85,247,0.12);
}

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

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

/* --- Layout --- */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-logo {
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.sidebar-logo h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.sidebar-logo span {
  font-size: 12px;
  color: var(--text-dim);
  display: block;
  margin-top: 4px;
}

.sidebar nav {
  padding: 0 12px;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--text-dim);
  text-decoration: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  margin-bottom: 2px;
}

.sidebar nav a:hover {
  background: var(--bg-card-hover);
  color: var(--text);
}

.sidebar nav a.active {
  background: var(--accent);
  color: #fff;
}

.sidebar nav a .icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
}

.sidebar-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}

.sidebar-footer a {
  display: block;
  padding: 8px 12px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
  border-radius: 8px;
  transition: all 0.15s;
}

.sidebar-footer a:hover {
  background: var(--red-bg);
  color: var(--red);
}

.main {
  margin-left: 240px;
  flex: 1;
  padding: 32px;
  max-width: 1200px;
}

/* --- Page header --- */
.page-header {
  margin-bottom: 28px;
}

.page-header h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.page-header p {
  color: var(--text-dim);
  font-size: 14px;
  margin-top: 4px;
}

/* --- Cards --- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  transition: border-color 0.15s;
}

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

.card-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.card-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1px;
}

.card-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* --- Status badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.badge-online { background: var(--green-bg); color: var(--green); }
.badge-online::before { background: var(--green); }

.badge-nginx { background: var(--blue-bg); color: var(--blue); }
.badge-nginx::before { background: var(--blue); }

.badge-stopped { background: var(--red-bg); color: var(--red); }
.badge-stopped::before { background: var(--red); }

.badge-unknown { background: var(--yellow-bg); color: var(--yellow); }
.badge-unknown::before { background: var(--yellow); }

/* --- Tables --- */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 24px;
}

.table-wrap h3 {
  padding: 16px 20px;
  font-size: 15px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 14px 20px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

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

tr:hover td {
  background: var(--bg-card-hover);
}

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

td a:hover {
  text-decoration: underline;
}

/* --- Site cards (websites page) --- */
.site-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: start;
}

.site-card h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.site-card .domain {
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
}

.site-card .desc {
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 8px;
}

.site-meta {
  display: flex;
  gap: 24px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.site-meta-item {
  font-size: 12px;
}

.site-meta-item .label {
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  display: block;
  margin-bottom: 2px;
}

.site-meta-item .val {
  font-weight: 600;
  font-size: 14px;
}

/* --- Backup slots --- */
.backup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.backup-slot {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.backup-slot h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.backup-file {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.backup-file:last-child {
  border-bottom: none;
}

.backup-file .fname {
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
}

.backup-file .fsize {
  color: var(--text-dim);
}

/* --- Log viewer --- */
.log-box {
  background: #0d0f14;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--text-dim);
  max-height: 400px;
  overflow-y: auto;
}

/* --- Docs list --- */
.doc-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: border-color 0.15s;
  text-decoration: none;
  color: inherit;
}

.doc-item:hover {
  border-color: var(--accent);
}

.doc-item h4 {
  font-size: 15px;
  font-weight: 600;
}

.doc-item .doc-meta {
  color: var(--text-dim);
  font-size: 12px;
}

/* --- Doc viewer --- */
.doc-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  line-height: 1.7;
}

.doc-content h1, .doc-content h2, .doc-content h3 {
  margin-top: 24px;
  margin-bottom: 12px;
}

.doc-content h1 { font-size: 24px; }
.doc-content h2 { font-size: 20px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.doc-content h3 { font-size: 16px; }

.doc-content p { margin-bottom: 12px; color: var(--text); }
.doc-content ul, .doc-content ol { margin-bottom: 12px; padding-left: 24px; }
.doc-content li { margin-bottom: 6px; }

.doc-content code {
  background: #0d0f14;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
}

.doc-content pre {
  background: #0d0f14;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  margin-bottom: 16px;
}

.doc-content pre code {
  background: none;
  padding: 0;
}

.doc-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}

.doc-content table th,
.doc-content table td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  font-size: 13px;
}

.doc-content table th {
  background: var(--bg-card-hover);
}

.doc-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 16px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}

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

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

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

.btn-secondary:hover {
  border-color: var(--accent);
}

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

/* --- Editor --- */
.editor-textarea {
  width: 100%;
  min-height: 500px;
  background: #0d0f14;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
}

.editor-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.editor-input {
  width: 100%;
  padding: 10px 14px;
  background: #0d0f14;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 12px;
}

.editor-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* --- Toolbar --- */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

/* --- Login --- */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
}

.login-box h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-box p {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 24px;
}

.login-box input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  background: #0d0f14;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  margin-bottom: 16px;
}

.login-box input:focus {
  outline: none;
  border-color: var(--accent);
}

.login-box button {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.login-box button:hover {
  background: var(--accent-hover);
}

.login-error {
  color: var(--red);
  font-size: 13px;
  margin-bottom: 12px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 16px; }
  .backup-grid { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr 1fr; }
  .site-card { grid-template-columns: 1fr; }
}
