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

:root {
  --nomentia-charcoal: #3a3a3a;
  --nomentia-gold: #d4b84f;
  --nomentia-gold-light: #e8d68a;
  --nomentia-gold-dark: #b89a2e;
  --bg: #f4f5f7;
  --card-bg: #ffffff;
  --text-primary: #1a1a1a;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border: #e5e7eb;
  --success: #10b981;
  --error: #ef4444;
  --error-bg: #fef2f2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* === Header === */
.header {
  background: var(--nomentia-charcoal);
  color: #fff;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-logo {
  height: 28px;
  width: auto;
}

.header-title {
  font-size: 15px;
  font-weight: 500;
  opacity: 0.85;
  padding-left: 16px;
  border-left: 1px solid rgba(255,255,255,0.2);
}

.header-user {
  font-size: 13px;
  opacity: 0.75;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-user::before {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  display: inline-block;
}

/* === Main === */
.main {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px;
}

/* === Utility === */
.hidden { display: none !important; }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--nomentia-gold);
  color: var(--nomentia-charcoal);
}

.btn-primary:hover {
  background: var(--nomentia-gold-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--card-bg);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card-bg);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.btn-icon:hover {
  background: #f3f4f6;
  color: var(--text-primary);
  border-color: #d1d5db;
}

/* === Login Card === */
.login-card {
  max-width: 420px;
  margin: 80px auto;
  text-align: center;
  padding: 48px 32px;
}

.card-icon {
  color: var(--nomentia-gold);
  margin-bottom: 16px;
}

.login-card h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.login-card p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
  line-height: 1.5;
}

/* === Cards === */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 24px;
}

/* === Welcome Bar === */
.welcome-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.welcome-bar h1 {
  font-size: 24px;
  font-weight: 700;
}

.welcome-sub {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

/* === Loading === */
.loading-card {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--nomentia-gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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

/* === Error Card === */
.error-card {
  text-align: center;
  padding: 32px;
  color: var(--error);
  background: var(--error-bg);
  border-color: #fecaca;
}

.error-card p {
  margin: 12px 0 16px;
  color: var(--text-primary);
}

/* === Empty State === */
.empty-card {
  text-align: center;
  padding: 48px 32px;
  color: var(--text-secondary);
}

.empty-card h3 {
  color: var(--text-primary);
  margin: 16px 0 8px;
}

.empty-card p {
  font-size: 14px;
  line-height: 1.5;
}

/* === Device Grid === */
.device-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

/* === Device Card === */
.device-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.device-card:hover {
  box-shadow: var(--shadow-lg);
}

.device-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.device-icon {
  width: 42px;
  height: 42px;
  background: #f3f4f6;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--nomentia-charcoal);
  flex-shrink: 0;
}

.device-name {
  font-size: 16px;
  font-weight: 600;
}

.device-os {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.device-card-body {
  padding: 20px 24px;
}

.device-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.meta-item {
  font-size: 12px;
}

.meta-label {
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
  margin-bottom: 2px;
}

.meta-value {
  color: var(--text-primary);
  font-weight: 500;
  font-size: 13px;
}

/* === Password Section === */
.password-section {
  background: #f9fafb;
  border-radius: var(--radius-sm);
  padding: 16px;
  border: 1px solid var(--border);
}

.password-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 4px;
}

.password-account {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

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

.password-value {
  flex: 1;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  padding: 8px 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  user-select: all;
}

.password-masked {
  color: var(--text-muted);
  letter-spacing: 3px;
}

/* === Countdown Ring === */
.countdown-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.countdown-ring {
  width: 20px;
  height: 20px;
  position: relative;
}

.countdown-ring svg {
  transform: rotate(-90deg);
}

.countdown-ring circle {
  fill: none;
  stroke-width: 2.5;
}

.countdown-ring .ring-bg {
  stroke: var(--border);
}

.countdown-ring .ring-fg {
  stroke: var(--nomentia-gold);
  stroke-dasharray: 44;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear;
}

/* === Error in device card === */
.laps-error {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  padding: 8px 0;
}

/* === Toast === */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--nomentia-charcoal);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1000;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* === Footer === */
.footer {
  text-align: center;
  padding: 20px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* === Responsive === */
@media (max-width: 640px) {
  .header-title { display: none; }
  .welcome-bar { flex-direction: column; align-items: flex-start; }
  .device-meta { grid-template-columns: 1fr; }
  .main { padding: 20px 16px; }
}
