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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242836;
  --border: #2e3347;
  --text: #e4e6f0;
  --text-dim: #8b8fa7;
  --accent: #6c5ce7;
  --accent-hover: #7c6ef7;
  --success: #00b894;
  --danger: #e17055;
  --warning: #fdcb6e;
  --info: #74b9ff;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; min-height: 100vh; }

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

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: var(--surface); border-right: 1px solid var(--border);
  padding: 1.5rem 0; display: flex; flex-direction: column; position: fixed; height: 100vh; overflow-y: auto;
}
.sidebar-brand { padding: 0 1.25rem 1.5rem; font-size: 1.1rem; font-weight: 700; color: var(--accent); border-bottom: 1px solid var(--border); margin-bottom: 0.75rem; }
.sidebar-nav a {
  display: block; padding: 0.6rem 1.25rem; color: var(--text-dim); font-size: 0.9rem; transition: background 0.15s, color 0.15s;
}
.sidebar-nav a:hover, .sidebar-nav a.active { background: var(--surface2); color: var(--text); }
.sidebar-footer { margin-top: auto; padding: 1rem 1.25rem; border-top: 1px solid var(--border); font-size: 0.8rem; color: var(--text-dim); }

.main { flex: 1; margin-left: 220px; padding: 2rem; }

/* Page header */
.page-header { margin-bottom: 1.5rem; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 600; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.card-header { font-size: 0.85rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.5rem; }
.card-value { font-size: 1.75rem; font-weight: 700; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
tr:hover td { background: var(--surface2); }

/* Badges */
.badge {
  display: inline-block; padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
}
.badge-ad { background: rgba(108,92,231,0.2); color: var(--accent); }
.badge-group { background: rgba(0,184,148,0.2); color: var(--success); }
.badge-enabled { background: rgba(0,184,148,0.15); color: var(--success); }
.badge-disabled { background: rgba(225,112,85,0.15); color: var(--danger); }
.badge-pinned { background: rgba(253,203,110,0.2); color: var(--warning); }
.badge-rotate { background: rgba(116,185,255,0.2); color: var(--info); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.5rem 1rem;
  border-radius: var(--radius); font-size: 0.85rem; font-weight: 500; border: none;
  cursor: pointer; transition: background 0.15s; text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c95541; color: #fff; }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-dim); }
.btn-outline:hover { border-color: var(--text-dim); color: var(--text); background: var(--surface2); }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.35rem; font-size: 0.85rem; font-weight: 500; color: var(--text-dim); }
.form-control {
  width: 100%; padding: 0.55rem 0.75rem; background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 0.9rem; font-family: var(--font);
}
.form-control:focus { outline: none; border-color: var(--accent); }
textarea.form-control { min-height: 120px; resize: vertical; }
select.form-control { appearance: auto; }

.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 150px; }

.form-check { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.form-check input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.form-check label { margin: 0; cursor: pointer; }

.form-inline { display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.form-inline .form-group { margin-bottom: 0; }

/* Toggle switch */
.toggle-form { display: inline; }
.toggle-btn {
  padding: 0.25rem 0.6rem; border-radius: 4px; font-size: 0.75rem; font-weight: 600;
  border: none; cursor: pointer; transition: background 0.15s;
}
.toggle-on { background: rgba(0,184,148,0.2); color: var(--success); }
.toggle-on:hover { background: rgba(0,184,148,0.35); }
.toggle-off { background: rgba(225,112,85,0.15); color: var(--danger); }
.toggle-off:hover { background: rgba(225,112,85,0.3); }

/* Login */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { width: 100%; max-width: 380px; }
.login-box h1 { text-align: center; margin-bottom: 1.5rem; color: var(--accent); }
.login-error { background: rgba(225,112,85,0.15); color: var(--danger); padding: 0.65rem 0.75rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.85rem; }

/* Pagination */
.pagination { display: flex; gap: 0.5rem; margin-top: 1rem; align-items: center; }
.pagination a, .pagination span { padding: 0.35rem 0.75rem; border-radius: var(--radius); font-size: 0.85rem; }
.pagination a { background: var(--surface2); color: var(--text-dim); }
.pagination a:hover { color: var(--text); }
.pagination .current { background: var(--accent); color: #fff; }
.pagination .info { color: var(--text-dim); font-size: 0.8rem; }

/* Detail sections */
.detail-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; font-size: 0.9rem; }
.detail-label { color: var(--text-dim); min-width: 130px; }
.detail-value { color: var(--text); }
.body-preview { background: var(--surface2); padding: 1rem; border-radius: var(--radius); white-space: pre-wrap; font-size: 0.88rem; margin-top: 0.5rem; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
}
