/* ===== PORTFOLIO TRACKER — DESIGN SYSTEM ===== */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=Space+Mono:wght@400;700&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;1,9..40,300&display=swap');

:root {
  --font-display: 'Syne', sans-serif;
  --font-mono: 'Space Mono', monospace;
  --font-body: 'DM Sans', sans-serif;

  --c-bg: #0a0a0f;
  --c-bg-surface: #111118;
  --c-bg-raised: #18181f;
  --c-bg-hover: #1e1e28;
  --c-border: rgba(255,255,255,0.07);
  --c-border-md: rgba(255,255,255,0.12);
  --c-border-accent: rgba(99,102,241,0.4);

  --c-text-primary: #f0f0f8;
  --c-text-secondary: #8888aa;
  --c-text-muted: #55556a;

  --c-accent: #6366f1;
  --c-accent-hover: #7c7ff5;
  --c-accent-glow: rgba(99,102,241,0.15);

  --c-green: #22d3a0;
  --c-green-bg: rgba(34,211,160,0.08);
  --c-red: #f43f5e;
  --c-red-bg: rgba(244,63,94,0.08);
  --c-amber: #f59e0b;
  --c-amber-bg: rgba(245,158,11,0.08);
  --c-blue: #38bdf8;
  --c-blue-bg: rgba(56,189,248,0.08);
  --c-purple: #a78bfa;
  --c-purple-bg: rgba(167,139,250,0.08);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-card: 0 1px 0 0 rgba(255,255,255,0.04) inset, 0 -1px 0 0 rgba(0,0,0,0.3) inset;
  --shadow-glow: 0 0 40px rgba(99,102,241,0.08);

  --transition: 0.18s ease;
}

/* ===== LIGHT MODE ===== */
[data-theme="light"] {
  --c-bg:           #f4f5f7;
  --c-bg-surface:   #ffffff;
  --c-bg-raised:    #eef0f3;
  --c-bg-hover:     #e8eaed;
  --c-border:       rgba(0,0,0,0.08);
  --c-border-md:    rgba(0,0,0,0.14);
  --c-border-accent:rgba(99,102,241,0.35);

  --c-text-primary:   #111827;
  --c-text-secondary: #4b5563;
  --c-text-muted:     #9ca3af;

  --c-accent:       #5254cc;
  --c-accent-hover: #4345b0;
  --c-accent-glow:  rgba(99,102,241,0.10);

  --c-green:    #059669;
  --c-green-bg: rgba(5,150,105,0.08);
  --c-red:      #dc2626;
  --c-red-bg:   rgba(220,38,38,0.08);
  --c-amber:    #d97706;
  --c-amber-bg: rgba(217,119,6,0.08);
  --c-blue:     #2563eb;
  --c-blue-bg:  rgba(37,99,235,0.08);
  --c-purple:   #7c3aed;
  --c-purple-bg:rgba(124,58,237,0.08);

  --shadow-card: 0 1px 3px rgba(0,0,0,0.08), 0 1px 0 rgba(0,0,0,0.04);
  --shadow-glow: 0 0 40px rgba(99,102,241,0.06);
}

/* Light mode: noise overlay lighter */
[data-theme="light"] body::before { opacity: 0.15; }

/* Light mode: grid lines darker */
[data-theme="light"] .grid-bg {
  background-image:
    linear-gradient(rgba(0,0,0,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.04) 1px, transparent 1px);
}

/* Light mode: orbs lighter */
[data-theme="light"] .orb-1 { background: rgba(99,102,241,0.07); }
[data-theme="light"] .orb-2 { background: rgba(5,150,105,0.05); }

/* Light mode: scrollbar */
[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.18); }
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.28); }

/* Light mode: nav blur */
[data-theme="light"] nav { background: rgba(244,245,247,0.9); }

/* Light mode: sidebar */
[data-theme="light"] .sidebar { background: #ffffff; }

/* Light mode: select/input arrows need fixing */
[data-theme="light"] .form-select,
[data-theme="light"] .form-input { color: var(--c-text-primary); }

/* Light mode: Chart.js canvas — white bg for better readability */
[data-theme="light"] canvas { filter: none; }

/* Theme toggle button */
.theme-toggle {
  width: 36px; height: 20px;
  background: var(--c-bg-raised);
  border: 1px solid var(--c-border-md);
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  transition: background 0.25s ease;
  flex-shrink: 0;
}
.theme-toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--c-text-muted);
  transition: transform 0.25s cubic-bezier(.4,0,.2,1), background 0.25s;
}
[data-theme="light"] .theme-toggle { background: #dde1ff; border-color: #b4baff; }
[data-theme="light"] .theme-toggle::after { transform: translateX(16px); background: var(--c-accent); }

.theme-toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--c-text-muted);
}
.theme-toggle-wrap .icon { font-size: 0.8rem; line-height: 1; }

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--c-bg);
  color: var(--c-text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== NOISE TEXTURE OVERLAY ===== */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  opacity: 0.4;
}

/* ===== GRID BACKGROUND ===== */
.grid-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(99,102,241,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99,102,241,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  z-index: 0;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5 { font-family: var(--font-display); letter-spacing: -0.02em; }
h1 { font-size: clamp(2rem, 4vw, 3.5rem); font-weight: 700; }
h2 { font-size: clamp(1.4rem, 2.5vw, 2rem); font-weight: 600; }
h3 { font-size: 1.2rem; font-weight: 600; }

.mono { font-family: var(--font-mono); }

/* ===== LAYOUT ===== */
.container { max-width: 1400px; margin: 0 auto; padding: 0 2rem; }
.container-sm { max-width: 560px; margin: 0 auto; padding: 0 1.5rem; }

/* ===== NAVIGATION ===== */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10,10,15,0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--c-border);
  padding: 0 2rem;
}

.nav-inner {
  max-width: 1400px;
  margin: 0 auto;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 2rem;
}

.nav-logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--c-text-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.nav-logo .logo-icon {
  width: 28px; height: 28px;
  background: var(--c-accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}

.nav-links { display: flex; gap: 0.25rem; flex: 1; }

.nav-link {
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--c-text-secondary);
  text-decoration: none;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  display: flex; align-items: center; gap: 0.4rem;
  white-space: nowrap;
}

.nav-link:hover { color: var(--c-text-primary); background: var(--c-bg-hover); }
.nav-link.active { color: var(--c-text-primary); background: var(--c-bg-raised); }
.nav-link svg { width: 15px; height: 15px; }

.nav-actions { display: flex; align-items: center; gap: 0.75rem; margin-left: auto; }

/* ===== BUTTONS ===== */
.btn {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--c-accent);
  color: #fff;
}
.btn-primary:hover { background: var(--c-accent-hover); transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  color: var(--c-text-secondary);
  border-color: var(--c-border-md);
}
.btn-ghost:hover { color: var(--c-text-primary); background: var(--c-bg-raised); }

.btn-danger {
  background: var(--c-red-bg);
  color: var(--c-red);
  border-color: rgba(244,63,94,0.2);
}
.btn-danger:hover { background: rgba(244,63,94,0.15); }

.btn-sm { padding: 0.35rem 0.85rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 2rem; font-size: 1rem; }
.btn svg { width: 16px; height: 16px; }

/* ===== CARDS ===== */
.card {
  background: var(--c-bg-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1.5rem;
  transition: border-color var(--transition), transform var(--transition);
}

.card:hover { border-color: var(--c-border-md); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.card-title {
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--c-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ===== STAT CARDS ===== */
.stat-card {
  background: var(--c-bg-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-card);
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--c-text-primary);
  line-height: 1.2;
}

.stat-change {
  font-size: 0.8rem;
  margin-top: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.stat-change.up { color: var(--c-green); }
.stat-change.down { color: var(--c-red); }
.stat-change svg { width: 12px; height: 12px; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
}

.badge-green { background: var(--c-green-bg); color: var(--c-green); }
.badge-red { background: var(--c-red-bg); color: var(--c-red); }
.badge-blue { background: var(--c-blue-bg); color: var(--c-blue); }
.badge-amber { background: var(--c-amber-bg); color: var(--c-amber); }
.badge-purple { background: var(--c-purple-bg); color: var(--c-purple); }
.badge-gray { background: rgba(255,255,255,0.06); color: var(--c-text-secondary); }

/* ===== FORMS ===== */
.form-group { margin-bottom: 1.25rem; }
.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--c-text-secondary);
  margin-bottom: 0.5rem;
  letter-spacing: 0.03em;
}

.form-input {
  width: 100%;
  background: var(--c-bg-raised);
  border: 1px solid var(--c-border-md);
  border-radius: var(--radius-md);
  color: var(--c-text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 0.65rem 1rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px var(--c-accent-glow);
}

.form-input::placeholder { color: var(--c-text-muted); }

.form-select {
  width: 100%;
  background: var(--c-bg-raised);
  border: 1px solid var(--c-border-md);
  border-radius: var(--radius-md);
  color: var(--c-text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 0.65rem 1rem;
  outline: none;
  cursor: pointer;
  appearance: none;
  transition: border-color var(--transition);
}
.form-select:focus { border-color: var(--c-accent); }

.form-hint { font-size: 0.75rem; color: var(--c-text-muted); margin-top: 0.4rem; }
.form-error { font-size: 0.75rem; color: var(--c-red); margin-top: 0.4rem; }

/* ===== TABS ===== */
.tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--c-bg-raised);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 3px;
}

.tab {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--c-text-secondary);
  background: transparent;
  border: none;
  padding: 0.4rem 0.9rem;
  border-radius: 7px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.tab.active {
  background: var(--c-bg-hover);
  color: var(--c-text-primary);
}

.tab:hover:not(.active) { color: var(--c-text-primary); }

/* ===== TABLE ===== */
.table-wrapper { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

th {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}

td {
  padding: 0.875rem 1rem;
  font-size: 0.875rem;
  color: var(--c-text-primary);
  border-bottom: 1px solid var(--c-border);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--c-bg-raised); }

/* ===== ALERTS ===== */
.alert {
  padding: 0.875rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--c-green-bg); color: var(--c-green); border: 1px solid rgba(34,211,160,0.15); }
.alert-error { background: var(--c-red-bg); color: var(--c-red); border: 1px solid rgba(244,63,94,0.15); }
.alert-info { background: var(--c-blue-bg); color: var(--c-blue); border: 1px solid rgba(56,189,248,0.15); }
.alert-warning { background: var(--c-amber-bg); color: var(--c-amber); border: 1px solid rgba(245,158,11,0.15); }

/* ===== SIDEBAR ===== */
.layout { display: flex; min-height: calc(100vh - 64px); }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--c-bg-surface);
  border-right: 1px solid var(--c-border);
  padding: 1.5rem 1rem;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
}

.sidebar-section { margin-bottom: 1.75rem; }

.sidebar-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0 0.5rem;
  margin-bottom: 0.5rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--c-text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  transition: all var(--transition);
  margin-bottom: 2px;
}

.sidebar-link:hover { color: var(--c-text-primary); background: var(--c-bg-hover); }
.sidebar-link.active { color: var(--c-text-primary); background: var(--c-bg-raised); }
.sidebar-link svg { width: 16px; height: 16px; flex-shrink: 0; }

.main-content { flex: 1; padding: 2rem; min-width: 0; }

/* ===== GLOW ORBS ===== */
.orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
}
.orb-1 { width: 600px; height: 600px; background: rgba(99,102,241,0.06); top: -200px; right: -100px; }
.orb-2 { width: 400px; height: 400px; background: rgba(34,211,160,0.04); bottom: 0; left: 100px; }

/* ===== PAGE WRAPPER ===== */
.page-wrapper { position: relative; z-index: 1; }

/* ===== CHART PERIOD SELECTOR ===== */
.period-selector {
  display: flex;
  gap: 0.15rem;
}

.period-btn {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--c-text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.period-btn.active, .period-btn:hover { color: var(--c-text-primary); background: var(--c-bg-hover); }

/* ===== TOAST ===== */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--c-bg-raised);
  border: 1px solid var(--c-border-md);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.1rem;
  font-size: 0.875rem;
  color: var(--c-text-primary);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: slideIn 0.2s ease;
  max-width: 360px;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ===== SPINNER ===== */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--c-border-md);
  border-top-color: var(--c-accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-border-md); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--c-text-muted); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--c-bg-surface);
  border: 1px solid var(--c-border-md);
  border-radius: var(--radius-xl);
  padding: 2rem;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform var(--transition);
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

/* ===== UTILITY ===== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--c-text-secondary); }
.text-green { color: var(--c-green); }
.text-red { color: var(--c-red); }
.text-right { text-align: right; }
.hidden { display: none !important; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .container { padding: 0 1rem; }
  .main-content { padding: 1rem; }
}

/* Light mode: nav logo text readable */
[data-theme="light"] .nav-logo { color: var(--c-text-primary); }
[data-theme="light"] .nav-link { color: var(--c-text-secondary); }
[data-theme="light"] .nav-link:hover { color: var(--c-text-primary); }

/* ===== PWA / MOBILE OPTIMIERUNGEN ===== */

/* Safe area für iPhone Notch / Dynamic Island */
body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Mobile Bottom Navigation (PWA) */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: rgba(10,10,15,0.95);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--c-border);
  padding: 0.5rem 0 calc(0.5rem + env(safe-area-inset-bottom));
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
}

.mobile-bottom-nav .mob-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.4rem 0.5rem;
  text-decoration: none;
  color: var(--c-text-muted);
  font-size: 0.6rem;
  font-weight: 500;
  transition: color var(--transition);
  letter-spacing: 0.03em;
}
.mobile-bottom-nav .mob-link.active { color: var(--c-accent); }
.mobile-bottom-nav .mob-link svg { width: 22px; height: 22px; }

/* Pull-to-refresh indicator */
.ptr-indicator {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--c-accent), var(--c-green));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
  z-index: 9999;
}
.ptr-indicator.loading { transform: scaleX(1); animation: ptrPulse 1s ease-in-out infinite; }
@keyframes ptrPulse { 0%,100%{opacity:1}50%{opacity:0.5} }

/* Offline banner */
.offline-banner {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--c-amber-bg);
  border-bottom: 1px solid rgba(245,158,11,.3);
  color: var(--c-amber);
  font-size: 0.78rem;
  font-weight: 500;
  text-align: center;
  padding: 0.5rem;
  z-index: 9998;
}
.offline-banner.visible { display: block; }

/* Install prompt banner */
.install-banner {
  display: none;
  position: fixed;
  bottom: calc(70px + env(safe-area-inset-bottom));
  left: 1rem; right: 1rem;
  background: var(--c-bg-surface);
  border: 1px solid var(--c-border-accent);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  z-index: 500;
  align-items: center;
  gap: 1rem;
}
.install-banner.visible { display: flex; }

@media (max-width: 768px) {
  .mobile-bottom-nav { display: grid; }
  .layout { padding-bottom: 70px; }
  .sidebar { display: none !important; }
  nav .nav-links { display: none; }
  nav .nav-actions .btn:not(:last-child) { display: none; }
  .main-content { padding: 1rem; }
  .grid-4 { grid-template-columns: repeat(2,1fr); }
  h1 { font-size: 1.75rem; }

  /* Touch-friendly tap targets */
  .btn { min-height: 44px; }
  .tab, .period-btn { min-height: 36px; }
  input, select, textarea { min-height: 44px; font-size: 16px !important; } /* prevent iOS zoom */
}

@media (max-width: 480px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* PWA standalone mode adjustments */
@media (display-mode: standalone) {
  nav { padding-top: env(safe-area-inset-top); }
  .mobile-bottom-nav { display: grid; }
}

/* ══════════════════════════════════════════════════
   GLOBAL SEARCH OVERLAY
══════════════════════════════════════════════════ */
#global-search-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
}
#global-search-overlay.open {
  display: block;
}
.gsearch-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
}
.gsearch-box {
  position: absolute;
  top: 12%;
  left: 50%;
  transform: translateX(-50%);
  width: min(600px, calc(100vw - 2rem));
  background: var(--c-bg-surface);
  border: 1px solid var(--c-border-md);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
  overflow: hidden;
  animation: gsearch-drop .18s cubic-bezier(.2,.8,.4,1) both;
}
@keyframes gsearch-drop {
  from { opacity:0; transform:translateX(-50%) translateY(-12px); }
  to   { opacity:1; transform:translateX(-50%) translateY(0); }
}
.gsearch-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .875rem 1.125rem;
  border-bottom: 1px solid var(--c-border);
}
.gsearch-result {
  display: flex;
  align-items: center;
  gap: .875rem;
  padding: .75rem 1.125rem;
  text-decoration: none;
  color: var(--c-text-primary);
  transition: background var(--transition);
  border-bottom: 1px solid var(--c-border);
}
.gsearch-result:last-child { border-bottom: none; }
.gsearch-result:hover { background: var(--c-bg-hover); }

/* ── Search button in nav ── */
.nav-search-btn {
  display: flex;
  align-items: center;
  gap: .45rem;
  background: var(--c-bg-raised);
  border: 1px solid var(--c-border-md);
  border-radius: var(--radius-md);
  color: var(--c-text-muted);
  padding: .3rem .65rem;
  cursor: pointer;
  font-size: .8rem;
  transition: all var(--transition);
  white-space: nowrap;
}
.nav-search-btn:hover {
  border-color: var(--c-border-active);
  color: var(--c-text-primary);
}
.nav-search-hint {
  font-size: .65rem;
  color: var(--c-text-muted);
  background: var(--c-bg-hover);
  border: 1px solid var(--c-border);
  border-radius: 3px;
  padding: .05rem .3rem;
}
@media (max-width: 900px) { .nav-search-hint { display: none; } }

/* ══════════════════════════════════════════════════
   LANGUAGE SWITCHER (nav bar)
══════════════════════════════════════════════════ */
.nav-lang-switcher {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center;
  background: var(--c-bg-raised);
  border: 1px solid var(--c-border-md);
  border-radius: 100px;
  padding: 2px 4px;
  gap: 2px;
  flex-shrink: 0;
}
.nav-lang-btn {
  background: none;
  border: none;
  border-radius: 100px;
  padding: 3px 7px;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  transition: all var(--transition);
  opacity: 0.45;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav-lang-btn:hover { opacity: .8; background: var(--c-bg-hover); }
.nav-lang-btn.active {
  background: var(--c-bg-surface);
  opacity: 1;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}
@media (max-width: 900px) {
  .nav-lang-switcher { display: none !important; }
}
@media (max-width: 768px) {
  nav .nav-search-btn .nav-search-hint { display: none; }
}
