:root {
  --bg-primary: #0f172a;
  --bg-surface: #1e293b;
  --bg-elevated: #334155;
  --border-color: #475569;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

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

body {
  font-family: var(--font);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* Container & Center Cards */
.center-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow);
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.auth-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 0.5rem;
}

.ip-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  padding: 0.4rem 0.9rem;
  border-radius: 9999px;
  font-family: monospace;
  font-size: 0.9rem;
  color: #38bdf8;
  margin-top: 0.75rem;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  transition: border-color 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s ease, transform 0.05s ease;
  text-decoration: none !important;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-block,
.auth-card form button[type="submit"],
.auth-card .btn-primary:not(.toggle-password) {
  width: 100%;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover:not(:disabled) {
  background: #059669;
}

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

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  width: auto;
}

/* Alerts & Banners */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.alert-danger {
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  color: #fca5a5;
}

.alert-warning {
  background: var(--warning-bg);
  border: 1px solid var(--warning);
  color: #fcd34d;
}

.alert-success {
  background: var(--success-bg);
  border: 1px solid var(--success);
  color: #6ee7b7;
}

.alert-title {
  font-weight: 700;
  font-size: 1rem;
}

/* Status Cards & Ports */
.status-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 600px;
  box-shadow: var(--shadow);
}

.countdown-box {
  text-align: center;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin: 1.5rem 0;
}

.countdown-digits {
  font-family: monospace;
  font-size: 2.75rem;
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 0.1em;
}

.countdown-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.ports-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1rem 0;
}

.port-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.6rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.port-item:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.port-badge {
  color: #a7f3d0;
  font-family: monospace;
  font-size: 0.9rem;
  font-weight: 600;
}

.port-check-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.port-check-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.port-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
  transition: all 0.2s ease;
}

.status-indicator-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
  flex-shrink: 0;
}

.port-status-badge.status-open {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.port-status-badge.status-closed {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.port-status-badge.status-unreachable {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.port-status-badge.status-checking {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.port-status-badge.status-checking .status-indicator-dot {
  animation: pulse-dot 1.2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

/* Admin Portal Layout */
.admin-shell {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: 260px;
  background: #090d16;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.brand {
  padding: 1.5rem;
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-nav {
  list-style: none;
  padding: 1rem 0.75rem;
  flex: 1;
}

.admin-nav li {
  margin-bottom: 0.25rem;
}

.admin-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.9rem;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.admin-nav a:hover, .admin-nav a.active {
  background: var(--bg-elevated);
  color: #fff;
  text-decoration: none;
}

.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  overflow-y: auto;
}

.admin-topbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-content {
  padding: 2rem;
  flex: 1;
}

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

.content-header .btn,
.content-header form .btn {
  width: auto;
  white-space: nowrap;
  flex-shrink: 0;
}

.content-header form {
  margin: 0;
  display: inline-flex;
  flex-shrink: 0;
}

.content-header h2 {
  font-size: 1.6rem;
  font-weight: 700;
}

/* Stats Cards */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.metric-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 600;
}

.metric-value {
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  margin: 0.35rem 0;
}

/* Tables */
.table-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  background: #111827;
  padding: 0.85rem 1rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
}

td {
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(71, 85, 105, 0.4);
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success { background: var(--success-bg); color: #34d399; }
.badge-danger { background: var(--danger-bg); color: #f87171; }
.badge-warning { background: var(--warning-bg); color: #fbbf24; }
.badge-info { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

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

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-secondary);
  cursor: pointer;
}

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

.flex-row input {
  flex: 1;
  min-width: 0;
}

.toggle-password {
  width: auto !important;
  min-width: 4.5rem;
  padding: 0.75rem 0.85rem !important;
  flex-shrink: 0;
  text-align: center;
}

/* Footer & Branding */
.public-footer {
  margin: 2rem 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
}

.public-footer a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.public-footer a:hover {
  color: #38bdf8;
  text-decoration: underline;
}

.footer-version {
  color: var(--text-muted);
  font-size: 0.75rem;
  background: var(--bg-elevated);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-family: monospace;
}

.brand-sub {
  padding: 0 1.5rem 0.85rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.brand-sub a {
  color: #38bdf8;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.brand-sub a:hover {
  color: #7dd3fc;
  text-decoration: underline;
}

.sidebar-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.sidebar-footer a:hover {
  color: var(--text-secondary);
  text-decoration: underline;
}

