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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0f1117;
  color: #e1e4e8;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header (Brand) ─────────────────────────── */

.header-brand {
  background: linear-gradient(135deg, #1a1f35 0%, #0d1117 100%);
  border-bottom: 1px solid #21262d;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  flex-shrink: 0;
}

.header-titles h1 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #f0f6fc;
}

.header-subtitle {
  font-size: 0.8rem;
  color: #8b949e;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── Status Bar ──────────────────────────────── */

.status-bar {
  display: flex;
  justify-content: center;
  gap: 2rem;
  padding: 0.5rem;
  background: #161b22;
  border-bottom: 1px solid #21262d;
  font-size: 0.75rem;
  color: #8b949e;
  flex-wrap: wrap;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
}

.dot.green { background: #3fb950; }

/* ── Navigation ─────────────────────────────── */

.nav-link {
  font-size: 0.8rem;
  color: #58a6ff;
  text-decoration: none;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  transition: background 0.15s;
}

.nav-link:hover {
  background: rgba(88, 166, 255, 0.1);
}

.user-badge {
  font-size: 0.7rem;
  color: #8b949e;
  padding: 0.2rem 0.6rem;
  background: #21262d;
  border-radius: 12px;
}

.btn-logout {
  font-size: 0.7rem;
  color: #f85149;
  text-decoration: none;
  padding: 0.25rem 0.6rem;
  border: 1px solid #f85149;
  border-radius: 6px;
  transition: background 0.15s;
}

.btn-logout:hover {
  background: rgba(248, 81, 73, 0.1);
}

/* ── Flash Messages ─────────────────────────── */

.flash {
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.8rem;
  margin-bottom: 1rem;
}

.flash.success {
  background: rgba(63, 185, 80, 0.12);
  border: 1px solid rgba(63, 185, 80, 0.25);
  color: #3fb950;
}

.flash.error {
  background: rgba(248, 81, 73, 0.12);
  border: 1px solid rgba(248, 81, 73, 0.25);
  color: #f85149;
}

/* ── Main ─────────────────────────────────────── */

main {
  flex: 1;
  max-width: 820px;
  width: 100%;
  margin: 2rem auto;
  padding: 0 1rem;
}

/* ── Dashboard ────────────────────────────────── */

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.card-dash {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 8px;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.card-dash-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.card-dash-icon.green  { background: rgba(63,185,80,0.12); color: #3fb950; }
.card-dash-icon.blue   { background: rgba(56,139,253,0.12); color: #388bfd; }
.card-dash-icon.red    { background: rgba(248,81,73,0.12);  color: #f85149; }
.card-dash-icon.purple { background: rgba(163,113,247,0.12); color: #a371f7; }
.card-dash-icon.cyan   { background: rgba(57,211,216,0.12); color: #39d3d8; }

.card-dash-body h3 {
  font-size: 0.7rem;
  color: #8b949e;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.card-dash-body p {
  font-size: 1.2rem;
  font-weight: 700;
  color: #f0f6fc;
  margin-top: 0.1rem;
}

/* ── Quick Actions ────────────────────────────── */

.quick-actions h2 {
  font-size: 0.8rem;
  color: #8b949e;
  font-weight: 500;
  margin-bottom: 0.75rem;
}

.action-list {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.action-btn {
  padding: 0.5rem 1rem;
  background: #21262d;
  border: 1px solid #21262d;
  border-radius: 6px;
  color: #c9d1d9;
  font-size: 0.8rem;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}

.action-btn:hover {
  border-color: #388bfd;
  color: #58a6ff;
}

/* ── Section Cards ──────────────────────────── */

.section-card {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.section-card h2 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #f0f6fc;
  margin-bottom: 1rem;
}

.help-text {
  font-size: 0.8rem;
  color: #8b949e;
  margin-bottom: 1rem;
}

.help-text a {
  color: #58a6ff;
}

/* ── Mode Bar ────────────────────────────────── */

.mode-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  padding: 0.7rem 1rem;
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 8px;
  flex-wrap: wrap;
}

.mode-label {
  font-weight: 500;
  font-size: 0.8rem;
  color: #8b949e;
  margin-right: 0.25rem;
}

.mode-form { display: inline; }

.mode-btn {
  padding: 0.35rem 0.85rem;
  border: 1px solid #21262d;
  border-radius: 6px;
  background: #21262d;
  color: #c9d1d9;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.mode-btn:hover {
  background: #30363d;
  border-color: #388bfd;
}

.mode-btn.active {
  background: #1f6feb;
  border-color: #1f6feb;
  color: #fff;
}

.mode-hint {
  font-size: 0.72rem;
  color: #8b949e;
  margin-left: auto;
}

/* ── Group List ──────────────────────────────── */

.group-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.group-count {
  font-size: 0.72rem;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.group-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.group-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: #0d1117;
  border: 1px solid #21262d;
  border-radius: 8px;
  transition: border-color 0.15s;
}

.group-item.included {
  border-color: #238636;
}

.group-item.excluded {
  border-color: #21262d;
  opacity: 0.65;
}

.toggle-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #21262d;
  border-radius: 6px;
  background: #21262d;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: all 0.15s;
  flex-shrink: 0;
}

.group-item.included .toggle-btn {
  border-color: #238636;
  background: #162b1a;
}

.group-item.included .toggle-btn:hover {
  background: #1a3a20;
}

.group-item.excluded .toggle-btn:hover {
  background: #30363d;
  border-color: #f85149;
}

.check { line-height: 1; }

.group-item.included .check { color: #3fb950; }
.group-item.excluded .check { color: #8b949e; }

.group-name {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-status {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  flex-shrink: 0;
}

.group-status.included {
  background: #162b1a;
  color: #3fb950;
}

.group-status.excluded {
  background: #21262d;
  color: #8b949e;
}

/* ── Empty State ────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #8b949e;
}

.empty-state .subtle {
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

.empty-state code,
.empty-state a {
  background: #21262d;
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-size: 0.8rem;
  color: #58a6ff;
}

/* ── Actions ──────────────────────────────────── */

.actions {
  margin-top: 1rem;
  text-align: center;
}

.btn-reset {
  padding: 0.4rem 1rem;
  border: 1px solid #21262d;
  border-radius: 6px;
  background: transparent;
  color: #8b949e;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.btn-reset:hover {
  border-color: #f85149;
  color: #f85149;
}

/* ── Login Page ───────────────────────────────── */

.login-page {
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f1117 0%, #1a1f35 100%);
}

.login-container {
  max-width: 380px;
  width: 100%;
  padding: 2.5rem 2rem;
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 10px;
  text-align: center;
}

.login-logo {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  margin-bottom: 0.75rem;
}

.login-container h1 {
  font-size: 1.2rem;
  font-weight: 600;
  color: #f0f6fc;
  margin-bottom: 0.2rem;
}

.login-subtitle {
  font-size: 0.8rem;
  color: #8b949e;
  margin-bottom: 1.5rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-align: left;
}

.login-form label {
  font-size: 0.8rem;
  font-weight: 500;
  color: #c9d1d9;
  margin-top: 0.5rem;
}

.login-form label:first-child { margin-top: 0; }

.login-form input {
  padding: 0.6rem 0.75rem;
  background: #0d1117;
  border: 1px solid #21262d;
  border-radius: 6px;
  color: #e1e4e8;
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.login-form input:focus {
  border-color: #388bfd;
}

.login-form input::placeholder {
  color: #484f58;
}

.btn-login {
  margin-top: 1.25rem;
  padding: 0.65rem;
  background: #238636;
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-login:hover {
  background: #2ea043;
}

/* ── Forms ────────────────────────────────────── */

.form-stacked {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-stacked label {
  font-size: 0.8rem;
  font-weight: 500;
  color: #c9d1d9;
  margin-top: 0.75rem;
}

.form-stacked label:first-child { margin-top: 0; }

.form-stacked input {
  padding: 0.55rem 0.75rem;
  background: #0d1117;
  border: 1px solid #21262d;
  border-radius: 6px;
  color: #e1e4e8;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
}

.form-stacked input:focus {
  border-color: #388bfd;
}

.form-actions {
  margin-top: 1.25rem;
}

.inline-form { display: inline; }

.inline-form-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.input-med {
  padding: 0.5rem 0.7rem;
  background: #0d1117;
  border: 1px solid #21262d;
  border-radius: 6px;
  color: #e1e4e8;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  flex: 1;
  min-width: 160px;
}

.input-med:focus {
  border-color: #388bfd;
}

.btn-primary {
  padding: 0.5rem 1.2rem;
  background: #238636;
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover {
  background: #2ea043;
}

.btn-sm {
  padding: 0.3rem 0.75rem;
  background: #21262d;
  border: 1px solid #21262d;
  border-radius: 6px;
  color: #c9d1d9;
  font-size: 0.72rem;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s;
}

.btn-sm:hover {
  border-color: #388bfd;
}

.btn-danger-small {
  padding: 0.25rem 0.6rem;
  background: transparent;
  border: 1px solid #f85149;
  border-radius: 4px;
  color: #f85149;
  font-size: 0.68rem;
  font-family: inherit;
  cursor: pointer;
}

.btn-danger-small:hover {
  background: rgba(248,81,73,0.1);
}

/* ── Tables ──────────────────────────────────── */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.table th {
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid #21262d;
  color: #8b949e;
  font-weight: 500;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid #21262d;
  color: #c9d1d9;
}

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

.badge-role {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge-role.super_admin {
  background: rgba(210,153,34,0.15);
  color: #d29922;
  border: 1px solid rgba(210,153,34,0.3);
}

.badge-role.user {
  background: rgba(56,139,253,0.12);
  color: #388bfd;
  border: 1px solid rgba(56,139,253,0.25);
}

/* ── Footer (Brand) ─────────────────────────── */

.footer-brand {
  text-align: center;
  padding: 1.5rem;
  margin-top: 2rem;
  border-top: 1px solid #21262d;
  font-size: 0.72rem;
  color: #484f58;
}

.footer-brand a {
  color: #58a6ff;
  text-decoration: none;
}

.footer-brand a:hover {
  text-decoration: underline;
}

.footer-brand strong {
  color: #8b949e;
}

.card-dash-icon.orange { background: rgba(255,165,0,0.12); color: #ffa500; }

.dot.red { background: #f85149; }
.dot.yellow { background: #d29922; }

.process-status-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: #0d1117;
  border: 1px solid #21262d;
  border-radius: 8px;
}

.process-status-icon {
  flex-shrink: 0;
}

.process-status-icon .dot {
  width: 14px;
  height: 14px;
  margin: 0;
}

.process-status-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.process-status-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #f0f6fc;
}

.process-status-detail {
  font-size: 0.72rem;
  color: #8b949e;
}

.process-status-time {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.process-refresh-label {
  font-size: 0.65rem;
  color: #484f58;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.process-refresh-countdown {
  font-size: 0.75rem;
  color: #8b949e;
  font-weight: 600;
  min-width: 24px;
  text-align: right;
}
