@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #e0e7ff;
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-input: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

::selection {
  background: var(--primary-light);
  color: var(--primary);
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
}

.layout-wrapper {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-card {
  max-width: 400px;
  width: 100%;
}

.card {
  background: var(--bg-card);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  border: 1px solid var(--border);
  width: 100%;
}

.card-header {
  margin-bottom: 2rem;
  text-align: center;
}
.card-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

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

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

.stat-card {
  background: white;
  padding: 1.5rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: transform 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.stat-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
}
.stat-value {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.key-text {
  font-family: 'Monaco', monospace;
  letter-spacing: -0.5px;
}

.bg-blue-soft {
  background: #e0e7ff;
  color: #4f46e5;
}
.bg-green-soft {
  background: #dcfce7;
  color: #166534;
}
.bg-orange-soft {
  background: #ffedd5;
  color: #c2410c;
}

.table-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.search-box {
  flex: 1;
  max-width: 300px;
}

.table-wrapper {
  background: white;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  width: 100%;
  overflow: hidden;
}
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 800px;
}
thead tr {
  background-color: var(--bg-input);
  border-bottom: 1px solid var(--border);
}
th {
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 1rem 1.5rem;
  text-align: left;
  white-space: nowrap;
}
td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td {
  border-bottom: none;
}

.action-buttons {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-start;
}
.form-group {
  margin-bottom: 1.5rem;
}
label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

input,
select {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background-color: var(--bg-input);
  font-size: 1rem;
  color: var(--text-main);
  outline: none;
  transition: all 0.2s;
}
input:focus,
select:focus {
  border-color: var(--primary);
  background-color: #fff;
  box-shadow: 0 0 0 3px var(--primary-light);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 0.875rem 1.5rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  width: auto;
  white-space: nowrap;
}
.btn.w-full {
  width: 100%;
}
.btn-primary {
  background-color: var(--primary);
  color: white;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}
.btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}
.btn-secondary {
  background-color: white;
  color: var(--text-main);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background-color: var(--bg-input);
}
.btn-danger {
  background-color: #fee2e2;
  color: #ef4444;
}
.btn-danger:hover {
  background-color: #fecaca;
}
.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  display: flex;
  align-items: flex-start;
  background: white;
  color: var(--text-main);
  padding: 16px;
  border-radius: 12px;
  min-width: 300px;
  max-width: 350px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08), 0 4px 6px rgba(0, 0, 0, 0.04);
  border-left: 5px solid var(--primary);
  transform: translateX(100%);
  animation: slideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards, fadeOut 0.4s forwards 4.5s;
  position: relative;
  overflow: hidden;
  font-size: 0.92rem;
  line-height: 1.4;
}
.toast-icon {
  margin-right: 12px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.toast-content {
  flex-grow: 1;
}
.toast-title {
  font-weight: 600;
  margin-bottom: 2px;
  display: block;
}
.toast-message {
  color: var(--text-muted);
  font-size: 0.85rem;
}
.toast-close {
  cursor: pointer;
  margin-left: 10px;
  opacity: 0.4;
  font-size: 1.2rem;
  line-height: 1;
}
.toast.success {
  border-left-color: var(--success);
}
.toast.success .toast-icon {
  color: var(--success);
}
.toast.error {
  border-left-color: var(--danger);
}
.toast.error .toast-icon {
  color: var(--danger);
}
.toast.info {
  border-left-color: var(--primary);
}
.toast.info .toast-icon {
  color: var(--primary);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
@keyframes fadeOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  animation: fadeIn 0.2s ease-out forwards;
}
.modal-box {
  background: white;
  width: 90%;
  max-width: 400px;
  padding: 2rem;
  border-radius: 20px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  transform: scale(0.95);
  opacity: 0;
  animation: popIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  text-align: center;
}
.modal-icon {
  width: 60px;
  height: 60px;
  background: #fee2e2;
  color: #ef4444;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
}
.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}
.modal-text {
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}
.modal-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}
.modal-actions button {
  flex: 1;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}
@keyframes popIn {
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@media (max-width: 768px) {
  .layout-wrapper {
    padding: 1.5rem 1rem;
  }
  .auth-wrapper {
    padding: 1rem;
  }
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .table-controls {
    flex-direction: column;
    align-items: stretch;
  }
  .search-box {
    max-width: 100%;
  }
  #toast-container {
    top: 20px;
    left: 20px;
    right: 20px;
    width: auto;
    align-items: center;
  }
  .toast {
    width: 100%;
    min-width: auto;
    max-width: 100%;
    animation: slideInMobile 0.4s forwards, fadeOutMobile 0.4s forwards 4.5s;
  }
  @keyframes slideInMobile {
    from {
      transform: translateY(-150%);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }
  @keyframes fadeOutMobile {
    from {
      transform: translateY(0);
      opacity: 1;
    }
    to {
      transform: translateY(-150%);
      opacity: 0;
    }
  }
}
