/* ── api_script — R&D Memoria Técnica ─────────────────────────────────────────── */

/* Layout: fixed sidebar + main editor area */
.idi-layout {
    display: flex;
    height: 100%;
    overflow: hidden;
}

/* Left sidebar */
.sidebar {
    width: 300px;
    min-width: 260px;
    max-width: 360px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 12px 14px 10px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.sidebar-header h3 {
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent-color);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

/* ── Sidebar section list items (editor) ────────────────────────────── */
.sidebar-section {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 7px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.12s;
    user-select: none;
}
.sidebar-section:last-child { border-bottom: none; }
.sidebar-section:hover { background: rgba(201,160,67,0.08); }
.sidebar-section.active {
    background: rgba(201,160,67,0.15);
    border-left: 3px solid var(--accent-color);
    padding-left: 9px;
}
.sidebar-section-body { flex: 1; min-width: 0; }
.sidebar-section-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-color);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.section-tick {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 1.5px solid rgba(92,74,42,0.35);
    background: transparent;
    margin-right: 6px;
    vertical-align: middle;
    flex-shrink: 0;
}
.section-tick.done {
    background: #2d7a3e;
    border-color: #2d7a3e;
}
.sidebar-section.active .section-tick { border-color: var(--accent-color); }
.sidebar-section.active .sidebar-section-name { color: var(--accent-color); }
.sidebar-section-foot {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
}
.sidebar-section-meta {
    font-size: 10px;
    color: var(--text-light);
    flex-shrink: 0;
}
.word-bar {
    flex: 1;
    height: 3px;
    background: rgba(92,74,42,0.12);
    border-radius: 2px;
    overflow: hidden;
}
.word-bar-fill {
    height: 100%;
    background: rgba(139,32,32,0.45);
    border-radius: 2px;
    transition: width 0.3s;
}
.word-bar-fill.over { background: var(--danger); }
.sidebar-empty {
    padding: 20px 14px;
    font-size: 12px;
    color: var(--text-light);
    text-align: center;
}

/* ── Sidebar document section ────────────────────────────────────────── */
.sdoc-section {
    border-top: 1px solid var(--border);
    margin-top: 4px;
    padding-top: 2px;
}

.sdoc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px 4px;
}

.sdoc-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent-color);
}

.sdoc-add-btn {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: rgba(201,160,67,0.08);
    color: var(--accent-color);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.sdoc-add-btn:hover {
    background: rgba(201,160,67,0.18);
    color: var(--accent-color);
    border-color: rgba(201,160,67,0.4);
}

.sdoc-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    border-radius: 4px;
    margin: 1px 6px;
    transition: background 0.12s;
}

.sdoc-row:hover {
    background: rgba(201,160,67,0.08);
}

.sdoc-row:hover .sdoc-actions {
    opacity: 1;
}

.sdoc-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sdoc-type {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #C9A043;
}

.sdoc-label {
    font-size: 11px;
    color: #2c3e50;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sdoc-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.sdoc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: rgba(201,160,67,0.07);
    color: var(--accent-color);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.sdoc-btn:hover {
    background: rgba(201,160,67,0.18);
    color: var(--accent-color);
    border-color: rgba(201,160,67,0.4);
}

.sdoc-btn.danger:hover {
    background: rgba(229,62,62,0.12);
    color: #c0392b;
    border-color: rgba(229,62,62,0.35);
}

.sdoc-empty {
    padding: 4px 14px 8px;
    font-size: 11px;
    color: var(--text-light);
    font-style: italic;
}

/* Section list items */
.section-item {
    padding: 4px 16px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.12s, border-color 0.12s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-item:hover { background: rgba(201, 160, 67, 0.07); }

.section-item.active {
    background: rgba(201, 160, 67, 0.12);
    border-left-color: var(--primary-color);
}

.section-item-name {
    flex: 1;
    font-size: 12px;
    color: var(--text-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1;
}

.section-item-meta {
    font-size: 10px;
    color: var(--text-light);
    white-space: nowrap;
    line-height: 1;
}

.section-check {
    font-size: 12px;
    color: var(--success);
    flex-shrink: 0;
}

/* Word count progress bar */
.word-bar {
    height: 2px;
    background: var(--border);
    border-radius: 2px;
    margin: 2px 16px 1px;
    overflow: hidden;
}

.word-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #C9A043, #E8D4A0);
    border-radius: 2px;
    transition: width 0.3s;
}

.word-bar-fill.over { background: var(--danger); }

/* Main editor */
.editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: rgba(245, 240, 230, 0.55);
    backdrop-filter: blur(10px);
}

.editor-toolbar {
    padding: 3px 10px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.editor-toolbar h2 {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-color);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.editor-meta {
    font-size: 11px;
    color: var(--text-light);
    white-space: nowrap;
}

.editor-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 3px 8px;
    gap: 3px;
}

.editor-textarea {
    flex: 1;
    width: 100%;
    resize: none;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 3px 8px;
    font-family: var(--font-body);
    font-size: 12px;
    line-height: 1.2;
    color: var(--text-color);
    background: rgba(245, 240, 230, 0.95);
    transition: border-color 0.15s;
}

.editor-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(201, 160, 67, 0.12);
}

.editor-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
}

.word-count-display {
    font-size: 12px;
    color: var(--text-light);
}

.word-count-display.over { color: var(--danger); font-weight: 600; }

/* AI Chat panel — positioned relative to viewport, respecting header/footer */
.chat-panel {
    position: fixed;
    top: var(--navbar-h);
    right: -48%;
    width: 45%;
    min-width: 340px;
    height: calc(100vh - var(--navbar-h) - var(--footer-h));
    z-index: 150;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid var(--glass-border);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.12);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.chat-panel.open { right: 0; }

.chat-panel-header {
    padding: 12px 16px 10px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.chat-panel-header h3 {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-color);
    flex: 1;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-msg {
    max-width: 92%;
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 12px;
    line-height: 1;
}

.chat-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--accent-color), var(--primary-color));
    color: #fff;
    border-bottom-right-radius: 3px;
}

.chat-msg.assistant {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border);
    color: var(--text-color);
    border-bottom-left-radius: 3px;
}

.chat-msg.assistant.streaming { opacity: 0.85; }

.chat-msg pre {
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    font-family: var(--font-body);
}

.chat-accept-btn {
    margin-top: 8px;
    display: block;
}

.chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.chat-textarea {
    width: 100%;
    height: 72px;
    resize: none;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.9);
    transition: border-color 0.15s;
}

.chat-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(201, 160, 67, 0.12);
}

.chat-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Views */
.view { display: none; height: 100%; }
.view.active { display: flex; flex-direction: column; height: 100%; width: 100%; }
#viewEditor.active { flex-direction: row; }

/* Grants / Projects list view */
.list-view {
    padding: 24px;
    overflow-y: auto;
    flex-direction: column;
    gap: 20px;
}

.page-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.card {
    background: #F5F0E6;
    backdrop-filter: blur(16px);
    border: 1px solid rgba(201, 160, 67, 0.3);
    border-radius: 12px;
    padding: 18px 20px;
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    position: relative;
}

.card:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4); }

.card-title {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 4px;
}

.card-sub {
    font-size: 12px;
    color: #555;
    margin-bottom: 10px;
}

.card-stats {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: #555;
}

/* Card actions overlay */
.card-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}

.card:hover .card-actions { opacity: 1; }

/* Criteria tooltip */
.criteria-hint {
    font-size: 11px;
    color: var(--text-light);
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    margin-top: 4px;
    line-height: 1.5;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-light);
}

.empty-state svg { opacity: 0.3; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* Empty states inside list-view sit on the gradient — need white text + span full grid */
.list-view .empty-state {
    color: rgba(255, 255, 255, 0.75);
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Empty states inside grant detail tab content also sit on the gradient */
#viewGrantDetail .empty-state {
    color: rgba(255, 255, 255, 0.75);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
    flex-shrink: 0;
}

.tab-btn {
    padding: 9px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.55);
    cursor: pointer;
    transition: color 0.12s, border-color 0.12s;
    margin-bottom: -1px;
}

.tab-btn:hover { color: rgba(255, 255, 255, 0.85); }
.tab-btn.active { color: #fff; border-bottom-color: rgba(255, 255, 255, 0.9); }

/* ── Lang switch ── */
.lang-switch {
    display: flex;
    gap: 2px;
    background: rgba(70, 130, 180, 0.08);
    border-radius: 6px;
    padding: 2px;
}

.lang-btn {
    background: none;
    border: none;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    color: var(--text-light);
    transition: all 0.2s;
    font-family: var(--font-body);
    line-height: 1.4;
}

.lang-btn.active {
    background: white;
    color: var(--accent-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ── Grants list view — improved cards ──────────────────────────────────── */

.grants-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.grants-meta {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 4px;
    letter-spacing: 0.2px;
}

.grants-new-btn {
    white-space: nowrap;
    flex-shrink: 0;
}

.grants-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

/* Grant Card */
.grant-card {
    background: #F5F0E6;
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s cubic-bezier(0.2, 0, 0.3, 1), box-shadow 0.15s;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(201, 160, 67, 0.3);
    display: flex;
    flex-direction: column;
}

.grant-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.22);
}

/* Colored gradient header strip */
.grant-card-hd {
    padding: 3px 18px;
    position: relative;
    min-height: 52px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    overflow: hidden;
}

/* Dot-grid texture overlay */
.grant-card-hd::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
    background-size: 16px 16px;
    pointer-events: none;
}

/* Decorative arc */
.grant-card-hd::after {
    content: '';
    position: absolute;
    right: -20px;
    bottom: -30px;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 50%;
    pointer-events: none;
}

.grant-hd-cdti  { background: linear-gradient(135deg, #1a3a5c 0%, #2d6fa8 100%); }
.grant-hd-ccaa  { background: linear-gradient(135deg, #1a4731 0%, #16a34a 100%); }
.grant-hd-h2020 { background: linear-gradient(135deg, #2e1065 0%, #7c3aed 100%); }
.grant-hd-other { background: linear-gradient(135deg, #7c2d12 0%, #c05621 100%); }

/* Edit / delete buttons — visible on hover */
.grant-hd-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 1;
}

.grant-card:hover .grant-hd-actions { opacity: 1; }

.btn-glass {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.12s;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.btn-glass:hover            { background: rgba(255, 255, 255, 0.25); }
.btn-glass.danger:hover     { background: rgba(220, 38, 38, 0.45); color: #fff; }

/* Program label + year inside header */
.grant-hd-program {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.8px;
    color: rgba(255, 255, 255, 0.65);
    line-height: 1;
    margin-bottom: 4px;
    position: relative;
    z-index: 1;
}

.grant-hd-year {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.95);
    line-height: 1;
    position: relative;
    z-index: 1;
}

.grant-hd-noyear {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.75);
    font-style: italic;
}

/* Card body */
.grant-card-bd {
    padding: 3px 18px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.grant-card-name {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 700;
    color: var(--text-color);
    line-height: 1;
    margin-bottom: 3px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.grant-card-desc {
    font-size: 12px;
    color: var(--text-light);
    line-height: 1;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Stats footer row */
.grant-card-ft {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-top: 3px;
    margin-top: 3px;
    border-top: 1px solid rgba(201, 160, 67, 0.1);
}

.grant-stat-pill {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-light);
}

.grant-stat-pill strong {
    font-weight: 700;
    color: var(--text-color);
    font-size: 13px;
}

.grant-stat-pill svg { opacity: 0.4; }

.grant-card-arrow {
    margin-left: auto;
    color: var(--primary-color);
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity 0.15s, transform 0.15s;
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
}

.grant-card:hover .grant-card-arrow {
    opacity: 1;
    transform: translateX(0);
}

/* ── Projects list view ── */
.projects-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.projects-meta {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 4px;
    letter-spacing: 0.2px;
}

.projects-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

/* Project Card — mirrors grant-card pattern */
.project-card {
    background: #F5F0E6;
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s cubic-bezier(0.2, 0, 0.3, 1), box-shadow 0.15s;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(201, 160, 67, 0.3);
    display: flex;
    flex-direction: column;
}

.project-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.22);
}

.project-card-hd {
    padding: 3px 18px;
    position: relative;
    min-height: 48px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    overflow: hidden;
}

.project-card-hd::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
    background-size: 16px 16px;
    pointer-events: none;
}

.project-card-hd::after {
    content: '';
    position: absolute;
    right: -20px;
    bottom: -30px;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 50%;
    pointer-events: none;
}

.project-hd-draft     { background: linear-gradient(135deg, #374151 0%, #6b7280 100%); }
.project-hd-in_review { background: linear-gradient(135deg, #78400a 0%, #c97d30 100%); }
.project-hd-submitted { background: linear-gradient(135deg, #1a3a5c 0%, #2d6fa8 100%); }
.project-hd-approved  { background: linear-gradient(135deg, #1a4731 0%, #16a34a 100%); }
.project-hd-rejected  { background: linear-gradient(135deg, #7c1d1d 0%, #dc2626 100%); }

.project-hd-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 1;
}

.project-card:hover .project-hd-actions { opacity: 1; }

.project-hd-label {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.8px;
    color: rgba(255, 255, 255, 0.65);
    line-height: 1;
    margin-bottom: 4px;
    position: relative;
    z-index: 1;
}

.project-hd-name {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.95);
    line-height: 1.2;
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.project-hd-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 0.2px;
    line-height: 1.5;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.project-hd-badge.granted { background: rgba(22, 163, 74, 0.35); }
.project-hd-badge.denied  { background: rgba(220, 38, 38, 0.35); }
.project-hd-badge.ref     { background: rgba(255, 255, 255, 0.22); }
.project-hd-badge.docx    { background: rgba(139, 92, 246, 0.35); }

.project-card-bd {
    padding: 3px 18px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.project-card-name {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 700;
    color: var(--text-color);
    line-height: 1;
    margin-bottom: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.project-card-sub {
    font-size: 12px;
    color: var(--text-light);
    line-height: 1;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-progress {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 4px 0 0;
    overflow: hidden;
}

.project-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #C9A043, #E8D4A0);
    border-radius: 2px;
    transition: width 0.3s;
}

.project-card-ft {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 3px;
    margin-top: 3px;
    border-top: 1px solid rgba(201, 160, 67, 0.1);
}

.project-stat-pill {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-light);
}

.project-stat-pill strong {
    font-weight: 700;
    color: var(--text-color);
    font-size: 13px;
}

.project-stat-pill svg { opacity: 0.4; }

.project-progress-pct {
    font-size: 11px;
    color: var(--text-light);
}

.project-card-arrow {
    margin-left: auto;
    color: var(--primary-color);
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity 0.15s, transform 0.15s;
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
}

.project-card:hover .project-card-arrow {
    opacity: 1;
    transform: translateX(0);
}

/* ── Upload spinner overlay on project card ── */
.upload-overlay {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: rgba(28,24,18,0.72);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    z-index: 10;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    pointer-events: all;
}

.upload-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255,255,255,0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ── Compact DOCX drop zone (project panel) ── */
.docx-drop-zone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: rgba(201, 160, 67, 0.03);
    user-select: none;
    font-size: 0.8rem;
    color: var(--text-light);
}

.docx-drop-zone:hover {
    border-color: var(--primary-color);
    background: rgba(201, 160, 67, 0.07);
    color: var(--text-color);
}

.docx-drop-zone.drag-over {
    border-color: var(--primary-color);
    background: rgba(201, 160, 67, 0.12);
    border-style: solid;
}

.docx-drop-zone.has-file {
    border-color: var(--success);
    border-style: solid;
    background: rgba(22, 163, 74, 0.05);
    color: var(--success);
}

/* ── Drag-and-drop file zone ── */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: rgba(201, 160, 67, 0.03);
    text-align: center;
    user-select: none;
}

.drop-zone:hover {
    border-color: var(--primary-color);
    background: rgba(201, 160, 67, 0.07);
}

.drop-zone.drag-over {
    border-color: var(--primary-color);
    background: rgba(201, 160, 67, 0.12);
    border-style: solid;
}

.drop-zone.has-file {
    border-color: var(--success);
    border-style: solid;
    background: rgba(22, 163, 74, 0.04);
}

.drop-zone-icon {
    color: var(--text-light);
    opacity: 0.5;
    margin-bottom: 2px;
    pointer-events: none;
}

.drop-zone.drag-over .drop-zone-icon,
.drop-zone:hover .drop-zone-icon {
    opacity: 0.75;
    color: var(--primary-color);
}

.drop-zone-primary {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-color);
    pointer-events: none;
}

.drop-zone-secondary {
    font-size: 11px;
    color: var(--text-light);
    pointer-events: none;
}

.drop-zone-filename {
    font-size: 12px;
    font-weight: 600;
    color: var(--success);
    margin-top: 4px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    pointer-events: none;
}

/* ── Help panel ── */
.help-panel {
    width: 45%;
    min-width: 340px;
}

/* ── PDF preview panel ── */
.pdf-panel {
    width: 72%;
    min-width: 480px;
    right: -75%;
    display: flex;
    flex-direction: column;
    height: 100vh;
}
.pdf-panel.open { right: 0; }
.pdf-panel .panel-body {
    padding: 0;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.doc-tab {
    flex: 1;
    padding: 6px 4px;
    font-size: 11px;
    font-weight: 600;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    color: var(--text-light);
    transition: color 0.15s, border-color 0.15s;
}
.doc-tab:hover { color: var(--text-color); }
.doc-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.doc-md-body { font-size: 12px; line-height: 1; color: var(--text-color); }
.doc-md-body h1,.doc-md-body h2,.doc-md-body h3,.doc-md-body h4 { font-weight: 700; margin: 6px 0 2px; color: var(--accent); }
.doc-md-body h1 { font-size: 13px; }
.doc-md-body h2 { font-size: 12px; }
.doc-md-body h3,.doc-md-body h4 { font-size: 11px; }
.doc-md-body p { margin: 0 0 3px; }
.doc-md-body ul { margin: 0 0 3px; padding-left: 14px; }
.doc-md-body li { margin-bottom: 1px; }
.doc-md-body strong { font-weight: 700; }
.doc-md-body em { font-style: italic; opacity: .8; }
.doc-md-body code { font-family: monospace; font-size: 11px; background: rgba(0,0,0,.07); border-radius: 2px; padding: 0 3px; }
.doc-md-body .md-sep { height: 4px; }
.pdf-embed {
    display: block;
    width: 100%;
    height: 100%;
    border: none;
    background: #fff;
}
.pdf-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 12px;
    color: var(--text-light);
    font-size: 14px;
    padding: 24px;
    text-align: center;
}
.pdf-fallback a {
    color: var(--accent);
}

.help-body {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.help-section {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.help-section:last-child {
    border-bottom: none;
}

.help-heading {
    font-family: var(--font-heading);
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.help-section p {
    font-size: 0.8125rem;
    color: var(--text-color);
    line-height: 1.55;
}

.help-list {
    list-style: disc;
    padding-left: 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.help-list li {
    font-size: 0.8125rem;
    color: var(--text-color);
    line-height: 1.5;
}

/* ── Document list table ─────────────────────────────────────────────────── */
.doc-table-wrap {
    background: rgba(0,0,0,0.18);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 10px;
    overflow: hidden;
}
.doc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}
.doc-table th {
    text-align: left;
    font-size: 10px;
    font-weight: 700;
    color: rgba(255,255,255,0.65);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 6px 10px;
    background: rgba(0,0,0,0.18);
    border-bottom: 1px solid rgba(255,255,255,0.12);
    line-height: 1;
}
.doc-table td {
    padding: 6px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    vertical-align: middle;
    color: rgba(255,255,255,0.88);
    line-height: 1.3;
}
.doc-table tr:last-child td { border-bottom: none; }
.doc-table tr:hover td { background: rgba(255,255,255,0.05); }
.doc-table .doc-label {
    font-weight: 500;
    color: #fff;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.doc-type-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    background: rgba(201,160,67,0.25);
    color: #E8D4A0;
    border: 1px solid rgba(201,160,67,0.35);
    white-space: nowrap;
}
.doc-year { font-size: 12px; color: rgba(255,255,255,0.62); white-space: nowrap; }
.doc-status { font-size: 11px; white-space: nowrap; }
.doc-ok   { color: #6fcf97; }
.doc-warn { color: rgba(255,255,255,0.38); }
.doc-rag  { color: #7eb8f7; margin-left: 8px; }
.doc-processing { color: #f0c040; display: inline-flex; align-items: center; gap: 5px; }
.spin-icon { animation: spin 1s linear infinite; display: inline-block; }
.doc-actions { white-space: nowrap; text-align: right; }
.doc-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.65);
    cursor: pointer;
    font-size: 0;
    text-decoration: none;
    margin-left: 4px;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.doc-action-btn:hover {
    background: rgba(201,160,67,0.22);
    color: #E8D4A0;
    border-color: rgba(201,160,67,0.4);
}
.doc-action-btn.danger:hover {
    background: rgba(229,62,62,0.18);
    color: #fc8181;
    border-color: rgba(229,62,62,0.35);
}

/* ── Timeline (Calendario) ───────────────────────────────────────────────── */
.timeline {
    padding: 16px 8px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.tl-item {
    display: flex;
    gap: 14px;
    min-height: 52px;
}

.tl-track {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    width: 18px;
    padding-top: 4px;
}

.tl-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--primary-color, #4682b4);
    background: transparent;
    flex-shrink: 0;
    transition: box-shadow 0.2s;
}

.tl-dot.past {
    background: var(--primary-color, #4682b4);
}

.tl-dot.alert {
    border-color: #fbbf24;
    box-shadow: 0 0 0 3px rgba(251,191,36,.30);
}

.tl-dot.past.alert {
    background: #fbbf24;
}

.tl-line {
    width: 2px;
    flex: 1;
    background: rgba(255,255,255,0.12);
    margin-top: 4px;
    margin-bottom: 0;
    min-height: 20px;
}

.tl-content {
    flex: 1;
    padding-bottom: 20px;
    min-width: 0;
}

.tl-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.tl-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: rgba(255,255,255,0.88);
}

.tl-name.alert {
    color: #fcd34d;
}

.tl-date {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.45);
    white-space: nowrap;
}

.tl-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    white-space: nowrap;
}

.tl-badge.past {
    color: rgba(255,255,255,0.35);
    background: rgba(255,255,255,0.06);
}

.tl-badge.soon {
    color: #fbbf24;
    background: rgba(251,191,36,0.12);
}

.tl-badge.today {
    color: #6fcf97;
    background: rgba(111,207,151,0.12);
}

.tl-now-marker {
    color: var(--accent-color, #7eb8f7);
    font-weight: 700;
    font-size: 11px;
}

.tl-desc {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.45);
    margin-top: 4px;
    line-height: 1.4;
}

.tl-link {
    display: inline-flex;
    align-items: center;
    color: rgba(255,255,255,0.45);
    text-decoration: none;
    margin-left: 2px;
    transition: color 0.15s;
}

.tl-link:hover {
    color: #E8D4A0;
}

.tl-edit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 5px;
    border: 1px solid rgba(255,255,255,0.10);
    background: rgba(255,255,255,0.05);
    color: rgba(255,255,255,0.40);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
    margin-left: auto;
    flex-shrink: 0;
}

.tl-item:hover .tl-edit-btn {
    opacity: 1;
}

.tl-edit-btn:hover {
    background: rgba(201,160,67,0.22);
    color: #E8D4A0;
    border-color: rgba(201,160,67,0.4);
}

/* ── Template table (Plantillas tab) ────────────────────────────────── */
.tpl-done-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #6fcf97;
}

.tpl-done-cell {
    text-align: center;
    width: 32px;
}

/* ── Confirm dialog overlay ── */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.confirm-box {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px 28px 20px;
    min-width: 280px;
    max-width: 360px;
    box-shadow: 0 8px 32px rgba(201,160,67,0.18);
}

.confirm-msg {
    font-size: 14px;
    color: var(--accent-color);
    margin: 0 0 18px;
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ── Preview panel ── */
#previewPanel .panel-body {
    background: #fff;
    color: #1C1812;
    border-radius: 0;
    overflow-y: auto;
    padding: 16px 20px;
    font-family: var(--font-body);
    font-size: 13px;
    line-height: 1;
}
#previewPanel .panel-body h1 { font-size: 1rem; font-weight: 700; margin: 0 0 3px; color: #8B2020; }
#previewPanel .panel-body h2 { font-size: 0.9rem; font-weight: 700; margin: 6px 0 3px; color: #8B2020; }
#previewPanel .panel-body h3 { font-size: 0.85rem; font-weight: 700; margin: 4px 0 3px; color: #5C4A2A; }
#previewPanel .panel-body p  { margin: 0 0 3px; }
#previewPanel .panel-body ul { margin: 0 0 3px; padding-left: 16px; }
#previewPanel .panel-body li { margin-bottom: 2px; }
#previewPanel .panel-body strong { font-weight: 700; }
#previewPanel .panel-body em { font-style: italic; color: #5C4A2A; }
#previewPanel .panel-body code { font-family: monospace; font-size: 11px; background: #f0f0e8; padding: 0 4px; border-radius: 2px; }
#previewPanel .panel-header {
    background: rgba(26, 58, 92, 0.92);
    color: #fff;
}
#previewPanel .panel-header h2 { color: #fff; }
#previewPanel .panel-close { color: rgba(255,255,255,0.75); }

/* ── Section slug row (in section panel) ── */
.section-slug-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    padding: 7px 10px;
    margin-bottom: 12px;
}
.section-slug-label {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    white-space: nowrap;
    flex-shrink: 0;
}
.section-slug-code {
    flex: 1;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #7dd3fc;
    word-break: break-all;
    min-height: 16px;
}
.section-slug-copy {
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255,255,255,0.45);
    padding: 2px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    transition: color 0.15s;
}
.section-slug-copy:hover { color: #7dd3fc; }

/* ── Section tree (in grant detail tab) ── */
.section-tree { padding: 4px 0; }
.section-tree-item { border-bottom: 1px solid rgba(255,255,255,0.05); }
.section-tree-item:last-child { border-bottom: none; }
.section-tree-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 10px;
    transition: background 0.15s;
}
.section-tree-row:hover { background: rgba(255,255,255,0.05); }
.section-tree-icon {
    color: rgba(255,255,255,0.35);
    font-size: 11px;
    width: 12px;
    flex-shrink: 0;
    text-align: center;
}
.section-tree-toggle {
    cursor: pointer;
    color: rgba(255,255,255,0.55);
    transition: color 0.12s;
}
.section-tree-toggle:hover { color: var(--accent-color); }
.section-tree-info { flex: 1; min-width: 0; }
.section-tree-name {
    font-size: 13px;
    font-weight: 500;
    color: rgba(255,255,255,0.9);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.section-tree-slug {
    font-family: 'Courier New', monospace;
    font-size: 10px;
    color: rgba(125,211,252,0.65);
    display: block;
    margin-top: 1px;
}
.section-tree-meta {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.section-meta-pill {
    font-size: 10px;
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.55);
    padding: 1px 6px;
    border-radius: 10px;
    white-space: nowrap;
}
.section-tree-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* ── Sections toolbar (export / import) ── */
.sections-toolbar {
    display: flex;
    gap: 4px;
    padding: 4px 0 8px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 4px;
}
.sections-toolbar .app-header-btn {
    color: rgba(255,255,255,0.7);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 8px;
}
.sections-toolbar .app-header-btn:hover {
    color: #fff;
    border-color: rgba(255,255,255,0.4);
    background: rgba(201,160,67,0.2);
}

/* ── Grant detail tab rows ──────────────────────────────────────────────── */

/* Section rows (Secciones tab) */
.section-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    transition: background 0.15s;
}
.section-row:last-child { border-bottom: none; }
.section-row:hover { background: rgba(255,255,255,0.04); }
.section-row-order {
    width: 24px;
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 700;
    color: var(--accent-color);
    text-align: center;
    opacity: 0.8;
}
.section-row-info { flex: 1; min-width: 0; }
.section-row-name {
    font-size: 13px;
    font-weight: 500;
    color: rgba(255,255,255,0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.section-row-meta {
    display: inline-block;
    font-size: 10px;
    color: rgba(255,255,255,0.45);
    background: rgba(255,255,255,0.07);
    border-radius: 10px;
    padding: 1px 6px;
    margin-top: 2px;
    margin-right: 4px;
}

/* Document rows (Documentos tab) */
.doc-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    transition: background 0.15s;
}
.doc-row:last-child { border-bottom: none; }
.doc-row:hover { background: rgba(255,255,255,0.04); }
.doc-row-info { flex: 1; min-width: 0; }
.doc-row-label {
    font-size: 13px;
    font-weight: 500;
    color: rgba(255,255,255,0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.doc-row-meta {
    font-size: 10px;
    color: rgba(255,255,255,0.45);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.doc-row-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* Milestone rows (Calendario tab) */
.milestone-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    border-left: 3px solid transparent;
    transition: background 0.15s;
}
.milestone-row:last-child { border-bottom: none; }
.milestone-row:hover { background: rgba(255,255,255,0.04); }
.milestone-row.milestone-alert {
    border-left-color: var(--accent-color);
    background: rgba(201,160,67,0.04);
}
.milestone-date {
    width: 80px;
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 700;
    color: var(--accent-color);
    padding-top: 1px;
}
.milestone-info { flex: 1; min-width: 0; }
.milestone-name {
    font-size: 13px;
    font-weight: 500;
    color: rgba(255,255,255,0.9);
}
.milestone-desc {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    margin-top: 2px;
    line-height: 1.4;
}
.milestone-url {
    display: inline-block;
    font-size: 11px;
    color: #7dd3fc;
    text-decoration: none;
    margin-top: 3px;
}
.milestone-url:hover { text-decoration: underline; }

/* Template rows (Plantillas tab) */
.template-row-actions { display: flex; gap: 4px; flex-shrink: 0; }
.tpl-done-cb { cursor: pointer; accent-color: var(--accent-color); flex-shrink: 0; }
.tpl-export-radio { cursor: pointer; accent-color: #6ee7b7; flex-shrink: 0; }
.tpl-export-radio:disabled { cursor: not-allowed; opacity: 0.4; }
.template-export { background: rgba(110,231,183,0.05); }
.template-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    transition: background 0.15s;
}
.template-row:last-child { border-bottom: none; }
.template-row:hover { background: rgba(255,255,255,0.04); }
.template-row.template-done .template-row-name { color: rgba(255,255,255,0.5); text-decoration: line-through; }
.template-row-info { flex: 1; min-width: 0; }
.template-row-name {
    font-size: 13px;
    font-weight: 500;
    color: rgba(255,255,255,0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.template-row-desc {
    font-size: 11px;
    color: rgba(255,255,255,0.45);
    margin-top: 2px;
}
.template-row-url {
    display: inline-block;
    font-size: 11px;
    color: #7dd3fc;
    text-decoration: none;
    margin-top: 3px;
}
.template-row-url:hover { text-decoration: underline; }

/* ── Breadcrumb ─────────────────────────────────────────────────────────── */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: rgba(245,240,230,0.55);
    padding: 4px 0 2px;
    flex-wrap: wrap;
    line-height: 1;
}
.breadcrumb-sep {
    color: rgba(201,160,67,0.5);
    font-size: 10px;
}
.breadcrumb-item {
    cursor: pointer;
    color: rgba(245,240,230,0.7);
    transition: color 0.15s;
}
.breadcrumb-item:hover { color: #C9A043; }
.breadcrumb-item.current {
    color: #C9A043;
    font-weight: 600;
    cursor: default;
}

/* ── Orden cards ─────────────────────────────────────────────────────────── */
.orden-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.orden-card {
    background: #F5F0E6;
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s cubic-bezier(0.2, 0, 0.3, 1), box-shadow 0.15s;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(201, 160, 67, 0.3);
    display: flex;
    flex-direction: column;
}
.orden-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
}
.orden-card-hd {
    padding: 16px 18px 12px;
    background: linear-gradient(135deg, #1C1812 0%, #2E2416 100%);
    border-bottom: 1px solid rgba(201,160,67,0.25);
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    overflow: hidden;
}
.orden-card-hd::after {
    content: '';
    position: absolute;
    right: -20px;
    bottom: -30px;
    width: 100px;
    height: 100px;
    background: rgba(201,160,67,0.07);
    border-radius: 50%;
    pointer-events: none;
}
.orden-card-icon {
    font-size: 28px;
    line-height: 1;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}
.orden-card-title {
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 700;
    color: #C9A043;
    line-height: 1.2;
    position: relative;
    z-index: 1;
}
.orden-card-bd {
    padding: 10px 18px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.orden-card-desc {
    font-size: 12px;
    color: var(--text-light);
    line-height: 1.3;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.orden-card-ft {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 8px;
    border-top: 1px solid rgba(201,160,67,0.18);
    font-size: 12px;
    color: var(--text-light);
}
.orden-card-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 2;
}
.orden-card:hover .orden-card-actions { opacity: 1; }

/* ── Canon cards ─────────────────────────────────────────────────────────── */
.canon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.canon-card {
    background: #F5F0E6;
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s cubic-bezier(0.2, 0, 0.3, 1), box-shadow 0.15s;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(201, 160, 67, 0.3);
    display: flex;
    flex-direction: column;
}
.canon-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
}
.canon-card-hd {
    padding: 12px 18px 10px;
    background: linear-gradient(135deg, #2C4A7C 0%, #1a3060 100%);
    border-bottom: 1px solid rgba(201,160,67,0.2);
    position: relative;
    overflow: hidden;
}
.canon-card-hd::after {
    content: '';
    position: absolute;
    right: -20px;
    bottom: -30px;
    width: 100px;
    height: 100px;
    background: rgba(255,255,255,0.06);
    border-radius: 50%;
    pointer-events: none;
}
.canon-card-title {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 700;
    color: rgba(245,240,230,0.95);
    line-height: 1.2;
    position: relative;
    z-index: 1;
}
.canon-card-bd {
    padding: 10px 18px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.canon-card-desc {
    font-size: 12px;
    color: var(--text-light);
    line-height: 1.3;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.canon-card-ft {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 8px;
    border-top: 1px solid rgba(201,160,67,0.18);
    font-size: 12px;
    color: var(--text-light);
}
.canon-card-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 2;
}
.canon-card:hover .canon-card-actions { opacity: 1; }

/* ── Auth pages (login, 2FA) ─────────────────────────────────────────────── */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 24px 16px;
}
.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--glass-bg, rgba(28,24,18,.88));
    border: 1px solid var(--border, rgba(201,160,67,.2));
    border-radius: 16px;
    padding: 32px 28px;
    box-shadow: 0 8px 32px rgba(0,0,0,.5);
    backdrop-filter: blur(12px);
}
.auth-logo {
    text-align: center;
    margin-bottom: 28px;
}
.auth-logo img { margin-bottom: 12px; }
.auth-logo h1 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-color, #C9A043);
    margin: 0 0 6px;
}
.auth-logo p {
    font-size: 0.8rem;
    color: rgba(245,240,230,.55);
    margin: 0;
}
.auth-submit {
    width: 100%;
    margin-top: 8px;
    padding: 10px;
    font-size: 0.9rem;
}
.auth-error {
    padding: 8px 12px;
    background: rgba(192,57,43,.2);
    border: 1px solid rgba(192,57,43,.4);
    border-radius: 8px;
    color: #e88;
    font-size: 0.8rem;
    margin-bottom: 10px;
}
.auth-success {
    padding: 8px 12px;
    background: rgba(39,174,96,.2);
    border: 1px solid rgba(39,174,96,.4);
    border-radius: 8px;
    color: #6ec99a;
    font-size: 0.8rem;
    margin-bottom: 10px;
}
.auth-link {
    color: rgba(245,240,230,.6);
    text-decoration: underline;
}
.auth-link:hover { color: var(--accent-color, #C9A043); }
.auth-back {
    display: block;
    text-align: center;
    margin-top: 16px;
    font-size: 0.8rem;
    color: rgba(245,240,230,.55);
    text-decoration: none;
}
.auth-back:hover { color: var(--accent-color, #C9A043); }
.auth-footer-note {
    text-align: center;
    margin-top: 16px;
    font-size: 0.75rem;
    color: rgba(245,240,230,.4);
}
.auth-skip {
    width: 100%;
    background: transparent;
    border: 1px solid rgba(245,240,230,.2);
    color: rgba(245,240,230,.6);
}
.auth-skip:hover { border-color: var(--accent-color, #C9A043); color: var(--accent-color, #C9A043); }
.spinner-large {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(201,160,67,.2);
    border-top-color: var(--accent-color, #C9A043);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* "Sin clasificar" virtual canon */
.sin-clasificar-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(201,160,67,0.2);
}
.sin-clasificar-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: rgba(245,240,230,0.45);
    margin-bottom: 12px;
}

/* ── Panel hide position fix ─────────────────────────────────────────────
   pibico.css uses right:-50% which only hides a 45%-wide panel.
   Responsive rules widen panels to 60/90/100% — override to -110% so
   the panel is always fully off-screen regardless of its width.        ── */
.slide-panel { right: -110%; }

/* ═══════════════════════════════════════════════════════════════════════════
   LANDING PAGE LAYOUT — overrides app-layout overflow lock
   ═══════════════════════════════════════════════════════════════════════════ */

.landing-layout {
  height: auto !important;
  min-height: 100vh;
  overflow: visible !important;
}

.landing-layout .app-main {
  overflow-y: visible !important;
  flex: none !important;
  height: auto !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE-FIRST RESPONSIVE — breakpoints: 480 / 640 / 900
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── 900px: compact navbar, narrower panels ─────────────────────────────── */
@media (max-width: 900px) {
  .app-header { padding: 0 12px; }

  /* Hide less-critical nav buttons on mid-size screens */
  .lang-switch { display: none; }

  .slide-panel { width: 60%; max-width: none; }
  .help-panel  { width: 60%; }

  .grants-grid,
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
  }

  .orden-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
  }

  .canon-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
  }

  /* Editor: sidebar collapses to 200px */
  .editor-sidebar { min-width: 180px; max-width: 200px; }
}

/* ── 640px: tablet ──────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  :root {
    --navbar-h: 52px;
    --footer-h: 38px;
  }

  .app-header { padding: 0 10px; gap: 4px; }
  .app-header-title span { display: none; } /* icon only on small */
  .credits-badge { font-size: 10px; padding: 2px 7px; }

  /* Panels: full width on tablet */
  .slide-panel { width: 90%; max-width: none; }
  .help-panel  { width: 90%; }

  /* Page headers */
  .grants-page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
  }
  .grants-new-btn { align-self: flex-start; }

  /* Grids: 2 columns */
  .grants-grid,
  .card-grid,
  .orden-grid,
  .canon-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 12px;
  }

  /* Editor: stack sidebar above editor area */
  .idi-layout.editor-layout,
  .editor-container {
    flex-direction: column !important;
  }
  .editor-sidebar {
    min-width: unset !important;
    max-width: unset !important;
    width: 100% !important;
    height: 220px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-y: auto;
  }
  .editor-area { flex: 1; min-height: 300px; }

  /* Chat panel: full screen on mobile */
  .chat-panel {
    width: 100% !important;
    border-left: none;
  }

  /* Tables: horizontal scroll */
  .doc-table-wrap,
  .timeline-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Grant detail tabs: scroll horizontally */
  .grant-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }
  .grant-tab { white-space: nowrap; }

  /* Form rows: stack */
  .form-row { flex-direction: column; gap: 0; }
  .form-row .form-group { width: 100% !important; }
}

/* ── 480px: mobile ──────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .app-header-actions { gap: 2px; }

  /* Single column grids on phones */
  .grants-grid,
  .card-grid,
  .orden-grid,
  .canon-grid {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  /* Panels: fully full-screen */
  .slide-panel,
  .help-panel {
    width: 100%;
    border-left: none;
    border-radius: 0;
  }

  /* Section tree: full width */
  .sections-toolbar { flex-wrap: wrap; gap: 6px; }

  /* Editor sidebar: shorter on small phones */
  .editor-sidebar { height: 180px; }

  /* Auth card: remove horizontal padding */
  .auth-card { padding: 24px 16px; }

  /* Breadcrumb: truncate */
  .breadcrumb {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
  }

  /* Page title: smaller */
  .page-title { font-size: 1.2rem !important; }

  /* Grant card: compact */
  .grant-card-hd { padding: 10px 12px 8px; }
  .grant-card-bd { padding: 8px 12px 10px; }

  /* Summary stats: wrap */
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }

  /* Footer: compact */
  .app-footer { font-size: 11px; padding: 0 10px; }
  .footer-sep:last-of-type,
  .app-footer span:last-child { display: none; }
}

/* ── Print / reduce-motion ──────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .slide-panel { transition: none; }
  * { animation-duration: 0.01ms !important; }
}


/* ═══════════════════════════════════════════════════════════════════════════
   ADMIN PAGE
   ═══════════════════════════════════════════════════════════════════════════ */

.admin-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
}

.admin-sidebar {
  width: 180px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 16px 0;
  background: rgba(0,0,0,.15);
  overflow-y: auto;
}

.admin-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }

.admin-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border: none; background: none;
  color: rgba(245,240,230,.6);
  font-size: 13px; font-family: var(--font-body);
  border-radius: 8px; cursor: pointer; text-align: left;
  transition: background .15s, color .15s;
  width: 100%;
}
.admin-nav-item:hover  { background: rgba(255,255,255,.06); color: rgba(245,240,230,.9); }
.admin-nav-item.active { background: rgba(201,160,67,.15);  color: var(--primary-color); }

.admin-main { flex: 1; overflow-y: auto; }

.admin-section { display: none; padding: 20px 24px; }
.admin-section.active { display: block; }

.admin-section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.admin-title {
  font-family: var(--font-heading); font-size: 1.2rem;
  font-weight: 700; color: var(--primary-color);
}
.admin-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-filter-select { padding: 5px 10px; font-size: 12px; width: auto; }

/* Stat cards row */
.admin-stats-row {
  display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px;
}
.admin-stat-card {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 20px;
  min-width: 110px;
  flex: 1;
}
.asc-val { font-size: 1.6rem; font-weight: 700; color: var(--primary-color); line-height: 1; }
.asc-lbl { font-size: 11px; color: rgba(245,240,230,.5); margin-top: 4px; }

/* Table */
.admin-table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); }
.admin-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.admin-table th {
  padding: 10px 14px; text-align: left;
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: rgba(245,240,230,.45); background: rgba(0,0,0,.2);
  border-bottom: 1px solid var(--border);
}
.admin-table td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,.04);
  color: rgba(245,240,230,.85);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: rgba(255,255,255,.03); }
.row-inactive td { opacity: .5; }
.col-id    { width: 40px; font-size: 11px; color: rgba(245,240,230,.35); }
.col-email { max-width: 260px; }
.col-date  { font-size: 11px; color: rgba(245,240,230,.45); white-space: nowrap; }

/* Badges */
.tier-badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
}
.tier-free  { background: rgba(255,255,255,.08); color: rgba(245,240,230,.6); }
.tier-basic { background: rgba(44,74,124,.4);    color: #6ea8fe; }
.tier-pro   { background: rgba(201,160,67,.2);   color: var(--primary-color); }

.badge-admin {
  display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 9px;
  background: rgba(139,32,32,.4); color: #f87171; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; vertical-align: middle;
}
.status-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  margin-right: 6px; vertical-align: middle;
}
.status-on  { background: var(--success); }
.status-off { background: rgba(255,255,255,.2); }

/* Two-column layout */
.admin-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.admin-card {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.admin-card-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: rgba(245,240,230,.45);
  margin-bottom: 12px;
}

/* Stats bars */
.stats-op-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.stats-op-name { width: 160px; font-size: 12px; color: rgba(245,240,230,.7); flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-op-bar-wrap { flex: 1; height: 6px; background: rgba(255,255,255,.07); border-radius: 3px; overflow: hidden; }
.stats-op-bar { height: 100%; background: var(--primary-color); border-radius: 3px; transition: width .4s ease; }
.stats-op-nums { font-size: 11px; color: rgba(245,240,230,.55); white-space: nowrap; }

/* Top consumers */
.stats-top-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,.04); }
.stats-top-row:last-child { border-bottom: none; }
.stats-top-rank  { width: 20px; font-size: 11px; color: rgba(245,240,230,.35); flex-shrink: 0; }
.stats-top-email { flex: 1; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-top-cred  { font-size: 12px; color: var(--primary-color); font-family: var(--font-mono); white-space: nowrap; }

/* User panel internals */
.admin-user-email { font-size: 15px; font-weight: 600; color: var(--primary-color); word-break: break-all; }
.usage-summary { display: flex; gap: 12px; font-size: 12px; color: rgba(245,240,230,.6); margin-bottom: 10px; }
.usage-op-row  { display: flex; justify-content: space-between; font-size: 12px; padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,.04); }
.usage-section-lbl { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: rgba(245,240,230,.35); margin-top: 8px; margin-bottom: 4px; }
.usage-txn-row { display: flex; justify-content: space-between; font-size: 12px; padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,.04); }
.txn-pos span:last-child { color: var(--success); }
.txn-neg span:last-child { color: rgba(245,240,230,.5); }

/* Admin link in header — add to navbar on superadmin pages */
.admin-header-link {
  font-size: 11px; color: rgba(245,240,230,.45); text-decoration: none;
  border: 1px solid rgba(255,255,255,.1); border-radius: 6px; padding: 3px 8px;
}
.admin-header-link:hover { color: var(--primary-color); border-color: var(--primary-color); }

/* Responsive admin */
@media (max-width: 640px) {
  .admin-sidebar { width: 140px; }
  .admin-two-col { grid-template-columns: 1fr; }
  .stats-op-name { width: 110px; }
  .admin-section { padding: 14px 12px; }
}
@media (max-width: 480px) {
  .admin-layout { flex-direction: column; }
  .admin-sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--border); padding: 8px; }
  .admin-nav { flex-direction: row; }
  .admin-nav-item { justify-content: center; padding: 7px 10px; font-size: 12px; }
}

/* Credits badge in header — desktop */
.credits-badge {
  font-size: 11px;
  font-family: var(--font-mono, monospace);
  color: var(--primary-color);
  background: rgba(201,160,67,.12);
  border: 1px solid rgba(201,160,67,.25);
  border-radius: 20px;
  padding: 3px 10px;
  cursor: default;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Status chip (editor sidebar + cards) ────────────────────────────────── */
.status-chip {
  display: inline-flex;
  align-items: center;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.18);
  white-space: nowrap;
  flex-shrink: 0;
}
.status-chip-draft     { background: rgba(107,114,128,.4);  color: #d1d5db; }
.status-chip-in_review { background: rgba(201,130,40,.45);  color: #fde68a; }
.status-chip-submitted { background: rgba(45,111,168,.45);  color: #bfdbfe; }
.status-chip-approved  { background: rgba(22,163,74,.4);    color: #bbf7d0; }
.status-chip-rejected  { background: rgba(220,38,38,.4);    color: #fecaca; }

/* ── Sidebar action strip (editor) ──────────────────────────────────────── */
.sidebar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: rgba(255,255,255,.02);
}
.sidebar-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-light);
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 3px 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.sidebar-action-btn:hover { background: rgba(255,255,255,.1); color: var(--text-color); }
.sidebar-action-btn:disabled { opacity: .45; cursor: not-allowed; }
.sidebar-action-btn.primary { border-color: rgba(201,160,67,.4); color: var(--accent-color); }
.sidebar-action-btn.primary:hover { background: rgba(201,160,67,.12); }

/* ── Workflow history panel ──────────────────────────────────────────────── */
.workflow-list { display: flex; flex-direction: column; gap: 0; }
.workflow-event {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.workflow-event:last-child { border-bottom: none; }
.workflow-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent-color);
  flex-shrink: 0;
  margin-top: 3px;
  border: 2px solid rgba(201,160,67,.35);
}
.workflow-event-body { flex: 1; min-width: 0; }
.workflow-transition {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: var(--text-color);
  margin-bottom: 2px;
}
.workflow-arrow { color: var(--accent-color); }
.workflow-comment { color: var(--text-light); font-style: italic; margin-top: 2px; }
.workflow-meta { color: var(--text-light); font-size: 10px; margin-top: 3px; }

/* ── Generate-all progress ───────────────────────────────────────────────── */
.gen-progress-list { display: flex; flex-direction: column; gap: 0; }
.gen-progress-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-color);
}
.gen-progress-item:last-child { border-bottom: none; }
.gen-progress-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,.15);
}
.gen-progress-dot.pending  { background: rgba(255,255,255,.15); }
.gen-progress-dot.running  { background: var(--accent-color); border-color: rgba(201,160,67,.5); animation: gen-pulse 1s infinite; }
.gen-progress-dot.done     { background: #16a34a; border-color: rgba(22,163,74,.5); }
.gen-progress-dot.error    { background: #dc2626; border-color: rgba(220,38,38,.5); }
@keyframes gen-pulse { 0%,100%{opacity:1} 50%{opacity:.35} }
.gen-progress-words { margin-left: auto; color: var(--text-light); font-size: 10px; white-space: nowrap; }
.gen-summary-bar {
  font-size: 12px;
  color: var(--text-light);
  padding: 10px 0;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

/* ── Transition panel ────────────────────────────────────────────────────── */
.transition-options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.transition-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-color);
  text-align: left;
  width: 100%;
  transition: background .15s;
}
.transition-btn:hover { background: rgba(255,255,255,.09); border-color: rgba(255,255,255,.2); }
.transition-btn-icon { font-size: 16px; flex-shrink: 0; }
.transition-btn-text { flex: 1; }
.transition-btn-text strong { display: block; }
.transition-btn-text small { color: var(--text-light); font-size: 11px; }

/* ── Section template family picker (grant_detail) ───────────────────────── */
.sections-toolbar { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.family-import-row { display: flex; align-items: center; gap: 6px; margin-left: auto; }

/* ── Team panel ──────────────────────────────────────────────────────────── */
.team-member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.team-member-row:last-child { border-bottom: none; }
.team-member-info { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.team-member-email { color: var(--text-color); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-member-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.team-section-title {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-light);
  margin: 20px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.team-section-title:first-child { margin-top: 0; }
