:root {
  --bg: #0b1220;
  --bg-alt: #0f172a;
  --card: #111827;
  --elev: #0b1220;
  --border: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --primary: #60a5fa;
  --primary-2: #7c3aed;
  --primary-hover: #3b82f6;
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --accent: #22d3ee;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --shadow-sm: 0 4px 12px rgba(0,0,0,.25);
  --focus: 0 0 0 3px rgba(96,165,250,.35);
  --transition: all .2s ease;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: radial-gradient(1200px 800px at 80% -10%, rgba(124,58,237,.15), transparent 50%),
              radial-gradient(1200px 800px at 10% 110%, rgba(34,211,238,.12), transparent 50%),
              var(--bg);
  color: var(--text);
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: .9rem 1.25rem;
  background: rgba(15, 23, 42, .8);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-weight: 700;
  font-size: 1.15rem;
}
.logo-icon {
  display: inline-flex;
  align-items: center;
}

/* --- Modal Styles --- */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-content {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  max-width: 95vw;
  width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.modal-controls {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  gap: .5rem;
  margin-bottom: .75rem;
}
.modal-controls input[type="date"],
.modal-controls input[type="text"],
.modal-controls select {
  font-size: .9rem;
}
.toggle-group { display: flex; align-items: center; gap: .75rem; }
.toggle-group label { font-size: .85rem; color: var(--muted); }
.close-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
}
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  z-index: -1;
}
.history-list {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}
.history-item {
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.history-item header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .5rem;
}
.history-item .actions {
  display: flex;
  gap: .5rem;
}
.history-item pre {
  background: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: .98em;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.history-item .tags { margin: .25rem 0 .5rem; display: flex; flex-wrap: wrap; gap: .35rem; }
.history-item .tag { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); padding: .15rem .45rem; border-radius: 999px; font-size: .78rem; color: var(--muted); }

.pulse { animation: pulseHighlight 0.8s ease; }
@keyframes pulseHighlight { 0%{box-shadow: 0 0 0 0 rgba(96,165,250,.6)} 100%{box-shadow: 0 0 0 12px rgba(96,165,250,0);} }

/* --- Mobile First Improvements --- */
@media (max-width: 600px) {
  .app-header {
    grid-template-columns: 1fr auto;
    flex-wrap: wrap;
    padding: .7rem .5rem;
    font-size: .98em;
  }
  .top-nav {
    display: none;
  }
  .header-actions {
    gap: .5rem;
  }
  .container, .panel, .hero {
    padding: .5rem !important;
  }
  .modal-content {
    width: 98vw;
    padding: 1rem;
  }
  .modal-controls { grid-template-columns: 1fr 1fr; }
}

.logo-text { letter-spacing: .2px; }

.top-nav {
  display: flex;
  gap: .25rem;
  justify-content: center;
}
.top-nav a {
  color: var(--muted);
  text-decoration: none;
  padding: .5rem .85rem;
  border-radius: 8px;
  transition: var(--transition);
  border: 1px solid transparent;
}
.top-nav a:hover { color: var(--text); background: rgba(255,255,255,.06); }
.top-nav a.active { color: white; background: rgba(96,165,250,.15); border-color: rgba(96,165,250,.25); }

.header-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
}
select, input, textarea, button {
  font-family: inherit;
  font-size: .95rem;
}
select, input, textarea {
  background: #0b1220;
  color: var(--text);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  padding: .6rem .8rem;
  transition: var(--transition);
}
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: rgba(96,165,250,.45);
  box-shadow: var(--focus);
}
button {
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  padding: .6rem .9rem;
  background: linear-gradient(135deg, rgba(96,165,250,.25), rgba(124,58,237,.25));
  color: white;
  cursor: pointer;
  transition: var(--transition);
}
button:hover { transform: translateY(-1px); background: linear-gradient(135deg, rgba(96,165,250,.35), rgba(124,58,237,.35)); }
button:active { transform: translateY(0); }
button.secondary {
  background: rgba(255,255,255,.06);
  color: var(--text);
}
button.secondary:hover { background: rgba(255,255,255,.12); }
button.sm { padding: .45rem .6rem; font-size: .85rem; }
button.danger { background: rgba(239,68,68,.25); border-color: rgba(239,68,68,.35); }
button.danger:hover { background: rgba(239,68,68,.35); }

/* Container */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem 5rem;
}

/* Hero */
.hero {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 1.5rem;
  align-items: stretch;
}
.hero-left h1 {
  margin: 0 0 .5rem;
  font-size: 2rem;
}
.hero-left p { color: var(--muted); margin: 0 0 1rem; }
.quick-actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1rem; }
.qa {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .75rem 1rem;
  border-radius: 12px;
  text-decoration: none;
  color: white;
  background: linear-gradient(135deg, rgba(96,165,250,.25), rgba(124,58,237,.25));
  border: 1px solid rgba(255,255,255,.08);
  transition: var(--transition);
}
.qa:hover { transform: translateY(-1px); background: linear-gradient(135deg, rgba(96,165,250,.35), rgba(124,58,237,.35)); }

.hero-right { display: grid; gap: 1rem; }
.stat-box {
  background: linear-gradient(180deg, rgba(96,165,250,.08), rgba(124,58,237,.08));
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  padding: 1.25rem;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
}
.stat-value { font-size: 2.4rem; font-weight: 800; color: var(--primary); }
.stat-label { color: var(--muted); }

.info-card {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  padding: 1rem 1.25rem;
  color: var(--muted);
}

/* Panel */
.panel {
  margin-top: 2rem;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
.panel-head {
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.panel-head h2 { margin: 0; font-size: 1.1rem; }
.panel-actions { display: flex; gap: .5rem; }
.panel > *:not(.panel-head) { padding: 1.25rem; }

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

/* Forms */
.grid-form {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  padding: 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}
.grid-form label {
  font-size: .8rem;
  color: var(--muted);
  display: grid;
  gap: .5rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.grid-form .full { grid-column: 1 / -1; }
.actions-inline { display: flex; gap: .75rem; flex-wrap: wrap; }

/* Output */
.output-block {
  min-height: 150px;
  font-family: var(--mono);
  background: #0a0f1a;
  border: 1px solid rgba(255,255,255,.08);
  padding: 1rem;
  border-radius: 10px;
  font-size: .88rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 600px;
  overflow: auto;
  position: relative;
}
.output-block.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-style: italic;
}
.output-block.loading::after {
  content: '';
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,.12);
  border-top: 2px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-left: .5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Assets list */
.saved-assets {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 600px;
  overflow-y: auto;
}
.asset-item {
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  padding: 1rem;
  transition: var(--transition);
}
.asset-item:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.asset-item header {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap;
  color: var(--text);
  font-weight: 600;
  font-size: .95rem;
}
.asset-item pre {
  margin: .75rem 0 0;
  font-family: var(--mono);
  background: #0a0f1a;
  border: 1px solid rgba(255,255,255,.06);
  padding: .75rem;
  border-radius: 8px;
  max-height: 220px;
  overflow: auto;
  color: var(--text);
}

/* Status bar */
.status-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(15,23,42,.85);
  backdrop-filter: blur(6px);
  border-top: 1px solid rgba(255,255,255,.06);
  padding: .6rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: .85rem;
  z-index: 40;
}

/* Notes and empty */
.note {
  font-size: .9rem;
  color: var(--muted);
  background: rgba(34,211,238,.08);
  border: 1px solid rgba(34,211,238,.18);
  padding: .75rem 1rem;
  border-radius: 10px;
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  border: 1px dashed rgba(255,255,255,.12);
  border-radius: 12px;
}
.empty-state h3 { color: var(--text); margin: 0 0 .5rem; }

/* Responsive */
@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; }
  .top-nav { display: none; }
}

/* Scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: #0a0f1a; }
::-webkit-scrollbar-thumb { background: #1f2937; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #2b3648; }