:root {
  --bg-base: #0f1117;
  --bg-card: #1a1d27;
  --bg-input: #232734;
  --border: #2d3345;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.25);
  --danger: #ef4444;
  --success: #10b981;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-base);
  color: var(--text-main);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 1.5rem 1rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.card-wide {
  max-width: 820px;
}

@media (min-width: 640px) {
  body {
    padding: 2.5rem 1.5rem;
  }
  .card {
    padding: 2rem;
  }
}

h1, h2, h3 {
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-bottom: 0.75rem;
  line-height: 1.25;
}

p.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

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

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

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"] {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 1rem;
  min-height: 48px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 0.8rem 1.2rem;
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: background-color 0.15s ease, transform 0.05s ease;
}

.btn:hover {
  background: var(--accent-hover);
}

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

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: var(--bg-input);
}

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

@media (min-width: 480px) {
  .btn-group {
    flex-direction: row;
  }
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.alert-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--danger);
  color: #fca5a5;
}

.alert-success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid var(--success);
  color: #6ee7b7;
}

.divider {
  width: 100%;
  height: 1px;
  background: var(--border);
  margin: 1.75rem 0 1.25rem 0;
}

.empty-state {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.5rem;
}

/* Link Cards Layout */
.link-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
  width: 100%;
}

.link-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  overflow: hidden;
  box-sizing: border-box;
}

.link-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

/* Universal Link Styling */
a,
a:link,
a:visited {
  color: var(--accent);
  text-decoration: none;
}

/* Short Code Badge */
.link-badge,
.link-badge:link,
.link-badge:visited {
  display: inline-block;
  font-weight: 700;
  font-size: 0.95rem;
  color: #c7d2fe !important;
  background: rgba(99, 102, 241, 0.2) !important;
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  border: 1px solid rgba(99, 102, 241, 0.4);
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.link-badge:hover {
  background: rgba(99, 102, 241, 0.35) !important;
  color: #ffffff !important;
}

/* Copy Button */
.btn-copy {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-copy:hover {
  color: var(--text-main);
  border-color: var(--accent);
}

/* Destination Target URL */
.link-destination,
.link-destination:link,
.link-destination:visited {
  color: #e2e8f0 !important;
  font-size: 0.85rem;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  width: 100%;
  transition: color 0.15s ease;
}

.link-destination:hover {
  color: #ffffff !important;
  text-decoration: underline;
}

/* Legacy Table Styling (if still present) */
.table-responsive {
  width: 100%;
  overflow: hidden;
  margin-top: 1rem;
}

table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

th, td {
  padding: 0.75rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(255, 255, 255, 0.02);
}

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

th:first-child, td:first-child {
  width: 38%;
}

th:last-child, td:last-child {
  width: 62%;
}

td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

td a,
td a:link,
td a:visited {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #93c5fd !important;
  text-decoration: none;
}

td a:hover {
  color: #ffffff !important;
  text-decoration: underline;
}

.btn,
.btn:link,
.btn:visited {
  color: #ffffff !important;
}

.btn-secondary,
.btn-secondary:link,
.btn-secondary:visited {
  color: var(--text-main) !important;
}

.btn-secondary:hover {
  background: var(--bg-input);
  color: #ffffff !important;
}

.role-4 {
    background: rgba(168, 85, 247, 0.18);
    color: #d8b4fe;
    border: 1px solid rgba(168, 85, 247, 0.4);
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.2);
}