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

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 0.75rem 0;
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease, min-width 0.2s ease;
  overflow: hidden;
  flex-shrink: 0;
}
.layout.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-width);
  min-width: var(--sidebar-collapsed-width);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 1rem;
  white-space: nowrap;
}
.sidebar-brand-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
}
.layout.sidebar-collapsed .sidebar-brand { justify-content: center; padding-left: 0; padding-right: 0; }
.layout.sidebar-collapsed .sidebar-brand span:not(.sidebar-brand-icon) { display: none; }
.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.25rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}
.sidebar a .nav-icon {
  width: 20px;
  flex-shrink: 0;
  text-align: center;
  font-size: 1.1rem;
  opacity: 0.9;
}
.layout.sidebar-collapsed .sidebar a span:not(.nav-icon) { display: none; }
.layout.sidebar-collapsed .sidebar a { justify-content: center; padding-left: 0; padding-right: 0; }
.sidebar a:hover { color: var(--accent); background: var(--bg-tertiary); }
.sidebar a.active { color: var(--accent); background: var(--bg-tertiary); font-weight: 500; }
.sidebar .logout-btn { margin-top: auto; border-top: 1px solid var(--border); padding-top: 0.75rem; }

.main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar {
  height: var(--header-height);
  min-height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  flex-shrink: 0;
}
.sidebar-toggle {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: background 0.15s;
}
.sidebar-toggle:hover { background: var(--border); }
.topbar-title { font-size: 1.125rem; font-weight: 600; margin: 0; color: var(--text-primary); }
.topbar-spacer { flex: 1; }
.theme-toggle {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-primary);
  font-size: 0.9rem;
}
.theme-toggle:hover { background: var(--border); }

.main {
  flex: 1;
  padding: 1.5rem;
  overflow: auto;
}
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.header-row h2 { margin: 0; font-size: 1.35rem; font-weight: 600; }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-card { max-width: 360px; width: 100%; }
.login-card h1 { margin: 0 0 0.25rem; }
.login-card .sub { color: var(--text-secondary); margin: 0 0 1.5rem; }
.login-card label { display: block; margin: 0.75rem 0 0.25rem; font-size: 0.9rem; }
.login-card input { width: 100%; box-sizing: border-box; }
.login-card button { width: 100%; margin-top: 1.25rem; padding: 0.65rem; }
.login-card .error { color: var(--error); margin-top: 0.5rem; }

/* Sections (tabs) */
.section { display: none; }
.section.active { display: block; }

/* Tables */
table { width: 100%; border-collapse: collapse; border-radius: var(--radius-sm); overflow: hidden; }
th, td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--bg-tertiary); font-weight: 600; font-size: 0.875rem; }
tr:last-child td { border-bottom: none; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.actions button { padding: 0.4rem 0.75rem; font-size: 0.85rem; }
.actions button.danger { background: var(--error); }
.actions button.danger:hover { filter: brightness(1.1); }

/* Forms in modals */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.25rem; }
.form-group input, .form-group select { width: 100%; box-sizing: border-box; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: none; align-items: center; justify-content: center; z-index: 1000;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg-secondary); border-radius: var(--radius-md); max-width: 520px; width: 90%; max-height: 90vh; overflow: auto; padding: 1.5rem;
}
.modal h3 { margin: 0 0 1rem; }

.logout-btn { margin-left: 0; }

/* Status badges */
.badge { display: inline-block; padding: 0.2rem 0.5rem; border-radius: 6px; font-size: 0.8rem; }
.badge.ok { background: rgba(52,199,89,0.2); color: var(--success); }
.badge.fail { background: rgba(255,59,48,0.2); color: var(--error); }
.badge.warn { background: rgba(255,204,0,0.2); color: #c9a227; }

/* DNS modal */
.dns-compare { font-family: monospace; font-size: 0.85rem; }
.dns-compare .expected { color: var(--success); }
.dns-compare .current { color: var(--text-primary); }
.dns-compare .missing { color: var(--error); }

/* Empty state */
.empty-state { color: var(--text-secondary); text-align: center; padding: 2rem; }
