/* =============================================================
   NovaReq — Intelnova Design System
   Colors inspired by intelnova.co brand (purple/blue gradient, orange accent)
   ============================================================= */

/* ── Custom Properties ─────────────────────────────────────── */
:root {
  /* Brand gradient colors */
  --brand-purple-dark:  #130d4f;
  --brand-purple:       #231b8a;
  --brand-blue-dark:    #0d2f6e;
  --brand-blue:         #1246a0;

  /* Accent */
  --accent:             #f07920;
  --accent-hover:       #d96810;
  --accent-light:       #fff0e6;

  /* Surfaces */
  --surface:            #ffffff;
  --surface-alt:        #f4f5f9;
  --surface-border:     #e3e5ec;

  /* Text */
  --text-primary:       #1a1a2e;
  --text-secondary:     #5a6172;
  --text-light:         #ffffff;
  --text-muted:         #9ca3af;

  /* Semantic */
  --success:            #10b981;
  --warning:            #f59e0b;
  --danger:             #ef4444;
  --info:               #3b82f6;

  /* Status badge colors */
  --status-draft:              #6b7280;
  --status-submitted:          #3b82f6;
  --status-consideration:      #f59e0b;
  --status-estimation:         #8b5cf6;
  --status-quotation:          #06b6d4;
  --status-approval:           #10b981;
  --status-planning:           #0ea5e9;
  --status-execution:          #6366f1;
  --status-delivery:           #059669;
  --status-alternated:         #d97706;
  --status-denied-by-product:  #ef4444;
  --status-rejected-by-client: #dc2626;
  --status-cancelled:          #374151;

  /* Priority badge colors */
  --priority-low:       #6b7280;
  --priority-medium:    #3b82f6;
  --priority-high:      #f59e0b;
  --priority-critical:  #ef4444;

  /* Layout */
  --sidebar-width:      240px;
  --header-height:      60px;

  /* Spacing */
  --gap-xs: 4px;
  --gap-sm: 8px;
  --gap-md: 16px;
  --gap-lg: 24px;
  --gap-xl: 32px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.10);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.12);

  /* Transitions */
  --transition: 150ms ease;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text-primary);
  background: var(--surface-alt);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font: inherit; border: none; background: none; }
input, select, textarea { font: inherit; }

/* ── Loaders ────────────────────────────────────────────────── */
.initial-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: var(--gap-md);
  background: var(--brand-purple-dark);
}
.loader-mascot {
  width: 72px;
  height: 72px;
  animation: pulse 1.6s ease-in-out infinite;
}
.loader-text { color: rgba(255,255,255,.75); font-size: .95rem; }

.page-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  gap: var(--gap-md);
  color: var(--text-secondary);
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--surface-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin  { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.45; } }
@keyframes slideIn { from { transform: translateY(-10px); opacity:0; } to { transform: translateY(0); opacity:1; } }
@keyframes fadeIn  { from { opacity:0; } to { opacity:1; } }

/* ── Slow-request 8-bit loader ──────────────────────────────── */
.slow-loader {
  position: fixed;
  top: 64px; right: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #181828;
  border: 2px solid #39ff14;
  border-radius: 4px;
  padding: 6px 14px;
  font-family: 'Courier New', Courier, monospace;
  font-size: .75rem;
  color: #39ff14;
  z-index: 1000;
  animation: pixelFadeIn .25s steps(4);
  box-shadow: 0 0 8px rgba(57,255,20,.25);
  image-rendering: pixelated;
}
.slow-loader.hidden { display: none; }

/* 8-bit running character sprite */
.slow-loader-sprite {
  width: 16px; height: 16px;
  background: #39ff14;
  position: relative;
  animation: spriteRun .4s steps(2) infinite;
  clip-path: polygon(
    25% 0%, 75% 0%, 75% 12%, 87% 12%, 87% 37%,
    100% 37%, 100% 62%, 75% 62%, 75% 75%, 87% 75%,
    87% 100%, 62% 100%, 62% 75%, 37% 75%, 37% 100%,
    12% 100%, 12% 75%, 25% 75%, 25% 62%, 0% 62%,
    0% 37%, 12% 37%, 12% 12%, 25% 12%
  );
}

@keyframes spriteRun {
  0%   { transform: translateX(0); }
  50%  { transform: translateX(3px) scaleY(.9); }
  100% { transform: translateX(0); }
}
@keyframes pixelFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Toast notifications ────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
  z-index: 900;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  padding: 12px 16px;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 420px;
  pointer-events: all;
  animation: slideIn .25s ease;
  font-size: .9rem;
}
.toast-success { border-left: 4px solid var(--success); }
.toast-error   { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }
.toast-info    { border-left: 4px solid var(--info); }
.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-message { flex: 1; }
.toast-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1rem; flex-shrink: 0;
  padding: 2px 4px; border-radius: 4px;
}
.toast-close:hover { color: var(--text-primary); }

/* ── LOGIN PAGE ─────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand-purple-dark) 0%, var(--brand-blue-dark) 60%, var(--brand-blue) 100%);
  position: relative;
  overflow: hidden;
}

/* Decorative blobs */
.login-page::before,
.login-page::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  opacity: .12;
  pointer-events: none;
}
.login-page::before {
  width: 600px; height: 600px;
  background: radial-gradient(circle, var(--accent), transparent);
  top: -200px; right: -150px;
}
.login-page::after {
  width: 400px; height: 400px;
  background: radial-gradient(circle, var(--brand-purple), transparent);
  bottom: -150px; left: -100px;
}

.login-card {
  position: relative;
  z-index: 1;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  width: 100%;
  max-width: 400px;
  margin: var(--gap-lg);
  overflow: hidden;
  animation: fadeIn .4s ease;
}

.login-card-header {
  background: linear-gradient(135deg, var(--brand-purple-dark), var(--brand-blue-dark));
  padding: 36px 32px 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-md);
}

.login-mascot {
  width: 72px;
  height: 72px;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,.4));
}

.login-brand {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -.5px;
}
.brand-intel { color: var(--accent); }
.brand-nova  { color: var(--text-light); }

.login-app-name {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-light);
  letter-spacing: -1px;
  line-height: 1;
}

.login-subtitle {
  font-size: .85rem;
  color: rgba(255,255,255,.65);
  max-width: 260px;
  text-align: center;
}

.login-card-body {
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: var(--gap-lg);
}

.login-description {
  font-size: .9rem;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.6;
}

.btn-login-microsoft {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap-sm);
  width: 100%;
  padding: 14px 20px;
  background: var(--accent);
  color: var(--text-light);
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 14px rgba(240,121,32,.4);
}
.btn-login-microsoft:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(240,121,32,.5);
}
.btn-login-microsoft:active { transform: translateY(0); }
.btn-login-microsoft svg { flex-shrink: 0; }

.login-card-footer {
  padding: 16px 32px;
  border-top: 1px solid var(--surface-border);
  text-align: center;
  font-size: .78rem;
  color: var(--text-muted);
}
.login-hint {
  font-size: .8rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}
.header-username { display: none; }
@media (min-width: 768px) { .header-username { display: inline; } }

/* ── APP SHELL (authenticated layout) ──────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Header */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: linear-gradient(90deg, var(--brand-purple-dark), var(--brand-blue-dark));
  display: flex;
  align-items: center;
  padding: 0 var(--gap-lg);
  z-index: 100;
  box-shadow: var(--shadow-md);
  gap: var(--gap-md);
}
.header-brand {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  text-decoration: none;
  flex-shrink: 0;
}
.header-brand img { width: 32px; height: 32px; }
.header-brand-text { font-size: 1.05rem; font-weight: 700; color: var(--text-light); }
.header-brand-text .intel { color: var(--accent); }
.header-app-name {
  font-size: .8rem;
  font-weight: 600;
  color: rgba(255,255,255,.5);
  margin-left: 4px;
  text-transform: uppercase;
  letter-spacing: .5px;
  cursor: pointer;
  transition: color .2s;
}
.header-app-name:hover { color: #0ff; }

/* ── About popup (cyberpunk) ──────────────────────────────── */
.about-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 9999;
  align-items: center; justify-content: center;
}
.about-overlay.active { display: flex; }

.about-popup {
  position: relative;
  background: #0a0a12;
  border: 1px solid #0ff;
  box-shadow: 0 0 30px rgba(0,255,255,.3), inset 0 0 20px rgba(0,255,255,.05);
  padding: 2.5rem 3rem;
  text-align: center;
  animation: about-flicker .15s ease-out;
}

@keyframes about-flicker {
  0%   { opacity: 0; transform: scale(.95) translateY(10px); }
  50%  { opacity: 1; transform: scale(1.02); }
  100% { opacity: 1; transform: scale(1); }
}

.about-glitch {
  font-family: 'Courier New', monospace;
  font-size: 2.2rem;
  font-weight: 900;
  color: #0ff;
  text-shadow: 2px 0 #f0f, -2px 0 #0f0;
  letter-spacing: 3px;
  text-transform: uppercase;
  animation: glitch 2.5s infinite;
  position: relative;
}

@keyframes glitch {
  0%, 90%, 100% { text-shadow: 2px 0 #f0f, -2px 0 #0f0; transform: none; }
  92% { text-shadow: -3px 0 #f0f, 3px 0 #0f0; transform: translateX(-2px); }
  94% { text-shadow: 3px 0 #f0f, -3px 0 #0f0; transform: translateX(2px); }
  96% { text-shadow: -1px 0 #f0f, 1px 0 #0f0; transform: translateX(-1px); }
}

.about-by {
  font-family: 'Courier New', monospace;
  font-size: .95rem;
  color: #888;
  margin-top: .8rem;
  letter-spacing: 1px;
}
.about-author {
  color: #f0f;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(255,0,255,.5);
}
.about-version {
  font-family: 'Courier New', monospace;
  font-size: .8rem;
  color: #0f0;
  margin-top: .5rem;
  letter-spacing: 2px;
  text-shadow: 0 0 6px rgba(0,255,0,.4);
}
.about-close {
  position: absolute;
  top: .5rem; right: .8rem;
  background: none; border: none;
  color: #0ff;
  font-size: 1.2rem;
  cursor: pointer;
  transition: color .15s;
}
.about-close:hover { color: #f0f; }
.header-spacer { flex: 1; }
.header-user {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  color: rgba(255,255,255,.85);
  font-size: .875rem;
}
.header-avatar {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem; color: white;
  flex-shrink: 0;
}
.btn-logout {
  padding: 6px 12px;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.8);
  font-size: .8rem;
  transition: all var(--transition);
}
.btn-logout:hover {
  background: rgba(255,255,255,.1);
  color: white;
  border-color: rgba(255,255,255,.5);
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--surface-border);
  position: fixed;
  top: var(--header-height);
  bottom: 0;
  left: 0;
  overflow-y: auto;
  z-index: 90;
  padding: var(--gap-lg) 0;
  display: flex;
  flex-direction: column;
}
.nav-section-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
  padding: var(--gap-sm) var(--gap-lg);
  margin-top: var(--gap-sm);
}
.nav-link {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  padding: 10px var(--gap-lg);
  color: var(--text-secondary);
  font-size: .9rem;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  text-decoration: none;
}
.nav-link:hover { background: var(--surface-alt); color: var(--text-primary); text-decoration: none; }
.nav-link.active {
  background: var(--accent-light);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}
.nav-link .nav-icon { font-size: 1.05rem; width: 20px; text-align: center; }

/* Main content */
.app-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  flex: 1;
  padding: var(--gap-xl);
  min-height: calc(100vh - var(--header-height));
}

/* ── Page layout helpers ─────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--gap-xl);
  gap: var(--gap-md);
}
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}
.page-subtitle {
  font-size: .875rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: var(--gap-md) var(--gap-lg);
  border-bottom: 1px solid var(--surface-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-sm);
}
.card-title { font-size: 1rem; font-weight: 600; color: var(--text-primary); }
.card-body  { padding: var(--gap-lg); }

/* ── Stats grid ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--gap-md);
  margin-bottom: var(--gap-xl);
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--surface-border);
  padding: var(--gap-lg);
  display: flex;
  flex-direction: column;
  gap: var(--gap-xs);
}
.stat-label { font-size: .8rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.stat-value { font-size: 2rem; font-weight: 800; color: var(--text-primary); line-height: 1; }
.stat-sub   { font-size: .78rem; color: var(--text-muted); }
.stat-filter-link {
  font-size: .78rem;
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
  transition: color .15s;
}
.stat-filter-link:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* ── Table ──────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th {
  text-align: left;
  padding: 10px var(--gap-md);
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--surface-border);
  white-space: nowrap;
}
td {
  padding: 12px var(--gap-md);
  border-bottom: 1px solid var(--surface-border);
  color: var(--text-primary);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-alt); }
.table-link { color: var(--brand-blue); font-weight: 500; cursor: pointer; text-decoration: none; }
.table-link:hover { text-decoration: underline; }

/* ── Badges / Status chips ──────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  color: white;
  white-space: nowrap;
}
.badge-Draft             { background: var(--status-draft); }
.badge-Consideration     { background: var(--status-consideration); color: #1a1a2e; }
.badge-Estimation        { background: var(--status-estimation); }
.badge-Quotation         { background: var(--status-quotation); }
.badge-Approval          { background: var(--status-approval); }
.badge-Planning          { background: var(--status-planning); }
.badge-Execution         { background: var(--status-execution); }
.badge-Delivery          { background: var(--status-delivery); }
.badge-Alternated        { background: var(--status-alternated); color: #1a1a2e; }
.badge-DeniedByProduct   { background: var(--status-denied-by-product); }
.badge-RejectedByClient  { background: var(--status-rejected-by-client); }
.badge-Cancelled         { background: var(--status-cancelled); }

.badge-priority-Low      { background: var(--priority-low); }
.badge-priority-Medium   { background: var(--priority-medium); }
.badge-priority-High     { background: var(--priority-high); color: #1a1a2e; }
.badge-priority-Critical { background: var(--priority-critical); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--gap-xs);
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 8px rgba(240,121,32,.35);
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 12px rgba(240,121,32,.45); }
.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--surface-border);
}
.btn-secondary:hover { background: var(--surface-alt); }
.btn-ghost { color: var(--text-secondary); padding: 8px 12px; }
.btn-ghost:hover { background: var(--surface-alt); color: var(--text-primary); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: .875rem; font-weight: 600; color: var(--text-primary); }
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-input, .form-select, .form-textarea {
  padding: 9px 12px;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  font-size: .9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(18,70,160,.12);
}
.form-textarea { min-height: 100px; resize: vertical; }
.form-error { font-size: .8rem; color: var(--danger); }
.form-hint  { font-size: .8rem; color: var(--text-muted); }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap-md); }
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--gap-sm);
  padding-top: var(--gap-md);
  border-top: 1px solid var(--surface-border);
  margin-top: var(--gap-md);
}

/* ── Filter bar ─────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  flex-wrap: wrap;
  margin-bottom: var(--gap-md);
}
.filter-bar .form-input,
.filter-bar .form-select { width: auto; }

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px var(--gap-lg);
  color: var(--text-secondary);
  gap: var(--gap-md);
  text-align: center;
}
.empty-icon { font-size: 3rem; }
.empty-title { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); }
.empty-subtitle { font-size: .875rem; max-width: 320px; }

/* ── Timeline ───────────────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex;
  gap: var(--gap-md);
  position: relative;
  padding-bottom: var(--gap-lg);
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--surface-alt);
  border: 2px solid var(--surface-border);
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.timeline-line {
  position: absolute;
  left: 15px; top: 32px; bottom: 0;
  width: 2px;
  background: var(--surface-border);
}
.timeline-item:last-child .timeline-line { display: none; }
.timeline-content { flex: 1; padding-top: 4px; }
.timeline-header { font-size: .875rem; font-weight: 600; color: var(--text-primary); }
.timeline-meta   { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }
.timeline-note   { font-size: .875rem; color: var(--text-secondary); margin-top: var(--gap-xs); }

/* ── Comments ───────────────────────────────────────────────── */
.comment-item {
  display: flex;
  gap: var(--gap-md);
  padding: var(--gap-md) 0;
  border-bottom: 1px solid var(--surface-border);
}
.comment-item:last-child { border-bottom: none; }
.comment-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--brand-purple);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700;
  flex-shrink: 0;
}
.comment-body { flex: 1; }
.comment-meta { font-size: .78rem; color: var(--text-muted); margin-bottom: 4px; }
.comment-meta strong { color: var(--text-primary); font-size: .85rem; }
.comment-text { font-size: .9rem; color: var(--text-primary); }


/* ── Detail page layout ─────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: var(--gap-lg);
}
.detail-main  { display: flex; flex-direction: column; gap: var(--gap-lg); }
.detail-aside { display: flex; flex-direction: column; gap: var(--gap-md); }

.meta-list { display: flex; flex-direction: column; gap: var(--gap-sm); }
.meta-item { display: flex; align-items: flex-start; gap: var(--gap-sm); }
.meta-label { font-size: .78rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; width: 120px; flex-shrink: 0; padding-top: 2px; }
.meta-value { font-size: .875rem; color: var(--text-primary); }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  padding: var(--gap-lg);
  animation: fadeIn .2s ease;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideIn .25s ease;
}
.modal-header {
  padding: var(--gap-lg) var(--gap-xl);
  border-bottom: 1px solid var(--surface-border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 1.1rem; font-weight: 700; }
.modal-close { color: var(--text-muted); padding: 4px 8px; border-radius: 4px; }
.modal-close:hover { background: var(--surface-alt); color: var(--text-primary); }
.modal-body    { padding: var(--gap-xl); display: flex; flex-direction: column; gap: var(--gap-md); }
.modal-footer  { padding: var(--gap-md) var(--gap-xl); border-top: 1px solid var(--surface-border); display: flex; justify-content: flex-end; gap: var(--gap-sm); }

/* ── Status option picker (transition modal) ───────────────── */
.status-options         { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow-y: auto; padding-right: 4px; }
.status-option          { padding: 8px 14px; border-radius: 6px; cursor: pointer; font-size: .9rem; font-weight: 500;
                           border: 1px solid transparent; transition: opacity .15s, outline .1s; user-select: none; }
.status-option--active   { background: #dcfce7; color: #166534; border-color: #86efac; }
.status-option--terminal { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.status-option:hover     { opacity: .8; }
.status-option.selected  { outline: 2px solid currentColor; outline-offset: 1px; font-weight: 700; }

/* ── Chevron Status Trail ──────────────────────────────────── */
.chevron-trail {
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: wrap;
  margin: 4px 0 var(--gap-md);
}
.chevron-node {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 6px 18px 6px 28px;
  font-size: .78rem;
  font-weight: 600;
  white-space: nowrap;
  color: white;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%, 14px 50%);
  line-height: 1.3;
}
.chevron-node:first-child {
  padding-left: 14px;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%);
  border-radius: 4px 0 0 4px;
}
.chevron-node--completed {
  background: var(--brand-blue);
}
.chevron-node--current {
  background: var(--accent);
}
.chevron-node--terminal {
  background: var(--danger);
}
.chevron-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px dashed var(--accent);
  color: var(--accent);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.chevron-add:hover {
  background: var(--accent-light);
  border-color: var(--accent-hover);
  color: var(--accent-hover);
  transform: scale(1.1);
}

/* ── Autocomplete ──────────────────────────────────────────── */
.autocomplete-wrapper { position: relative; }
.autocomplete-list {
  position: absolute;
  top: calc(100% + 3px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 18px rgba(0,0,0,.10);
  max-height: 240px;
  overflow-y: auto;
  z-index: 300;
  margin: 0; padding: 0;
  list-style: none;
  display: none;
}
.autocomplete-list.open { display: block; }
.autocomplete-list li {
  padding: 8px 12px;
  cursor: pointer;
  font-size: .9rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--surface-border);
}
.autocomplete-list li:last-child { border-bottom: none; }
.autocomplete-list li:hover,
.autocomplete-list li.active {
  background: var(--brand-blue);
  color: var(--text-light);
}
.autocomplete-list .ac-no-results {
  padding: 10px 12px;
  font-size: .85rem;
  color: var(--text-muted);
  cursor: default;
}

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap-xs);
  padding: var(--gap-md) 0;
}
.page-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.page-btn:hover { background: var(--surface-alt); color: var(--text-primary); }
.page-btn.active { background: var(--accent); color: white; font-weight: 700; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Tag chips ──────────────────────────────────────────────── */
.tag-list { display: flex; flex-wrap: wrap; gap: var(--gap-xs); }
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  background: var(--surface-alt);
  border: 1px solid var(--surface-border);
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ── Not-found / Error ──────────────────────────────────────── */
.not-found, .error-page {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 60vh; gap: var(--gap-md); text-align: center;
}
.not-found h2, .error-page h2 { font-size: 1.4rem; color: var(--text-primary); }

/* ── Reports ────────────────────────────────────────────────── */
.report-tabs {
  display: flex;
  gap: var(--gap-sm);
  margin-bottom: var(--gap-lg);
  flex-wrap: wrap;
}
.report-tab {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--surface-border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.report-tab:hover { border-color: var(--brand-blue); color: var(--brand-blue); }
.report-tab.active {
  background: var(--brand-purple);
  border-color: var(--brand-purple);
  color: #fff;
}
.report-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow-sm);
  padding: var(--gap-xl);
}
.report-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--gap-lg);
}
.report-title { font-size: 1.15rem; font-weight: 600; color: var(--text-primary); }
.report-subtitle { font-size: .85rem; color: var(--text-secondary); margin-top: 2px; }

/* KPIs */
.report-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap-md);
  margin-bottom: var(--gap-xl);
}
.report-kpi {
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  padding: var(--gap-md) var(--gap-lg);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.report-kpi-label { font-size: .78rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; }
.report-kpi-value { font-size: 1.3rem; font-weight: 700; color: var(--brand-purple); }
.report-kpi-sale  { color: var(--accent); }

/* Table */
.report-table-wrap { overflow-x: auto; }
.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.report-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--surface-border);
  white-space: nowrap;
}
.report-table th.report-th-r { text-align: right; }
.report-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--surface-border);
  vertical-align: middle;
}
.report-table tbody tr:hover { background: var(--surface-alt); }
.report-month-cell { font-weight: 500; white-space: nowrap; }
.report-num-cell   { text-align: right; color: var(--text-secondary); white-space: nowrap; }
.report-cost-cell  { text-align: right; font-weight: 600; white-space: nowrap; }
.report-sale       { color: var(--accent); }

/* Bar chart column */
.report-bar-cell { width: 160px; }
.report-bar-wrap {
  height: 10px;
  background: var(--surface-alt);
  border-radius: 99px;
  overflow: hidden;
}
.report-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-purple), var(--brand-blue));
  border-radius: 99px;
  transition: width .4s ease;
  min-width: 3px;
}

/* Total row */
.report-total-row td {
  border-top: 2px solid var(--surface-border);
  border-bottom: none;
  background: var(--surface-alt);
}

.report-footnote {
  margin-top: var(--gap-lg);
  font-size: .78rem;
  color: var(--text-muted);
}

/* Solicitudes sin saldar — estilos específicos */
.report-req-link {
  color: var(--brand-blue);
  text-decoration: none;
  font-weight: 600;
}
.report-req-link:hover { text-decoration: underline; }

.report-title-cell {
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.report-status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  background: var(--surface-alt);
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Botón "← Volver" en drill-down */
.report-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: var(--gap-lg);
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--brand-blue);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.report-back-btn:hover { background: var(--surface-alt); }

/* Links de mes en tabla de facturación */
.report-month-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--brand-blue);
  font-weight: 600;
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.report-month-link:hover { text-decoration: underline; }

/* Filter bar */
.report-filter-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: var(--gap-xl);
  flex-wrap: wrap;
  background: var(--surface-alt);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 5px 8px;
  width: fit-content;
}
.report-filter-icon {
  font-size: .95rem;
  margin-right: 2px;
  flex-shrink: 0;
  opacity: .65;
}
.report-filter-sep {
  width: 1px;
  height: 20px;
  background: var(--surface-border);
  margin: 0 4px;
  flex-shrink: 0;
}
.report-filter-btn {
  padding: 5px 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--brand-blue);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.report-filter-btn:hover:not(.active) {
  background: rgba(18, 70, 160, .08);
}
.report-filter-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .app-sidebar { transform: translateX(-100%); transition: transform .25s ease; }
  .app-sidebar.open { transform: translateX(0); }
  .app-content { margin-left: 0; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .app-content { padding: var(--gap-md); }
}
