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

:root {
  --primary-color: #2563eb;
  --secondary-color: #64748b;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-color: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.header {
  background: white;
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 0;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
}

.header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.5rem;
  color: var(--primary-color);
  font-weight: 700;
}

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

.main {
  min-height: calc(100vh - 200px);
  padding-bottom: 2rem;
}

.footer {
  background: white;
  border-top: 1px solid var(--border-color);
  padding: 2rem 0;
  margin-top: 3rem;
  text-align: center;
  color: var(--text-muted);
}

.btn {
  display: inline-block;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-secondary {
  background: var(--secondary-color);
  color: white;
}

.btn-secondary:hover {
  background: #475569;
}

.btn-warning {
  background: var(--warning-color);
  color: white;
}

.btn-danger {
  background: var(--danger-color);
  color: white;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.813rem;
}

.btn-full {
  width: 100%;
}

.btn-link {
  background: none;
  color: var(--primary-color);
  border: none;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  font-size: 0.875rem;
}

.card {
  background: var(--card-bg);
  border-radius: 0.5rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.card h3 {
  margin-bottom: 1rem;
  color: var(--text-color);
}

.auth-container {
  max-width: 400px;
  margin: 3rem auto;
  background: var(--card-bg);
  padding: 2rem;
  border-radius: 0.5rem;
  box-shadow: var(--shadow-lg);
}

.auth-container h2 {
  margin-bottom: 1.5rem;
  text-align: center;
}

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

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-color);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.625rem;
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  font-size: 0.875rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group small {
  display: block;
  margin-top: 0.25rem;
  color: var(--text-muted);
  font-size: 0.813rem;
}

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

.input-grow {
  flex: 1;
  padding: 0.625rem;
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  font-size: 0.875rem;
}

.form-wide {
  max-width: 600px;
}

.alert {
  padding: 1rem;
  border-radius: 0.375rem;
  margin-bottom: 1rem;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

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

.table-container {
  overflow-x: auto;
  background: white;
  border-radius: 0.5rem;
  box-shadow: var(--shadow);
}

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

.table th,
.table td {
  padding: 0.875rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.table th {
  background: var(--bg-color);
  font-weight: 600;
  color: var(--text-color);
}

.table tbody tr:hover {
  background: var(--bg-color);
}

.table .actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.api-key {
  background: var(--bg-color);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-family: 'Courier New', monospace;
  font-size: 0.875rem;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.api-key-section {
  margin-bottom: 1.5rem;
}

.api-key-display {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

#apiKeyDisplay {
  flex: 1;
  background: var(--bg-color);
  padding: 0.5rem;
  border-radius: 0.25rem;
  font-family: 'Courier New', monospace;
}

.api-info {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-color);
  border-radius: 0.375rem;
}

.api-info h4 {
  margin-bottom: 0.5rem;
}

.code-example {
  background: #1e293b;
  color: #e2e8f0;
  padding: 1rem;
  border-radius: 0.375rem;
  overflow-x: auto;
  margin-top: 0.5rem;
  font-size: 0.813rem;
}

.current-link {
  padding: 1rem;
  background: var(--bg-color);
  border-radius: 0.375rem;
  border-left: 4px solid var(--success-color);
}

.current-link a {
  color: var(--primary-color);
  word-break: break-all;
  font-weight: 500;
}

.current-link small {
  display: block;
  margin-top: 0.5rem;
  color: var(--text-muted);
}

.text-muted {
  color: var(--text-muted);
}

.links-list h4 {
  margin-bottom: 1rem;
}

.sortable-list {
  list-style: none;
}

.link-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  margin-bottom: 0.5rem;
  cursor: move;
}

.link-item:hover {
  background: #f1f5f9;
}

.drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 1.25rem;
}

.link-url {
  flex: 1;
  word-break: break-all;
  font-size: 0.875rem;
}

.form-note {
  display: block;
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.813rem;
}

.error-container {
  text-align: center;
  padding: 3rem 0;
}

.error-container h1 {
  font-size: 4rem;
  color: var(--primary-color);
  margin-bottom: 1rem;
}

.error-container h2 {
  margin-bottom: 1rem;
}

.error-container p {
  color: var(--text-muted);
  margin-bottom: 2rem;
}

@media (max-width: 768px) {
  .header .container {
    flex-direction: column;
    gap: 1rem;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .table .actions {
    flex-direction: column;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}
