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

body {
  background: #0c0707;
  color: #e8e0e0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
}

/* ---- Views ---- */
.view { display: none; width: 100%; }
.view.active { display: flex; flex-direction: column; align-items: center; }

/* ---- Landing ---- */
.landing-card {
  background: #171010;
  border: 1px solid #2a1515;
  border-radius: 14px;
  padding: 60px 40px;
  width: 100%;
  max-width: 520px;
  text-align: center;
}

.logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 32px;
}

.logo-wrap img {
  height: 42px;
  width: auto;
}

.landing-card h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #e8e0e0;
  margin-bottom: 12px;
}

.landing-card p {
  font-size: 14px;
  color: #a07070;
  margin-bottom: 36px;
  line-height: 1.5;
}

/* ---- Auth Form ---- */
.auth-form {
  width: 100%;
  max-width: 340px;
  margin: 0 auto;
  text-align: left;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 1px solid #2a1515;
}

.auth-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: #7a5555;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 10px 0;
  cursor: pointer;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.auth-tab.active {
  color: #d71920;
  border-bottom-color: #d71920;
}

.auth-tab:hover { color: #e8e0e0; }

.auth-fields .modal-field { margin-bottom: 14px; }

.btn-microsoft {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #2f2f2f;
  color: #fff;
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  padding: 12px 28px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
}

.btn-microsoft:hover { background: #404040; }
.btn-microsoft:active { background: #1a1a1a; }

.btn-microsoft svg {
  width: 20px;
  height: 20px;
}

/* ---- Dashboard ---- */
.dash-header {
  width: 100%;
  max-width: 960px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  padding-bottom: 16px;
  border-bottom: 1px solid #2a1515;
}

.dash-header .logo-wrap {
  margin-bottom: 0;
}

.dash-user {
  display: flex;
  align-items: center;
  gap: 16px;
}

.dash-user-email {
  font-size: 13px;
  color: #a07070;
}

.btn-logout {
  background: transparent;
  color: #a07070;
  border: 1px solid #3a2020;
  border-radius: 6px;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  font-family: inherit;
}

.btn-logout:hover { border-color: #d71920; color: #e8e0e0; }

/* ---- Create QR Section ---- */
.create-section {
  width: 100%;
  max-width: 960px;
  background: #171010;
  border: 1px solid #2a1515;
  border-radius: 14px;
  padding: 28px 32px;
  margin-bottom: 32px;
}

.create-section h2 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #d71920;
  margin-bottom: 20px;
}

.create-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.create-field {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.field-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #a07070;
  margin-bottom: 8px;
}

.url-input, .title-input {
  width: 100%;
  background: #1e1010;
  border: 1px solid #3a2020;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 14px;
  color: #e8e0e0;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.url-input::placeholder, .title-input::placeholder { color: #5a3535; }
.url-input:focus, .title-input:focus { border-color: #d71920; }

.btn-create {
  background: #d71920;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
  white-space: nowrap;
}

.btn-create:hover { background: #ff2d35; }
.btn-create:active { background: #b5141a; }

.error-msg {
  margin-top: 10px;
  font-size: 13px;
  color: #ff6b6f;
  min-height: 18px;
}

/* ---- QR List ---- */
.qr-list-section {
  width: 100%;
  max-width: 960px;
}

.qr-list-section h2 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #e8e0e0;
  margin-bottom: 20px;
}

.qr-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.qr-card {
  background: #171010;
  border: 1px solid #2a1515;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.qr-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.qr-card-title {
  font-size: 16px;
  font-weight: 600;
  color: #e8e0e0;
  word-break: break-word;
}

.qr-card-clicks {
  font-size: 12px;
  color: #a07070;
  background: #1e1010;
  border-radius: 12px;
  padding: 4px 10px;
  white-space: nowrap;
}

.qr-card-short {
  font-size: 13px;
  color: #d71920;
  font-weight: 600;
  word-break: break-all;
}

.qr-card-dest {
  font-size: 12px;
  color: #7a5555;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qr-card-preview {
  display: flex;
  justify-content: center;
  padding: 8px 0;
}

.qr-card-preview canvas {
  border-radius: 4px;
}

/* ---- Style Picker ---- */
.qr-style-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.style-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.style-swatch {
  width: 28px;
  height: 28px;
  padding: 3px;
  border: 2px solid #3a2020;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  transition: border-color 0.2s;
}

.style-swatch span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 3px;
}

.style-swatch:hover { border-color: #a07070; }
.style-swatch.active { border-color: #d71920; }

.style-transparent {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #7a5555;
  cursor: pointer;
  margin-left: 4px;
  user-select: none;
}

.style-transparent input[type="checkbox"] {
  accent-color: #d71920;
  cursor: pointer;
}

.text-label-input {
  flex: 1;
  min-width: 0;
  background: #1e1010;
  border: 1px solid #3a2020;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
  color: #e8e0e0;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}

.text-label-input::placeholder { color: #5a3535; }
.text-label-input:focus { border-color: #d71920; }

.size-toggle {
  display: flex;
  gap: 0;
  border: 1px solid #3a2020;
  border-radius: 6px;
  overflow: hidden;
}

.size-btn {
  background: transparent;
  border: none;
  color: #7a5555;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, color 0.2s;
}

.size-btn:not(:last-child) {
  border-right: 1px solid #3a2020;
}

.size-btn:hover { color: #e8e0e0; }
.size-btn.active { background: #d71920; color: #fff; }

.text-color-input {
  width: 28px;
  height: 28px;
  border: 1px solid #3a2020;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  padding: 2px;
}

.text-color-input::-webkit-color-swatch-wrapper { padding: 0; }
.text-color-input::-webkit-color-swatch { border: none; border-radius: 3px; }

.qr-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-sm {
  background: transparent;
  color: #a07070;
  border: 1px solid #3a2020;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  font-family: inherit;
}

.btn-sm:hover { border-color: #d71920; color: #e8e0e0; }

.btn-sm.danger:hover { border-color: #ff6b6f; color: #ff6b6f; }

.empty-state {
  text-align: center;
  color: #5a3535;
  font-size: 14px;
  padding: 40px;
}

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

.modal-overlay.hidden { display: none; }

.modal {
  background: #171010;
  border: 1px solid #2a1515;
  border-radius: 14px;
  padding: 32px;
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal h3 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #e8e0e0;
  margin-bottom: 24px;
}

.modal-field {
  margin-bottom: 16px;
}

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

.btn-save {
  background: #d71920;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 24px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  font-family: inherit;
}

.btn-save:hover { background: #ff2d35; }

.btn-cancel {
  background: transparent;
  color: #a07070;
  border: 1px solid #3a2020;
  border-radius: 8px;
  padding: 10px 24px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-cancel:hover { border-color: #d71920; color: #e8e0e0; }

/* ---- Stats ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-box {
  background: #1e1010;
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: #d71920;
}

.stat-label {
  font-size: 11px;
  color: #7a5555;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
}

.clicks-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.clicks-table th {
  text-align: left;
  color: #a07070;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
  padding: 8px 6px;
  border-bottom: 1px solid #2a1515;
}

.clicks-table td {
  padding: 8px 6px;
  color: #e8e0e0;
  border-bottom: 1px solid #1e1010;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Loading ---- */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #3a2020;
  border-top-color: #d71920;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-center {
  display: flex;
  justify-content: center;
  padding: 40px;
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
  body { padding: 20px 12px; }

  .landing-card { padding: 40px 24px; }

  .create-row {
    flex-direction: column;
    align-items: stretch;
  }

  .create-section { padding: 20px; }

  .qr-list {
    grid-template-columns: 1fr;
  }

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

  .dash-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
}
