/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background-color: #f5f5f5;
  color: #1a1a1a;
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== Navbar ===== */
.navbar {
  background-color: #111;
  color: #fff;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.navbar-brand {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  letter-spacing: 0.5px;
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.nav-link {
  color: #ccc;
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.15s;
  padding: 0.25rem 0;
}

.nav-link:hover {
  color: #fff;
}

.nav-active {
  color: #fff !important;
  font-weight: 600;
  border-bottom: 2px solid #fff;
  padding-bottom: 2px;
}

.nav-email {
  color: #aaa;
  font-size: 0.875rem;
}

/* ===== Flash Messages ===== */
.flash {
  padding: 0.75rem 1.5rem;
  font-size: 0.9rem;
  text-align: center;
  font-weight: 500;
}

.flash-success {
  background-color: #d4edda;
  color: #155724;
  border-bottom: 1px solid #c3e6cb;
}

.flash-error {
  background-color: #f8d7da;
  color: #721c24;
  border-bottom: 1px solid #f5c6cb;
}

/* ===== Container ===== */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* ===== Card ===== */
.card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1.5rem;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: #111;
}

/* ===== Auth Layout ===== */
.auth-wrapper {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  min-height: calc(100vh - 56px);
}

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

.auth-toggle {
  margin-top: 1.25rem;
  text-align: center;
  font-size: 0.875rem;
  color: #555;
}

.auth-toggle a {
  color: #111;
  font-weight: 600;
  text-decoration: none;
  margin-left: 0.25rem;
}

.auth-toggle a:hover {
  text-decoration: underline;
}

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

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: #333;
}

.form-control {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 16px; /* prevents iOS zoom on focus */
  font-family: inherit;
  color: #1a1a1a;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

select.form-control {
  -webkit-appearance: auto;
  appearance: auto;
}

.form-control:focus {
  border-color: #111;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
}

.form-control::placeholder {
  color: #aaa;
}

/* ===== Input with prefix ===== */
.input-prefix-wrapper {
  display: flex;
  align-items: stretch;
  border: 1px solid #ccc;
  border-radius: 5px;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-prefix-wrapper:focus-within {
  border-color: #111;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
}

.input-prefix {
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  background: #f0f0f0;
  color: #333;
  font-weight: 600;
  font-size: 0.95rem;
  border-right: 1px solid #ccc;
  white-space: nowrap;
  user-select: none;
}

.input-with-prefix {
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 5px;
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn-primary {
  background-color: #111;
  color: #fff;
  border-color: #111;
}

.btn-primary:hover {
  background-color: #333;
  border-color: #333;
}

.btn-outline {
  background-color: transparent;
  color: #111;
  border-color: #111;
}

.btn-outline:hover {
  background-color: #111;
  color: #fff;
}

.btn-sm {
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
}

.btn-block {
  display: flex;
  width: 100%;
  margin-top: 0.5rem;
}

.btn-danger {
  background-color: #c0392b;
  color: #fff;
  border-color: #c0392b;
}

.btn-danger:hover {
  background-color: #a93226;
  border-color: #a93226;
}

/* ===== Waiting page ===== */
.text-center {
  text-align: center;
}

.waiting-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.waiting-subtitle {
  color: #444;
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}

.waiting-hint {
  color: #888;
  font-size: 0.85rem;
}

/* ===== Tables ===== */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -0.5rem;
  padding: 0 0.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead {
  background-color: #f0f0f0;
}

th {
  text-align: left;
  padding: 0.5rem 0.6rem;
  font-weight: 600;
  border-bottom: 2px solid #ddd;
  color: #333;
  white-space: nowrap;
}

td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid #eee;
  color: #444;
}

tbody tr:nth-child(even) {
  background-color: #fafafa;
}

tbody tr:hover {
  background-color: #f5f5f5;
}

/* ===== Page heading ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.page-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
}

/* ===== Badge ===== */
.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-success {
  background-color: #d4edda;
  color: #155724;
}

.badge-warning {
  background-color: #fff3cd;
  color: #856404;
}

.badge-danger {
  background-color: #f8d7da;
  color: #721c24;
}

/* ===== Page Title ===== */
.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

/* ===== Stats Cards ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.stat-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1.25rem 1rem;
  text-align: center;
}

.stat-number {
  font-size: 2rem;
  font-weight: 700;
  color: #111;
  line-height: 1;
  margin-bottom: 0.4rem;
}

.stat-label {
  font-size: 0.8rem;
  color: #666;
  font-weight: 500;
}

/* ===== Responsive ===== */
@media (min-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .stat-number {
    font-size: 2.5rem;
  }

  .stat-label {
    font-size: 0.9rem;
  }

  .card {
    padding: 2rem;
  }

  .card-title {
    font-size: 1.4rem;
  }

  table {
    font-size: 0.9rem;
  }

  th, td {
    padding: 0.6rem 0.8rem;
  }

  .page-title {
    font-size: 1.5rem;
  }
}

@media (max-width: 600px) {
  .navbar {
    padding: 0.5rem 0.75rem;
  }

  .navbar-right {
    gap: 0.5rem;
    width: 100%;
    justify-content: flex-start;
  }

  .nav-link {
    font-size: 0.8rem;
  }

  .nav-email {
    display: none;
  }

  .container {
    padding: 1rem 0.75rem;
  }

  .card {
    padding: 1rem;
    border-radius: 6px;
  }

  .card-title {
    font-size: 1.1rem;
    margin-bottom: 1rem;
  }

  .auth-wrapper {
    padding: 1.5rem 0.75rem;
    align-items: flex-start;
  }

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

  .page-title {
    font-size: 1.2rem;
    margin-bottom: 1rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .stat-card {
    padding: 1rem 0.5rem;
  }

  .stat-number {
    font-size: 1.75rem;
  }

  .stat-label {
    font-size: 0.75rem;
  }

  .btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
  }

  .btn-block {
    padding: 0.6rem 1rem;
  }

  table {
    font-size: 0.78rem;
  }

  th, td {
    padding: 0.4rem 0.5rem;
  }

  td[style*="font-family:monospace"] {
    font-size: 0.75rem;
    word-break: break-all;
  }
}
