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

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  min-height: 100vh;
  padding: 1rem;
}

.container {
  max-width: 900px;
  margin: 0 auto;
}

header {
  margin-bottom: 1.5rem;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #f8fafc;
}

.subtitle {
  color: #94a3b8;
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.add-form {
  background: #1e293b;
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.add-form h2,
.users-list h2 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: #cbd5e1;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.filter-label {
  font-size: 0.85rem;
  color: #94a3b8;
  margin-right: 0.25rem;
}

.filter-btn {
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0f172a;
  color: #94a3b8;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.filter-btn:hover {
  background: #334155;
  color: #e2e8f0;
}

.filter-btn.active {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

form input {
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 1rem;
  width: 100%;
  min-width: 0;
}

form input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

form button {
  padding: 0.65rem 1.2rem;
  border-radius: 8px;
  border: none;
  background: #3b82f6;
  color: white;
  font-weight: 600;
  cursor: pointer;
  font-size: 1rem;
  width: 100%;
}

form button:hover {
  background: #2563eb;
}

form button:active {
  transform: scale(0.98);
}

.btn-excel {
  background: rgba(34, 197, 94, 0.2) !important;
  color: #4ade80 !important;
}

.btn-excel:hover {
  background: rgba(34, 197, 94, 0.35) !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal[aria-hidden="true"] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  cursor: pointer;
}

.modal-content {
  position: relative;
  background: #1e293b;
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-content h3 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: #f8fafc;
}

.modal-step {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.modal-hint {
  font-size: 0.9rem;
  color: #94a3b8;
}

.modal-step input[type="password"],
.modal-step input[type="text"] {
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 1rem;
}

.modal-step input[type="file"] {
  padding: 0.5rem;
  font-size: 0.9rem;
  color: #94a3b8;
}

.modal-step button {
  padding: 0.65rem 1rem;
  border-radius: 8px;
  border: none;
  background: #3b82f6;
  color: white;
  font-weight: 600;
  cursor: pointer;
}

.modal-step button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.modal-msg {
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.modal-msg.success { color: #22c55e; }
.modal-msg.error { color: #ef4444; }

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: #e2e8f0;
}

.msg {
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.msg.success { color: #22c55e; }
.msg.error { color: #ef4444; }

.users-list {
  background: #1e293b;
  border-radius: 12px;
  padding: 1rem;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -0.5rem;
}

table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #334155;
}

th {
  font-size: 0.75rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

tr:hover td {
  background: rgba(15, 23, 42, 0.5);
}

td code {
  font-size: 0.85em;
  word-break: break-all;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
}

.badge.used {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.badge.unused {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
}

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

.actions button {
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  border: none;
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 500;
}

.btn-reset {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
}

.btn-reset:hover {
  background: rgba(59, 130, 246, 0.35);
}

.btn-delete {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.btn-delete:hover {
  background: rgba(239, 68, 68, 0.35);
}

.empty {
  color: #64748b;
  padding: 1.5rem;
  text-align: center;
}

/* ——— Tablet (576px+) ——— */
@media (min-width: 576px) {
  body {
    padding: 1.25rem;
  }

  header h1 {
    font-size: 1.6rem;
  }

  .add-form,
  .users-list {
    padding: 1.25rem;
  }

  form {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
  }

  form input {
    width: auto;
    min-width: 140px;
    flex: 1;
    max-width: 220px;
  }

  form button {
    width: auto;
  }

  th,
  td {
    padding: 0.7rem 0.9rem;
  }

  th {
    font-size: 0.78rem;
  }
}

/* ——— Desktop (992px+) ——— */
@media (min-width: 992px) {
  body {
    padding: 1.5rem;
  }

  header {
    margin-bottom: 2rem;
  }

  header h1 {
    font-size: 1.75rem;
  }

  .subtitle {
    font-size: 0.95rem;
  }

  .add-form {
    padding: 1.5rem;
    margin-bottom: 2rem;
  }

  .add-form h2,
  .users-list h2 {
    font-size: 1rem;
    margin-bottom: 1rem;
  }

  .users-list {
    padding: 1.5rem;
  }

  form input {
    min-width: 180px;
    max-width: none;
  }

  th,
  td {
    padding: 0.75rem 1rem;
  }

  th {
    font-size: 0.8rem;
  }
}

/* ——— Mobile touch ——— */
@media (hover: none) {
  form button:hover {
    background: #3b82f6;
  }

  .btn-reset:hover,
  .btn-delete:hover {
    opacity: 0.9;
  }
}
