* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f4f5f7;
  color: #1d2129;
}

a {
  color: #2563eb;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1, h2, h3 {
  font-weight: 600;
  margin-top: 0;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #111827;
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
}

.sidebar-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 1.5rem;
}

.sidebar-links {
  list-style: none;
  padding: 0;
  margin: 0;
  flex: 1;
}

.sidebar-links li {
  margin-bottom: 0.25rem;
}

.sidebar-links a {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  color: #d1d5db;
}

.sidebar-links a:hover {
  background: #1f2937;
  text-decoration: none;
  color: #fff;
}

.sidebar-user {
  border-top: 1px solid #374151;
  padding-top: 1rem;
  font-size: 0.875rem;
}

.sidebar-user-name {
  margin-bottom: 0.5rem;
  color: #fff;
}

.app-main {
  flex: 1;
  padding: 2rem;
  max-width: 1100px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.button-row {
  display: flex;
  gap: 0.5rem;
}

.button, button {
  display: inline-block;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.button:hover, button:hover {
  background: #1d4ed8;
  text-decoration: none;
}

.button-secondary {
  background: #6b7280;
}

.button-secondary:hover {
  background: #4b5563;
}

.button-danger {
  background: #dc2626;
}

.button-danger:hover {
  background: #b91c1c;
}

.link-button {
  background: none;
  color: #2563eb;
  border: none;
  padding: 0;
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  margin-bottom: 1.5rem;
}

.data-table th, .data-table td {
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid #eef0f2;
  font-size: 0.9rem;
}

.data-table th {
  background: #f9fafb;
  font-weight: 600;
  color: #4b5563;
}

.stat-grid {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: #fff;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  min-width: 160px;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
}

.stat-label {
  color: #6b7280;
  font-size: 0.85rem;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #e5e7eb;
  color: #374151;
}

.badge-online {
  background: #dcfce7;
  color: #166534;
}

.badge-offline {
  background: #fee2e2;
  color: #991b1b;
}

.badge-never_connected {
  background: #e5e7eb;
  color: #374151;
}

.badge-blocked {
  background: #fee2e2;
  color: #991b1b;
}

.stacked-form, .filter-form {
  background: #fff;
  padding: 1.25rem;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-width: 480px;
  margin-bottom: 1.5rem;
}

.filter-form {
  flex-direction: row;
  align-items: flex-end;
  max-width: none;
  gap: 0.75rem;
}

.stacked-form label {
  font-weight: 600;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.stacked-form input, .stacked-form select, .stacked-form textarea,
.filter-form input, .filter-form select {
  padding: 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
}

.stacked-form button {
  margin-top: 1rem;
  align-self: flex-start;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: normal !important;
}

.checkbox-label input {
  width: auto;
}

.form-error {
  background: #fee2e2;
  color: #991b1b;
  padding: 0.65rem 0.85rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.flash {
  padding: 0.65rem 0.85rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.flash-success {
  background: #dcfce7;
  color: #166534;
}

.flash-error {
  background: #fee2e2;
  color: #991b1b;
}

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #111827;
}

.auth-shell {
  background: #fff;
  border-radius: 10px;
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.auth-brand {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: #111827;
}

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

.auth-form label {
  font-weight: 600;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.auth-form input {
  padding: 0.6rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.95rem;
}

.auth-form button {
  margin-top: 1rem;
}

.totp-setup {
  text-align: center;
  margin: 1.5rem 0;
}

.totp-secret code {
  background: #f3f4f6;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  word-break: break-all;
}

.token-warning {
  background: #fef3c7;
  color: #92400e;
  padding: 0.85rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.token-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #111827;
  color: #f9fafb;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
}

.token-box code {
  flex: 1;
  word-break: break-all;
  font-size: 0.9rem;
}

.inline-form {
  display: inline;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 1rem;
}
