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

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #22263a;
  --border:    #2a2d3e;
  --text:      #e8eaf0;
  --text-muted:#7b7f96;
  --accent:    #4f8ef7;
  --danger:    #f75a5a;
  --radius:    14px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

/* ── Login page ────────────────────────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 36px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-logo {
  width: 60px;
  height: 60px;
  margin: 0 auto 20px;
  color: var(--accent);
}
.login-logo svg { width: 100%; height: 100%; }

.login-card h1 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 6px;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 28px;
}

.input-group input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  padding: 12px 16px;
  outline: none;
  transition: border-color .2s;
}
.input-group input:focus { border-color: var(--accent); }
.input-group input::placeholder { color: var(--text-muted); }

.input-group--password {
  position: relative;
}
.input-group--password input {
  padding-right: 44px;
}
.toggle-password {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  display: flex;
  align-items: center;
  transition: color .2s;
}
.toggle-password:hover { color: var(--text); }
.toggle-password svg { width: 18px; height: 18px; }

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
  text-align: left;
}
.error-msg.hidden { display: none; }

.login-card button[type=submit] {
  width: 100%;
  margin-top: 16px;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .2s;
}
.login-card button[type=submit]:hover   { opacity: .88; }
.login-card button[type=submit]:disabled{ opacity: .5; cursor: default; }

/* ── Header ────────────────────────────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}
.header-logo svg { width: 24px; height: 24px; color: var(--accent); }

.header-actions { display: flex; align-items: center; gap: 4px; }

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 7px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s, background .15s;
}
.icon-btn:hover { color: var(--text); background: var(--surface2); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.small svg { width: 17px; height: 17px; }
.icon-btn.danger:hover { color: var(--danger); background: rgba(247,90,90,.1); }

/* ── Timer bar ─────────────────────────────────────────────────────────────── */
.timer-bar-wrap {
  height: 3px;
  background: var(--surface2);
  max-width: 600px;
  margin: 0 auto;
}

.timer-bar {
  height: 100%;
  background: var(--accent);
  transition: width 1s linear, background .3s;
}
.timer-bar.danger { background: var(--danger); }

/* ── Main / code list ──────────────────────────────────────────────────────── */
main {
  max-width: 600px;
  margin: 0 auto;
  padding: 12px 12px 40px;
}

.code-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

/* ── Code card ─────────────────────────────────────────────────────────────── */
.code-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: background .15s;
  user-select: none;
}
.code-item:hover { background: var(--surface2); }
.code-item:active { transform: scale(.99); }

.code-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .5px;
}

.code-info { flex: 1; min-width: 0; }

.code-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.code-issuer {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}

.code-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--accent);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.code-value.code-error { font-size: 13px; color: var(--danger); letter-spacing: normal; font-weight: 500; }

.card-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

/* ── Skeleton loading ──────────────────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position: 600px 0; }
}

.skeleton-item {
  height: 74px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface2) 50%, var(--surface) 75%);
  background-size: 600px 100%;
  animation: shimmer 1.4s infinite linear;
}

/* ── Toast ─────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 18px;
  border-radius: 100px;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
  pointer-events: none;
  transition: opacity .2s;
}
.toast.hidden { opacity: 0; }

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}
.modal-overlay.hidden { display: none; }

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 28px 24px;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-card h2 { font-size: 18px; font-weight: 600; }

.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-group label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.field-group input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color .2s;
  font-family: var(--font);
}
.field-group input:focus { border-color: var(--accent); }
.field-group input::placeholder { color: var(--text-muted); }

.modal-btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }

.btn-secondary {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 10px;
  padding: 9px 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.btn-secondary:hover { color: var(--text); border-color: var(--text-muted); background: var(--surface2); }

.btn-primary {
  background: var(--accent);
  border: none;
  color: #fff;
  border-radius: 10px;
  padding: 9px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}
.btn-primary:hover { opacity: .88; }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .code-value { font-size: 22px; letter-spacing: 2px; }
  .login-card { padding: 32px 20px; }
}
