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

:root {
  --bg: #0f0f0f;
  --card: #1a1a1a;
  --border: #2a2a2a;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --text: #e5e5e5;
  --text-muted: #888;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #16a34a;
  --radius: 8px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

/* Auth page */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-container {
  width: 100%;
  max-width: 380px;
  padding: 24px 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 24px;
  justify-content: center;
}

.auth-card { text-align: center; }
.auth-card h1 { font-size: 20px; margin-bottom: 20px; }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}

/* Header */
header {
  border-bottom: 1px solid var(--border);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-inner .logo { margin: 0; font-size: 16px; }

/* Main */
main {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Forms */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input[type="text"],
input[type="url"],
input[type="password"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 12px;
  font-size: 14px;
  width: 100%;
  transition: border-color 0.15s;
  outline: none;
}

input:focus {
  border-color: var(--accent);
}

.create-form {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  gap: 12px;
  align-items: end;
}

.create-form .form-group { margin-bottom: 0; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

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

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

.btn-ghost:hover { color: var(--text); border-color: #444; }

.btn-full { width: 100%; justify-content: center; }

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.btn-icon:hover { color: var(--text); border-color: #444; background: #222; }
.btn-icon.copy-btn:hover { color: var(--accent); border-color: var(--accent); }
.btn-icon.delete-btn:hover { color: var(--danger); border-color: var(--danger); }

/* Table */
.table-card h2 {
  font-size: 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  background: #2a2a2a;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}

.table-wrapper { overflow-x: auto; }

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

thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid #1f1f1f;
  transition: background 0.1s;
}

tbody tr:hover { background: #1f1f1f; }
tbody tr:last-child { border-bottom: none; }

td {
  padding: 12px;
  vertical-align: middle;
}

td code {
  background: #252525;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 13px;
  color: var(--accent);
}

td.destination {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 13px;
}

td.clicks {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.short-url {
  font-size: 13px;
  color: var(--text-muted);
  margin-right: 6px;
}

td:last-child {
  display: flex;
  gap: 6px;
  align-items: center;
}

.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 32px !important;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 420px;
  padding: 24px;
}

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

.modal-header h3 { font-size: 16px; }

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* Error & Toast */
.error {
  color: #f87171;
  font-size: 13px;
  margin-top: 8px;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 13px;
  color: var(--text);
  z-index: 200;
  animation: slideIn 0.2s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error-toast { border-left: 3px solid var(--danger); }

@keyframes slideIn {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Responsive */
@media (max-width: 600px) {
  .create-form {
    grid-template-columns: 1fr;
  }
  main { padding: 16px; }
  .header-inner { padding: 12px 16px; }
}
