/* Licitaciones Novagentia — Alfred Studio (v5) */

@import url('https://rsms.me/inter/inter.css');

:root {
    --bg: #08090d;
    --bg-soft: #0d0f15;
    --bg-card: #11131a;
    --bg-elev: #181b25;
    --bg-hover: #1c2030;
    --bg-input: #161924;
    --bg-glass: rgba(13, 15, 21, 0.78);
    --border: #1f2330;
    --border-soft: #181b25;
    --border-strong: #2a3145;
    --text: #e7e9ef;
    --text-muted: #8a91a8;
    --text-dim: #555c74;
    --accent: #5b8cff;
    --accent-soft: rgba(91, 140, 255, 0.12);
    --accent-strong: rgba(91, 140, 255, 0.22);
    --accent-glow: rgba(91, 140, 255, 0.35);
    --accent-hover: #4574eb;
    --purple: #a78bfa;
    --purple-soft: rgba(167, 139, 250, 0.14);
    --green: #34d399;
    --green-soft: rgba(52, 211, 153, 0.14);
    --red: #f87171;
    --red-soft: rgba(248, 113, 113, 0.14);
    --amber: #fbbf24;
    --amber-soft: rgba(251, 191, 36, 0.14);
    --star: #fbbf24;
    --r-sm: 6px;
    --r: 10px;
    --r-lg: 14px;
    --r-xl: 20px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow: 0 4px 12px rgba(0,0,0,.35);
    --shadow-lg: 0 12px 36px rgba(0,0,0,.5);
    --shadow-glow: 0 0 0 1px var(--accent-strong), 0 8px 24px rgba(91,140,255,.18);
    --t: 160ms cubic-bezier(.4,0,.2,1);
}

@supports (font-variation-settings: normal) {
    :root { font-family: 'Inter var', -apple-system, BlinkMacSystemFont, sans-serif; }
}

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

html { color-scheme: dark; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(91,140,255,0.06), transparent),
        radial-gradient(ellipse 60% 40% at 90% 110%, rgba(167,139,250,0.04), transparent);
    background-attachment: fixed;
    min-height: 100vh;
}

a { color: inherit; }

button { font: inherit; }

.container { max-width: 1280px; margin: 0 auto; padding: 0 20px; }

/* ============ NAV ============ */
.navbar {
    background: var(--bg-glass);
    backdrop-filter: saturate(180%) blur(18px);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    border-bottom: 1px solid var(--border-soft);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-content { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.nav-left { display: flex; align-items: center; gap: 24px; }
.nav-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.nav-logo {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 15px; color: white;
    box-shadow: 0 4px 12px rgba(91,140,255,.3);
    letter-spacing: -.02em;
}
.nav-title { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.nav-links { display: flex; gap: 2px; }
.nav-link {
    color: var(--text-muted); text-decoration: none;
    padding: 7px 13px; border-radius: var(--r-sm);
    font-size: 13px; font-weight: 500;
    transition: color var(--t), background var(--t);
}
.nav-link:hover { color: var(--text); background: var(--bg-hover); }
.nav-link.active {
    color: var(--accent);
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 1px var(--accent-strong);
}
.nav-right { display: flex; align-items: center; gap: 10px; }

/* Alfred pill */
.alfred-pill {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 12px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 12px; font-weight: 500;
    transition: border-color var(--t);
}
.alfred-pill:hover { border-color: var(--border-strong); }
.alfred-pill-label { color: var(--text); font-weight: 600; }
.alfred-pill-meta { color: var(--text-muted); }
.alfred-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--text-dim);
    box-shadow: 0 0 0 0 var(--text-dim);
    animation: alfred-pulse 2.4s ease-in-out infinite;
}
.alfred-pill-activo .alfred-dot { background: var(--green); box-shadow: 0 0 8px rgba(52,211,153,.6); }
.alfred-pill-lento  .alfred-dot { background: var(--amber); box-shadow: 0 0 8px rgba(251,191,36,.5); }
.alfred-pill-caido  .alfred-dot { background: var(--red); box-shadow: 0 0 8px rgba(248,113,113,.5); }
@keyframes alfred-pulse {
    0%,100% { transform: scale(1); opacity: 1; }
    50%     { transform: scale(.85); opacity: .55; }
}

/* Chat trigger button */
.btn-chat-trigger {
    position: relative;
    background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 6px 12px; border-radius: 100px;
    cursor: pointer; font-size: 12px; font-weight: 600;
    display: inline-flex; align-items: center; gap: 6px;
    transition: all var(--t);
}
.btn-chat-trigger:hover { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.btn-chat-trigger .chat-badge {
    position: absolute; top: -4px; right: -4px;
    min-width: 18px; height: 18px; padding: 0 5px;
    background: var(--red); color: white;
    border-radius: 100px;
    font-size: 10px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    border: 2px solid var(--bg);
}

main.container { padding-top: 28px; padding-bottom: 60px; }

/* ============ PAGE HEADER ============ */
.page-header { margin-bottom: 24px; display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-header h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.page-header p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.page-header-actions { display: flex; gap: 8px; align-items: center; }

/* ============ CARDS ============ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 20px;
    margin-bottom: 16px;
    transition: border-color var(--t);
}
.card:hover { border-color: var(--border-strong); }
.card-flat { padding: 16px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-title { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }

/* ============ STATS GRID ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: var(--stat-color, var(--accent));
    opacity: 0;
    transition: opacity var(--t);
}
.stat-link { text-decoration: none; color: inherit; transition: border-color var(--t), transform var(--t); display: block; }
.stat-link:hover { border-color: var(--stat-color, var(--accent)); transform: translateY(-1px); }
.stat-link:hover::before { opacity: 1; }
.stat-value { font-size: 32px; font-weight: 700; line-height: 1; margin-bottom: 6px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stat-trend { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.stat-card-spark { padding: 18px 20px 4px; }
.stat-spark-row { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.sparkline { width: 100%; height: 48px; display: block; margin: 0 -4px; }

/* ============ DASHBOARD GRID ============ */
.dashboard-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }

/* ============ DEADLINE LIST ============ */
.deadline-list { display: flex; flex-direction: column; }
.deadline-item {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 14px;
    padding: 12px 0; border-bottom: 1px solid var(--border);
    text-decoration: none; color: inherit;
    transition: padding-left var(--t);
}
.deadline-item:last-child { border-bottom: none; }
.deadline-item:hover { padding-left: 4px; }
.deadline-item:hover .deadline-title { color: var(--accent); }
.deadline-info { flex: 1; min-width: 0; }
.deadline-title { font-size: 13px; font-weight: 500; line-height: 1.45; transition: color var(--t); }
.deadline-meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.deadline-date { font-size: 12px; color: var(--text-muted); white-space: nowrap; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

/* ============ FILTERS ============ */
.filters-bar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.filter-tabs { display: flex; gap: 2px; flex-wrap: wrap; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r); padding: 3px; }
.tab {
    padding: 6px 13px; border-radius: var(--r-sm);
    font-size: 12px; font-weight: 500;
    color: var(--text-muted); text-decoration: none;
    transition: all var(--t);
    display: inline-flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--text); background: var(--bg-hover); }
.tab.active { color: white; background: var(--accent); box-shadow: 0 1px 4px rgba(91,140,255,.4); }
.tab-count { font-size: 10px; font-weight: 700; background: rgba(255,255,255,.18); padding: 1px 6px; border-radius: 100px; }
.tab.active .tab-count { background: rgba(255,255,255,.25); }

.filter-input, .filter-select {
    background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--r);
    color: var(--text); padding: 8px 12px; font-size: 13px; font-family: inherit;
    outline: none; transition: border-color var(--t), background var(--t);
}
.filter-input { min-width: 220px; }
.filter-input:focus, .filter-select:focus { border-color: var(--accent); background: var(--bg-elev); }
.filter-input::placeholder { color: var(--text-dim); }
.filter-select { cursor: pointer; }

.search-wrap { position: relative; flex: 1; max-width: 360px; }
.search-wrap .filter-input { width: 100%; padding-left: 36px; min-width: 0; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--text-dim); pointer-events: none; }
.search-shortcut {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    font-size: 10px; color: var(--text-dim);
    background: var(--bg); border: 1px solid var(--border);
    padding: 2px 6px; border-radius: 4px;
    pointer-events: none; font-family: ui-monospace, monospace;
}

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    border: 1px solid transparent; border-radius: var(--r);
    padding: 8px 14px; font-size: 13px; font-weight: 500;
    cursor: pointer; transition: all var(--t);
    text-decoration: none; white-space: nowrap;
    font-family: inherit;
    background: var(--accent); color: white;
}
.btn:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(91,140,255,.3); }
.btn:active { transform: translateY(0); }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-lg { padding: 10px 18px; font-size: 14px; }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); background: var(--bg-hover); box-shadow: none; transform: none; }
.btn-active { background: var(--accent); color: white; border-color: var(--accent); }
.btn-purple { background: var(--purple); color: white; }
.btn-purple:hover { background: #9871fa; }
.btn-green  { background: var(--green); color: #06281c; }
.btn-green:hover { background: #1ec991; box-shadow: 0 4px 12px rgba(52,211,153,.3); }
.btn-red    { background: var(--red); color: white; }
.btn-red:hover { background: #f55c5c; }
.btn-icon {
    background: transparent; border: 1px solid var(--border); color: var(--text-muted);
    width: 32px; height: 32px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--r-sm);
}
.btn-icon:hover { color: var(--text); background: var(--bg-hover); border-color: var(--border-strong); transform: none; box-shadow: none; }

/* ============ STAR (favorita) ============ */
.icon-star { width: 18px; height: 18px; display: block; transition: transform var(--t); }
.btn-star {
    background: transparent; border: 1px solid var(--border);
    color: var(--text-dim);
    width: 32px; height: 32px; padding: 0;
    border-radius: var(--r-sm);
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: all var(--t);
}
.btn-star:hover { color: var(--star); border-color: var(--star); background: rgba(251,191,36,.06); }
.btn-star.is-on { color: var(--star); border-color: var(--star); background: rgba(251,191,36,.1); }
.btn-star.is-on .icon-star { transform: scale(1.05); }
.btn-star.btn-star-lg { width: 38px; height: 38px; }
.btn-star.btn-star-lg .icon-star { width: 20px; height: 20px; }
@keyframes star-pop {
    0% { transform: scale(1); }
    40% { transform: scale(1.4); }
    100% { transform: scale(1); }
}
.btn-star.is-on .icon-star.is-popping { animation: star-pop .4s ease-out; }

/* ============ LICITACIONES LIST ============ */
.lic-list { display: flex; flex-direction: column; gap: 10px; }
.lic-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-lg);
    padding: 16px 18px;
    display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
    transition: all var(--t);
    position: relative;
}
.lic-card:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow); }
.lic-card.is-focused { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-strong); }
.lic-card.is-favorita { border-left: 3px solid var(--star); padding-left: 16px; }
.lic-card-main { flex: 1; min-width: 0; }
.lic-card-top { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.lic-exp { font-size: 11px; color: var(--text-dim); font-family: ui-monospace, 'SF Mono', monospace; padding: 2px 6px; background: var(--bg); border-radius: 4px; }
.lic-card-title { display: block; font-size: 14.5px; font-weight: 500; color: var(--text); text-decoration: none; line-height: 1.45; margin-bottom: 6px; transition: color var(--t); }
.lic-card-title:hover { color: var(--accent); }
.lic-card-meta { font-size: 12.5px; color: var(--text-muted); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.lic-card-bottom { display: flex; gap: 18px; font-size: 12px; color: var(--text-dim); flex-wrap: wrap; align-items: center; }
.lic-amount { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; font-size: 13px; }
.lic-card-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: center; padding-top: 2px; }
.lic-card-actions .btn-star { width: 32px; height: 32px; }

/* ============ BADGES ============ */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 9px; border-radius: 100px;
    font-size: 11px; font-weight: 600; line-height: 1;
    white-space: nowrap;
}
.badge-sm { padding: 2px 7px; font-size: 10px; }
.badge-pulse { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .55 } }

.badge-estado[data-estado="activa"]     { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-strong); }
.badge-estado[data-estado="en_proceso"] { background: var(--purple-soft); color: var(--purple); border: 1px solid rgba(167,139,250,.3); }
.badge-estado[data-estado="presentada"] { background: var(--green-soft); color: var(--green); border: 1px solid rgba(52,211,153,.3); }
.badge-estado[data-estado="descartada"] { background: rgba(107,114,128,.14); color: var(--text-muted); border: 1px solid rgba(107,114,128,.3); }
.badge-estado[data-estado="expirada"]   { background: rgba(55,65,81,.3); color: var(--text-dim); border: 1px solid rgba(55,65,81,.5); }

.badge-prio[data-prio="alta"]  { background: var(--red-soft); color: var(--red); }
.badge-prio[data-prio="media"] { background: var(--amber-soft); color: var(--amber); }
.badge-prio[data-prio="baja"]  { background: var(--green-soft); color: var(--green); }

.plazo-expirado { background: rgba(55,65,81,.4); color: var(--text-dim); }
.plazo-hoy      { background: var(--red); color: white; }
.plazo-urgente  { background: var(--red-soft); color: var(--red); border: 1px solid rgba(248,113,113,.3); }
.plazo-proximo  { background: var(--amber-soft); color: var(--amber); border: 1px solid rgba(251,191,36,.3); }
.plazo-medio    { background: var(--bg-elev); color: var(--text-muted); border: 1px solid var(--border); }
.plazo-lejano   { background: var(--bg-elev); color: var(--text-dim); }

/* ============ SOBRE CHIPS ============ */
.sobre-chips { display: inline-flex; gap: 4px; align-items: center; }
.sobre-chip {
    display: inline-flex; align-items: center; justify-content: center; gap: 3px;
    min-width: 26px; height: 22px; padding: 0 7px;
    background: var(--bg-elev); color: var(--text-dim);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 11px; font-weight: 700;
    transition: all var(--t);
}
.sobre-chip.is-ready {
    background: var(--green-soft); color: var(--green); border-color: rgba(52,211,153,.3);
}
.sobre-chip .sobre-check { font-size: 9px; }
.sobre-chips-sm .sobre-chip { min-width: 22px; height: 18px; padding: 0 5px; font-size: 10px; }

.sobres-progress {
    display: flex; gap: 8px; padding: 14px;
    background: var(--bg); border-radius: var(--r); border: 1px solid var(--border);
}
.sobre-block {
    flex: 1; padding: 12px;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-sm);
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    transition: all var(--t);
}
.sobre-block.is-ready {
    background: var(--green-soft); border-color: rgba(52,211,153,.3);
}
.sobre-block-title { font-size: 11px; color: var(--text-muted); font-weight: 600; letter-spacing: .04em; }
.sobre-block.is-ready .sobre-block-title { color: var(--green); }
.sobre-block-num { font-size: 22px; font-weight: 700; line-height: 1; }
.sobre-block-status { font-size: 11px; color: var(--text-dim); }
.sobre-block.is-ready .sobre-block-status { color: var(--green); }

/* ============ DETAIL ============ */
.back-link {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--text-muted); text-decoration: none; font-size: 13px; margin-bottom: 16px;
    transition: color var(--t);
}
.back-link:hover { color: var(--text); }

.detail-header { margin-bottom: 20px; display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.detail-header-main { flex: 1; min-width: 0; }
.detail-header-actions { display: flex; gap: 8px; flex-shrink: 0; }
.detail-badges { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.detail-header h1 { font-size: 24px; font-weight: 700; line-height: 1.25; margin-bottom: 8px; letter-spacing: -.02em; }
.detail-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text-muted); align-items: center; }
.detail-meta .copy-btn {
    background: transparent; border: 1px solid var(--border); color: var(--text-muted);
    padding: 3px 8px; border-radius: 4px; font-family: ui-monospace, monospace; font-size: 12px;
    cursor: pointer; transition: all var(--t);
}
.detail-meta .copy-btn:hover { color: var(--accent); border-color: var(--accent); }

.detail-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; }
.detail-section h2 { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 12px; }

.status-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.status-label { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.status-form { display: flex; gap: 4px; flex-wrap: wrap; }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.info-item { padding: 12px; background: var(--bg); border-radius: var(--r); border: 1px solid var(--border-soft); }
.info-label { font-size: 10px; color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.info-value { font-size: 13px; font-weight: 500; }
.info-value.large { font-size: 20px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }

.text-block {
    background: var(--bg); border: 1px solid var(--border-soft); border-radius: var(--r);
    padding: 14px; font-size: 13px; line-height: 1.65;
    max-height: 480px; overflow-y: auto;
}
.text-block.is-pre { white-space: pre-wrap; font-family: ui-monospace, 'SF Mono', monospace; font-size: 12px; }

/* Markdown rendered */
.md-rendered h1, .md-rendered h2, .md-rendered h3, .md-rendered h4 { font-weight: 700; letter-spacing: -.01em; margin: 16px 0 8px; }
.md-rendered h1 { font-size: 18px; }
.md-rendered h2 { font-size: 16px; color: var(--accent); }
.md-rendered h3 { font-size: 14px; }
.md-rendered h4 { font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.md-rendered p { margin: 8px 0; }
.md-rendered ul, .md-rendered ol { margin: 8px 0 8px 22px; }
.md-rendered li { margin: 3px 0; }
.md-rendered code { background: var(--bg-elev); padding: 1px 6px; border-radius: 4px; font-size: 12px; font-family: ui-monospace, monospace; color: var(--purple); }
.md-rendered pre { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r); padding: 12px; overflow-x: auto; margin: 12px 0; }
.md-rendered pre code { background: none; padding: 0; color: var(--text); }
.md-rendered blockquote { border-left: 3px solid var(--accent); padding-left: 12px; color: var(--text-muted); margin: 8px 0; font-style: italic; }
.md-rendered a { color: var(--accent); text-decoration: none; }
.md-rendered a:hover { text-decoration: underline; }
.md-rendered hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.md-rendered strong { color: var(--text); font-weight: 700; }

/* Inline notas editor */
.notas-editor {
    width: 100%; min-height: 80px;
    background: var(--bg); border: 1px solid var(--border-soft); border-radius: var(--r);
    color: var(--text); padding: 12px; font-size: 13px; line-height: 1.6;
    font-family: inherit; resize: vertical; outline: none;
    transition: border-color var(--t), background var(--t);
}
.notas-editor:focus { border-color: var(--accent); background: var(--bg-elev); }
.notas-status { font-size: 11px; color: var(--text-dim); margin-top: 6px; min-height: 14px; }
.notas-status.is-saving { color: var(--amber); }
.notas-status.is-saved  { color: var(--green); }

/* ============ DOCS ============ */
.doc-list { list-style: none; }
.doc-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 0; border-bottom: 1px solid var(--border-soft); font-size: 13px;
}
.doc-item:last-child { border-bottom: none; }
.doc-icon {
    width: 30px; height: 30px; flex-shrink: 0;
    background: var(--bg-elev); border-radius: var(--r-sm);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
}
.doc-info { flex: 1; min-width: 0; }
.doc-info a { color: var(--text); text-decoration: none; font-weight: 500; word-break: break-word; }
.doc-info a:hover { color: var(--accent); }
.doc-meta { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.doc-actions { flex-shrink: 0; }

.upload-form {
    display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
    margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border);
}
.file-input { font-size: 12px; color: var(--text-muted); }
.file-input::file-selector-button {
    background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-sm);
    color: var(--text); padding: 5px 10px; font-size: 12px; cursor: pointer; margin-right: 8px;
    font-family: inherit;
}

/* ============ TIMELINE ============ */
.timeline { list-style: none; }
.timeline li {
    display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border-soft);
    font-size: 12.5px; align-items: flex-start;
}
.timeline li:last-child { border-bottom: none; }
.tl-icon-glyph { flex-shrink: 0; margin-top: 1px; font-size: 13px; color: var(--text-muted); }
.tl-icon-glyph[data-tipo="nueva"]    { color: var(--accent); }
.tl-icon-glyph[data-tipo="estado"]   { color: var(--purple); }
.tl-icon-glyph[data-tipo="documento"]{ color: var(--green); }
.tl-icon-glyph[data-tipo="alerta"]   { color: var(--red); }
.tl-icon-glyph[data-tipo="sync"]     { color: var(--text-dim); }
.tl-icon-glyph[data-tipo="favorita"] { color: var(--star); }
.tl-icon-glyph[data-tipo="mensaje"]  { color: var(--accent); }
.tl-text { flex: 1; line-height: 1.5; }
.tl-date { color: var(--text-dim); white-space: nowrap; font-size: 11px; }

/* ============ LINKS / TEXT ============ */
.link-accent { color: var(--accent); text-decoration: none; font-size: 13px; font-weight: 500; }
.link-accent:hover { text-decoration: underline; }
.link-muted { color: var(--text-muted); text-decoration: none; font-size: 12px; transition: color var(--t); }
.link-muted:hover { color: var(--text); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 13px; }
.empty-state-sm { padding: 18px 8px; color: var(--text-dim); font-size: 12px; text-align: center; }
.empty-state-icon { font-size: 32px; opacity: .4; margin-bottom: 8px; display: block; }

/* ============ EMPRESA FORM ============ */
.empresa-section { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; margin: 24px 0 12px; }
.empresa-section:first-child { margin-top: 0; }
.empresa-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.empresa-grid label, .empresa-full { display: flex; flex-direction: column; gap: 5px; font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.empresa-full { grid-column: 1 / -1; }
.empresa-grid label .filter-input, .empresa-full .filter-input { width: 100%; min-width: unset; color: var(--text); font-size: 13px; text-transform: none; font-weight: 400; letter-spacing: 0; }
.empresa-textarea { font-family: inherit; resize: vertical; line-height: 1.6; }
.empresa-checks { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--text); }
.empresa-checks label { display: flex; align-items: center; gap: 6px; cursor: pointer; text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--text); }
.empresa-checks input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }

/* ============ ALFRED CHAT PANEL ============ */
.chat-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4); backdrop-filter: blur(2px);
    z-index: 998;
    opacity: 0; pointer-events: none;
    transition: opacity var(--t);
}
.chat-overlay.is-open { opacity: 1; pointer-events: auto; }

.chat-panel {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: min(440px, 95vw);
    background: var(--bg-card);
    border-left: 1px solid var(--border-strong);
    box-shadow: var(--shadow-lg);
    z-index: 999;
    display: flex; flex-direction: column;
    transform: translateX(100%);
    transition: transform var(--t);
}
.chat-panel.is-open { transform: translateX(0); }

.chat-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: var(--bg-glass);
}
.chat-header-left { display: flex; align-items: center; gap: 10px; }
.chat-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: white; font-size: 14px;
    box-shadow: 0 2px 8px rgba(91,140,255,.3);
}
.chat-header-info { display: flex; flex-direction: column; }
.chat-header-name { font-size: 14px; font-weight: 600; }
.chat-header-status { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }
.chat-header-status .alfred-dot { width: 6px; height: 6px; }
.chat-header-actions { display: flex; gap: 4px; }
.chat-close, .chat-tg-link {
    background: transparent; border: 1px solid var(--border); color: var(--text-muted);
    width: 30px; height: 30px; padding: 0; border-radius: var(--r-sm);
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: all var(--t);
    text-decoration: none;
}
.chat-close:hover, .chat-tg-link:hover { color: var(--text); border-color: var(--border-strong); background: var(--bg-hover); }

.chat-context {
    padding: 8px 16px;
    background: var(--accent-soft);
    border-bottom: 1px solid var(--accent-strong);
    font-size: 12px; color: var(--accent);
    display: flex; align-items: center; gap: 6px;
}
.chat-context strong { font-weight: 700; font-family: ui-monospace, monospace; }

.chat-messages {
    flex: 1; overflow-y: auto;
    padding: 16px;
    display: flex; flex-direction: column; gap: 10px;
}
.chat-empty {
    text-align: center; color: var(--text-dim); font-size: 13px; padding: 32px 16px;
    display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.chat-empty .chat-empty-icon { font-size: 28px; opacity: .5; }

.chat-msg {
    max-width: 85%;
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 13px; line-height: 1.5;
    word-wrap: break-word; white-space: pre-wrap;
    animation: msg-in .25s ease-out;
}
@keyframes msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.chat-msg-usuario {
    align-self: flex-end;
    background: var(--accent); color: white;
    border-bottom-right-radius: 4px;
}
.chat-msg-alfred {
    align-self: flex-start;
    background: var(--bg-elev); color: var(--text);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border);
}
.chat-msg-time { font-size: 10px; opacity: .65; margin-top: 4px; }
.chat-msg-ctx { font-size: 10px; opacity: .7; margin-bottom: 4px; font-family: ui-monospace, monospace; }

.chat-quick-actions { padding: 0 16px 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.chat-quick {
    background: var(--bg-elev); border: 1px solid var(--border); color: var(--text-muted);
    padding: 5px 10px; border-radius: 100px; font-size: 11px; cursor: pointer;
    transition: all var(--t); font-family: inherit;
}
.chat-quick:hover { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }

.chat-input-bar {
    padding: 12px 14px; border-top: 1px solid var(--border);
    display: flex; gap: 8px; align-items: flex-end;
    background: var(--bg-card);
}
.chat-input {
    flex: 1; resize: none; max-height: 140px; min-height: 40px;
    background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--r);
    color: var(--text); padding: 10px 12px;
    font-size: 13px; font-family: inherit; line-height: 1.45;
    outline: none; transition: border-color var(--t);
}
.chat-input:focus { border-color: var(--accent); }
.chat-send {
    background: var(--accent); color: white; border: none;
    width: 38px; height: 38px; border-radius: var(--r);
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: all var(--t); flex-shrink: 0;
}
.chat-send:hover { background: var(--accent-hover); }
.chat-send:disabled { opacity: .4; cursor: not-allowed; }

.chat-typing {
    align-self: flex-start;
    padding: 10px 14px;
    background: var(--bg-elev); border: 1px solid var(--border);
    border-radius: 14px; border-bottom-left-radius: 4px;
    display: inline-flex; gap: 4px;
}
.chat-typing span {
    width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted);
    animation: typing 1.2s ease-in-out infinite;
}
.chat-typing span:nth-child(2) { animation-delay: .15s; }
.chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes typing {
    0%,60%,100% { transform: translateY(0); opacity: .4; }
    30%         { transform: translateY(-4px); opacity: 1; }
}

/* ============ TOASTS ============ */
.toast-wrap {
    position: fixed; top: 80px; right: 20px; z-index: 2000;
    display: flex; flex-direction: column; gap: 8px;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    background: var(--bg-card); border: 1px solid var(--border-strong);
    border-left: 3px solid var(--accent);
    border-radius: var(--r);
    padding: 12px 16px; min-width: 240px; max-width: 360px;
    color: var(--text); font-size: 13px;
    box-shadow: var(--shadow-lg);
    display: flex; align-items: center; gap: 10px;
    animation: toast-in .25s ease-out;
}
.toast.is-leaving { animation: toast-out .2s ease-in forwards; }
.toast.toast-success { border-left-color: var(--green); }
.toast.toast-error   { border-left-color: var(--red); }
.toast.toast-warn    { border-left-color: var(--amber); }
.toast .toast-icon { flex-shrink: 0; font-size: 16px; }
@keyframes toast-in  { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { to   { opacity: 0; transform: translateX(20px); } }

/* ============ KEYBOARD SHORTCUTS HELP ============ */
.kbd-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5); backdrop-filter: blur(4px);
    z-index: 1500;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none;
    transition: opacity var(--t);
}
.kbd-overlay.is-open { opacity: 1; pointer-events: auto; }
.kbd-modal {
    background: var(--bg-card); border: 1px solid var(--border-strong);
    border-radius: var(--r-lg); padding: 28px;
    max-width: 460px; width: 90%;
    box-shadow: var(--shadow-lg);
    transform: scale(.95); transition: transform var(--t);
}
.kbd-overlay.is-open .kbd-modal { transform: scale(1); }
.kbd-modal h2 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.kbd-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; }
.kbd-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.kbd-row .kbd-label { color: var(--text-muted); }
kbd {
    background: var(--bg-elev); border: 1px solid var(--border-strong);
    padding: 2px 7px; border-radius: 4px;
    font-size: 11px; font-family: ui-monospace, monospace; font-weight: 600;
    box-shadow: 0 1px 0 var(--border-strong);
    color: var(--text);
}

/* ============ CALENDAR ============ */
.cal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 16px; }
.cal-title { font-size: 20px; font-weight: 700; letter-spacing: -.01em; text-transform: capitalize; }
.cal-nav { display: flex; gap: 6px; align-items: center; }

.cal-grid {
    display: grid; grid-template-columns: repeat(7, 1fr);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
}
.cal-dow {
    padding: 10px;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border);
    font-size: 11px; color: var(--text-muted); font-weight: 600;
    text-transform: uppercase; letter-spacing: .06em;
    text-align: center;
}
.cal-cell {
    min-height: 96px;
    padding: 8px;
    border-bottom: 1px solid var(--border-soft);
    border-right: 1px solid var(--border-soft);
    position: relative;
    display: flex; flex-direction: column; gap: 4px;
}
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell.is-empty { background: var(--bg-soft); opacity: .5; }
.cal-cell.is-today .cal-day { background: var(--accent); color: white; }
.cal-cell.is-past { opacity: .55; }
.cal-day {
    font-size: 12px; font-weight: 600; color: var(--text-muted);
    width: 22px; height: 22px; border-radius: 4px;
    display: inline-flex; align-items: center; justify-content: center;
    font-variant-numeric: tabular-nums;
}
.cal-event {
    background: var(--accent-soft); border: 1px solid var(--accent-strong);
    color: var(--accent);
    padding: 2px 6px; border-radius: 4px;
    font-size: 11px; line-height: 1.3;
    text-decoration: none;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    transition: all var(--t);
    cursor: pointer; display: block;
}
.cal-event:hover { background: var(--accent); color: white; }
.cal-event.is-favorita { border-left: 2px solid var(--star); }
.cal-event-overflow { font-size: 10px; color: var(--text-dim); padding: 0 6px; }

/* ============ FOOTER ============ */
.footer { border-top: 1px solid var(--border-soft); padding: 20px 0; margin-top: 48px; text-align: center; color: var(--text-dim); font-size: 12px; }

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 100px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
    .dashboard-grid, .detail-grid { grid-template-columns: 1fr; }
    .info-grid { grid-template-columns: 1fr 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .filter-input, .search-wrap { width: 100%; max-width: none; }
    .empresa-grid { grid-template-columns: 1fr; }
    .nav-title { display: none; }
    .nav-left { gap: 12px; }
    .nav-links { gap: 0; }
    .nav-link { padding: 6px 10px; font-size: 12px; }
    .alfred-pill-meta { display: none; }
    .lic-card { flex-direction: column; gap: 10px; }
    .lic-card-actions { width: 100%; }
    .upload-form { flex-direction: column; align-items: stretch; }
    .btn-sm { padding: 6px 10px; font-size: 11px; }
    .detail-header { flex-direction: column; }
    .detail-header-actions { width: 100%; }
    .cal-cell { min-height: 64px; }
    .cal-event { font-size: 10px; padding: 1px 4px; }
    .kbd-list { grid-template-columns: 1fr; }
    main.container { padding-top: 18px; }
    .page-header h1 { font-size: 22px; }
    .stat-value { font-size: 26px; }
    .chat-panel { width: 100vw; }
}

@media (max-width: 540px) {
    .info-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-value { font-size: 24px; }
    .filter-tabs { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
    .tab { white-space: nowrap; }
}

/* ============ UTILITY ============ */
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-sm { gap: 8px; }
.gap { gap: 12px; }
.mt-sm { margin-top: 8px; }
.mt { margin-top: 16px; }
.mb-sm { margin-bottom: 8px; }
.mb { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.is-hidden { display: none !important; }

/* Skeleton */
.skeleton {
    background: linear-gradient(90deg, var(--bg-elev) 25%, var(--bg-hover) 50%, var(--bg-elev) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s infinite;
    border-radius: var(--r-sm);
}
@keyframes skeleton-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
