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

:root {
  --accent:      #a78bfa;
  --accent-dim:  rgba(167,139,250,0.12);
  --accent-glow: rgba(167,139,250,0.15);
  --danger:      #f87171;
  --warning:     #fb923c;
  --warn-dim:    rgba(251,146,60,0.12);
  --success:     #4ade80;
  --bg:          #09080f;
  --bg-card:     #0e0c16;
  --bg-hover:    #141020;
  --border:      #1e1a2e;
  --text:        #ede8ff;
  --text-2:      #8a82b0;
  --text-3:      #4a4470;
  --font-mono:   'Consolas','Cascadia Code','Fira Code','Courier New',monospace;
  --font-body:   -apple-system,BlinkMacSystemFont,'Segoe UI',system-ui,sans-serif;
  --radius:      8px;
  --radius-lg:   12px;
}

html { font-size: 16px; }
body { background: var(--bg); color: var(--text); font-family: var(--font-body); line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; }

.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: linear-gradient(rgba(167,139,250,0.025) 1px,transparent 1px), linear-gradient(90deg,rgba(167,139,250,0.025) 1px,transparent 1px);
  background-size: 40px 40px;
}
.bg-glow {
  position: fixed; top: -15vh; left: 50%; transform: translateX(-50%);
  width: 70vw; height: 50vh; z-index: 0; pointer-events: none;
  background: radial-gradient(ellipse, var(--accent-glow) 0%, transparent 70%);
}

.app-layout { display: flex; flex-direction: column; min-height: 100vh; position: relative; z-index: 1; }

.site-header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem; height: 52px;
  background: rgba(9,8,15,0.94); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-left { display: flex; align-items: center; gap: 1.25rem; }
.logo { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; }
.logo-icon { font-size: 1.1rem; }
.logo-text { font-family: var(--font-mono); font-size: 0.88rem; font-weight: 600; color: var(--text); letter-spacing: 0.04em; }
.logo-sub { font-size: 0.6rem; color: var(--accent); font-family: var(--font-mono); }
.header-right { display: flex; align-items: center; gap: 0.75rem; }
.user-pill { font-size: 0.75rem; color: var(--text-3); font-family: var(--font-mono); }
.btn-logout { font-size: 0.72rem; color: var(--text-3); background: none; border: 1px solid var(--border); border-radius: 5px; padding: 0.2rem 0.55rem; cursor: pointer; transition: color 0.15s, border-color 0.15s; }
.btn-logout:hover { color: var(--danger); border-color: var(--danger); }

.main { flex: 1; padding: 2rem 1.5rem; max-width: 860px; width: 100%; margin: 0 auto; }

/* Cards */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.5rem; }
.card-title { font-family: var(--font-mono); font-size: 0.82rem; font-weight: 600; color: var(--text-2); letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 1.25rem; }

/* Form */
.form-label { display: block; font-size: 0.78rem; color: var(--text-2); margin-bottom: 0.35rem; }
.form-input { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-size: 0.88rem; padding: 0.55rem 0.75rem; transition: border-color 0.15s; outline: none; font-family: var(--font-body); }
.form-input:focus { border-color: var(--accent); }
.form-select { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-size: 0.88rem; padding: 0.55rem 0.75rem; outline: none; cursor: pointer; }
textarea.form-input { resize: vertical; min-height: 80px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.55rem 1.1rem; border-radius: var(--radius); font-size: 0.82rem; font-weight: 500; cursor: pointer; border: none; transition: opacity 0.15s, background 0.15s; text-decoration: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #09080f; }
.btn-primary:hover:not(:disabled) { opacity: 0.88; }
.btn-ghost { background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--text-3); }
.btn-danger { background: var(--danger); color: #09080f; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.78rem; }

/* QR preview */
.qr-preview {
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
  padding: 1.5rem; background: #fff; border-radius: var(--radius-lg);
  margin-top: 1.25rem;
}
.qr-preview img { max-width: 280px; width: 100%; image-rendering: pixelated; }
.qr-preview-name { color: #111; font-size: 0.85rem; font-weight: 600; text-align: center; max-width: 280px; }
.qr-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; margin-top: 0.25rem; }
.btn-dark { background: #111; color: #fff; border: none; }
.btn-dark:hover { background: #222; }

/* Size selector */
.size-pills { display: flex; gap: 0.4rem; margin-top: 0.35rem; flex-wrap: wrap; }
.size-pill { padding: 0.25rem 0.65rem; border-radius: 20px; font-size: 0.75rem; cursor: pointer; border: 1px solid var(--border); color: var(--text-2); background: none; transition: all 0.15s; }
.size-pill.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

/* Mobile view */
.mobile-header { background: var(--bg-card); border-bottom: 1px solid var(--border); padding: 1rem 1.25rem; }
.mobile-header-title { font-size: 1.15rem; font-weight: 600; color: var(--text); }
.mobile-header-sub { font-size: 0.78rem; color: var(--text-3); margin-top: 0.15rem; }
.mobile-badge { display: inline-block; padding: 0.18rem 0.55rem; border-radius: 20px; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.badge-active   { background: rgba(74,222,128,0.12); color: #4ade80; border: 1px solid rgba(74,222,128,0.25); }
.badge-inactive { background: var(--bg-hover); color: var(--text-3); border: 1px solid var(--border); }
.badge-retired  { background: rgba(248,113,113,0.12); color: var(--danger); border: 1px solid rgba(248,113,113,0.25); }
.badge-maintenance { background: var(--warn-dim); color: var(--warning); border: 1px solid rgba(251,146,60,0.25); }
.mobile-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 1rem; padding: 1.25rem; }
.mobile-field-label { font-size: 0.7rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.15rem; }
.mobile-field-value { font-size: 0.88rem; color: var(--text); word-break: break-word; }
.mobile-field-full { grid-column: 1 / -1; }
.mobile-notes { padding: 0 1.25rem 1.25rem; }
.mobile-notes-text { font-size: 0.83rem; color: var(--text-2); white-space: pre-wrap; }
.mobile-log-btn { display: block; width: calc(100% - 2.5rem); margin: 0 1.25rem 1.25rem; padding: 0.85rem; text-align: center; font-size: 1rem; font-weight: 600; background: var(--accent); color: #09080f; border: none; border-radius: var(--radius); cursor: pointer; }
.mobile-services { padding: 0 1.25rem 1.25rem; }
.mobile-services-title { font-size: 0.75rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.75rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.svc-row { padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.svc-row:last-child { border-bottom: none; }
.svc-row-date { font-size: 0.75rem; color: var(--text-3); }
.svc-row-desc { font-size: 0.85rem; color: var(--text); margin-top: 0.1rem; }
.svc-row-by   { font-size: 0.73rem; color: var(--text-3); margin-top: 0.1rem; }

/* Log service modal */
.modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 200; align-items: flex-end; }
.modal-backdrop.open { display: flex; }
.modal-sheet { background: var(--bg-card); border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: 1.5rem; width: 100%; border-top: 1px solid var(--border); max-height: 90vh; overflow-y: auto; }
.modal-sheet-title { font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: 1.25rem; }
.form-row { margin-bottom: 1rem; }
.modal-actions { display: flex; gap: 0.5rem; margin-top: 1.25rem; }
.status-msg { font-size: 0.8rem; margin-top: 0.75rem; padding: 0.45rem 0.75rem; border-radius: var(--radius); }
.status-ok    { background: rgba(74,222,128,0.1); color: #4ade80; border: 1px solid rgba(74,222,128,0.2); }
.status-error { background: rgba(248,113,113,0.1); color: var(--danger); border: 1px solid rgba(248,113,113,0.2); }
.hidden { display: none !important; }
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: flex; justify-content: center; align-items: center; padding: 3rem; }

/* Label page */
@media screen {
  .label-page { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; gap: 1.5rem; padding: 2rem; }
  .label-card { background: #fff; color: #111; border-radius: var(--radius-lg); padding: 1.5rem 2rem; display: flex; flex-direction: column; align-items: center; gap: 0.75rem; box-shadow: 0 4px 24px rgba(0,0,0,0.4); }
  .label-card img { width: 220px; height: 220px; }
  .label-name { font-size: 1rem; font-weight: 700; color: #111; text-align: center; max-width: 220px; }
  .label-sub  { font-size: 0.72rem; color: #555; text-align: center; max-width: 220px; }
  .label-actions { display: flex; gap: 0.75rem; }
}
@media print {
  body { background: #fff !important; }
  .label-actions, .site-header, .bg-grid, .bg-glow { display: none !important; }
  .label-page { margin: 0; padding: 0; min-height: unset; }
  .label-card { box-shadow: none; border: none; padding: 0.5rem; }
  .label-card img { width: 180px; height: 180px; }
  .label-name { font-size: 0.9rem; }
  .label-sub  { font-size: 0.65rem; }
}

/* Auth / login layout */
.auth-layout { display: grid; grid-template-columns: 1fr 420px; flex: 1 0 auto; min-height: 0; width: 100%; max-width: 1360px; margin: 0 auto; padding: 3rem 2rem; gap: 0 4rem; align-items: start; align-content: start; position: relative; z-index: 1; }
.auth-hero { display: contents; }
.auth-logo { grid-column: 1; display: flex; align-items: center; gap: 0.6rem; text-decoration: none; margin-bottom: 2.5rem; }
.auth-logo-name { font-size: 1rem; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.auth-logo-sub { color: var(--text-3); font-weight: 400; }
.auth-tagline { grid-column: 1; }
.auth-tagline h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); font-weight: 800; line-height: 1.15; letter-spacing: -0.03em; color: var(--text); margin-bottom: 0.75rem; }
.auth-tagline p { font-size: 1rem; color: var(--text-2); line-height: 1.6; max-width: 40ch; }
.auth-right { grid-column: 2; grid-row: 3; margin-top: 2.5rem; display: flex; flex-direction: column; }
.auth-card-wrap { flex: 1; display: flex; align-items: flex-start; padding: 0 0 3rem; }
.auth-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 2rem; width: 100%; }
.auth-card-title { font-size: 1.1rem; font-weight: 700; color: var(--text); margin-bottom: 1.5rem; letter-spacing: -0.01em; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-card-footer { margin-top: 1.25rem; font-size: 0.82rem; color: var(--text-3); text-align: center; }
.auth-link { color: var(--accent); text-decoration: none; }
.auth-link:hover { text-decoration: underline; }
.auth-footer { padding: 1.25rem 0; border-top: 1px solid var(--border); text-align: center; }
.auth-footer-line { font-size: 0.78rem; color: var(--text-3); margin-bottom: 0.4rem; }
.auth-footer-line a { color: inherit; text-decoration: none; }
.auth-footer-links { display: flex; align-items: center; justify-content: center; gap: 0.5rem; }
.auth-footer-link { font-size: 0.78rem; color: var(--accent); text-decoration: none; display: inline-flex; align-items: center; gap: 3px; }
.auth-footer-link:hover { opacity: 0.75; }
.auth-footer-sep { color: var(--text-3); }
.auth-preview { grid-column: 1; margin-top: 2.5rem; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--bg-card); box-shadow: 0 8px 40px rgba(0,0,0,0.5); position: relative; }
.auth-preview::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 60px; background: linear-gradient(transparent, var(--bg-card)); pointer-events: none; z-index: 1; }
.auth-preview-bar { background: rgba(0,0,0,0.35); border-bottom: 1px solid var(--border); padding: 0.5rem 0.75rem; display: flex; align-items: center; gap: 0.5rem; }
.auth-preview-dots { display: flex; gap: 5px; }
.auth-preview-dots span { width: 9px; height: 9px; border-radius: 50%; display: block; }
.auth-preview-dots span:nth-child(1) { background: #ef4444; }
.auth-preview-dots span:nth-child(2) { background: #f59e0b; }
.auth-preview-dots span:nth-child(3) { background: #22c55e; }
.auth-preview-addr { flex: 1; text-align: center; font-size: 0.68rem; color: var(--text-3); font-family: var(--font-mono); }
.auth-preview-body { padding: 0.85rem; }
.notice { font-size: 0.82rem; padding: 0.55rem 0.75rem; border-radius: var(--radius); margin-bottom: 0.75rem; }
.notice-danger { background: rgba(248,113,113,0.1); color: var(--danger); border: 1px solid rgba(248,113,113,0.2); }

@media (max-width: 700px) {
  .auth-layout { grid-template-columns: 1fr; max-width: 480px; padding: 0 1.25rem; }
  .auth-hero { display: flex; flex-direction: column; padding: 2rem 0 0.5rem; }
  .auth-logo { grid-column: unset; }
  .auth-tagline { grid-column: unset; }
  .auth-preview { display: none; }
  .auth-right { grid-column: 1; grid-row: auto; margin-top: 0; }
  .auth-card-wrap { padding: 1.25rem 0 1.5rem; align-items: center; }
}
