/* ─── Variables ─────────────────────────────────────────────────────────────── */
:root {
    --bg:          #0f172a;
    --bg-2:        #1e293b;
    --bg-3:        #162033;
    --surface:     rgba(30, 41, 59, 0.65);
    --border:      rgba(255, 255, 255, 0.09);
    --border-2:    rgba(255, 255, 255, 0.05);
    --primary:     #8b5cf6;
    --primary-h:   #7c3aed;
    --primary-glow: rgba(139, 92, 246, 0.35);
    --accent:      #38bdf8;
    --success:     #22c55e;
    --error:       #ef4444;
    --warning:     #f59e0b;
    --text-1:      #f8fafc;
    --text-2:      #cbd5e1;
    --text-3:      #64748b;
    --sidebar-w:   280px;
    --titlebar-h:  40px;
    --radius-sm:   8px;
    --radius-md:   12px;
    --radius-lg:   20px;
    --shadow:      0 20px 40px rgba(0,0,0,0.4);
}

:root[data-theme="light"] {
    --bg:          #f0fdf4;
    --bg-2:        #dcfce7;
    --bg-3:        #ffffff;
    --surface:     rgba(255, 255, 255, 0.65);
    --border:      rgba(0, 0, 0, 0.1);
    --border-2:    rgba(0, 0, 0, 0.05);
    --primary:     #16a34a;
    --primary-h:   #15803d;
    --primary-glow: rgba(22, 163, 74, 0.35);
    --accent:      #0ea5e9;
    --success:     #166534;
    --error:       #dc2626;
    --warning:     #d97706;
    --text-1:      #0f172a;
    --text-2:      #334155;
    --text-3:      #64748b;
    --shadow:      0 20px 40px rgba(0,0,0,0.08);
}

/* ─── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text-1);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    font-size: 14px;
    line-height: 1.5;
}

/* ─── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }

/* ─── Title Bar ─────────────────────────────────────────────────────────────── */
.title-bar {
    height: var(--titlebar-h);
    background: rgba(15,23,42,0.95);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    -webkit-app-region: drag;
    flex-shrink: 0;
    z-index: 100;
}

.title-bar-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-2);
}

.app-icon { font-size: 1.1rem; }
.dynamic-logo {
    max-height: 26px;
    width: auto;
    object-fit: contain;
    vertical-align: middle;
    margin-right: 0.2rem;
}


/* User Bar */
.user-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    -webkit-app-region: no-drag;
}
.user-name { font-size: 0.8rem; font-weight: 600; color: var(--text-2); }
.role-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.role-administrador { background: rgba(139,92,246,0.2); color: #c4b5fd; border: 1px solid rgba(139,92,246,0.3); }
.role-protocolista { background: rgba(56,189,248,0.15); color: #7dd3fc; border: 1px solid rgba(56,189,248,0.25); }
.logout-btn {
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.3);
    color: var(--error);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}
.logout-btn:hover { background: var(--error); color: white; }

/* Window Controls */
.window-controls {
    display: flex;
    gap: 4px;
    -webkit-app-region: no-drag;
}
.window-controls button {
    width: 30px; height: 26px;
    background: transparent; border: none;
    color: var(--text-3); border-radius: 6px;
    cursor: pointer; font-size: 0.8rem;
    transition: all 0.2s; display: flex;
    align-items: center; justify-content: center;
}
.window-controls button:hover { background: rgba(255,255,255,0.1); color: var(--text-1); }
#btn-close:hover { background: var(--error) !important; color: white !important; }

/* ─── App Layout ────────────────────────────────────────────────────────────── */
.app-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ─── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--bg-3);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.3s ease, min-width 0.3s ease;
}
.sidebar.collapsed { width: 0; min-width: 0; }

.sidebar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.2rem; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.sidebar-header h2 {
    font-size: 0.95rem; font-weight: 700;
    background: linear-gradient(135deg, var(--text-1), #c4b5fd);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
    letter-spacing: 0.03em; text-transform: uppercase;
}

.icon-btn {
    background: transparent; border: none; color: var(--text-3);
    cursor: pointer; font-size: 0.8rem; padding: 4px 8px;
    border-radius: 6px; transition: all 0.2s;
}
.icon-btn:hover { background: var(--border); color: var(--text-1); }

.sidebar-section {
    padding: 0.9rem 1.2rem; border-bottom: 1px solid var(--border-2); flex-shrink: 0;
}
.sidebar-label {
    display: block; font-size: 0.72rem; font-weight: 600;
    color: var(--primary); text-transform: uppercase;
    letter-spacing: 0.08em; margin-bottom: 0.5rem;
}
.select-with-action { display: flex; gap: 6px; }
.select-with-action select { flex: 1; min-width: 0; }

.mini-btn {
    width: 32px; height: 36px; border: 1px solid var(--border);
    background: rgba(139,92,246,0.15); color: var(--primary);
    border-radius: var(--radius-sm); cursor: pointer; font-size: 1.1rem;
    flex-shrink: 0; transition: all 0.2s; display: flex;
    align-items: center; justify-content: center;
}
.mini-btn:hover:not(:disabled) { background: var(--primary); color: white; }
.mini-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Template Status */
.template-status {
    display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm); background: rgba(15,23,42,0.5);
    border: 1px dashed var(--border); margin-bottom: 0.5rem; min-height: 36px;
}
.template-status.has-template { border-color: var(--success); border-style: solid; }
.template-icon { font-size: 1rem; }
.template-text { font-size: 0.75rem; color: var(--text-3); word-break: break-all; }
.template-status.has-template .template-text { color: var(--success); }

/* Records List */
.records-section {
    flex: 1; overflow: hidden; display: flex; flex-direction: column; padding-bottom: 0;
}
.records-list {
    flex: 1; overflow-y: auto; padding: 0.3rem 0; display: flex; flex-direction: column; gap: 4px;
}
.empty-msg {
    color: var(--text-3); font-size: 0.8rem; text-align: center; padding: 1rem; font-style: italic;
}
.record-item {
    padding: 0.45rem 0.7rem; border-radius: 6px; background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-2); transition: all 0.2s;
    display: flex; align-items: center; gap: 0.4rem;
}
.record-item:hover { background: rgba(139,92,246,0.1); border-color: var(--primary); }
.record-item .rec-body { flex: 1; min-width: 0; cursor: pointer; }
.record-item .rec-name { font-size: 0.8rem; font-weight: 600; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.record-item .rec-date { font-size: 0.7rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.record-item .rec-minuta { font-size: 0.7rem; color: var(--primary); }
.rec-del-btn {
    flex-shrink: 0; width: 26px; height: 26px; background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.25); color: var(--error); border-radius: 5px;
    cursor: pointer; font-size: 0.75rem; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; opacity: 0;
}
.record-item:hover .rec-del-btn { opacity: 1; }
.rec-del-btn:hover { background: var(--error) !important; color: white; opacity: 1 !important; }

/* Consultar table action buttons */
.rec-action-btn {
    border: none; border-radius: 5px; padding: 3px 8px; font-size: 0.75rem;
    cursor: pointer; font-weight: 600; transition: all 0.2s; margin: 0 2px;
}
.edit-btn  { background: rgba(139,92,246,0.15); color: #c4b5fd; border: 1px solid rgba(139,92,246,0.3); }
.edit-btn:hover  { background: var(--primary); color: white; }
.del-btn   { background: rgba(239,68,68,0.12); color: var(--error); border: 1px solid rgba(239,68,68,0.3); }
.del-btn:hover   { background: var(--error); color: white; }

.sidebar-footer {
    padding: 0.9rem 1.2rem; border-top: 1px solid var(--border); flex-shrink: 0;
    display: flex; gap: 0.5rem; flex-wrap: wrap;
}
.sidebar-footer .action-btn { flex: 1; text-align: center; justify-content: center; }

/* ─── Main Content ──────────────────────────────────────────────────────────── */
.main-content {
    flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--bg);
}

/* ─── Tab Navigation ────────────────────────────────────────────────────────── */
.tab-nav {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.5rem 1.5rem 0; border-bottom: 1px solid var(--border);
    background: rgba(15,23,42,0.8); flex-shrink: 0;
}
.tabs-left { display: flex; gap: 0.25rem; }
.tabs-right { display: flex; gap: 0.5rem; padding-bottom: 0.5rem; }

.tab-btn {
    padding: 0.6rem 1.25rem; border: 1px solid transparent; border-bottom: none;
    background: transparent; color: var(--text-3); border-radius: 8px 8px 0 0;
    cursor: pointer; font-size: 0.85rem; font-weight: 600; font-family: 'Inter', sans-serif;
    transition: all 0.2s; position: relative;
    margin-bottom: -1px; /* overlap border */
}
.tab-btn:hover { color: var(--text-2); background: rgba(255,255,255,0.02); }
.tab-btn.active {
    background: var(--bg); border-color: var(--border); color: var(--primary);
    border-bottom: 1px solid var(--bg);
}
.tab-btn.active::after {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: var(--primary); border-radius: 2px 2px 0 0;
}

/* ─── Tab Panels ────────────────────────────────────────────────────────────── */
.tab-panels {
    flex: 1; overflow: hidden; position: relative;
}
.tab-panel {
    position: absolute; inset: 0; display: none; opacity: 0;
    flex-direction: column; transition: opacity 0.3s;
}
.tab-panel.active { display: flex; opacity: 1; z-index: 10; }

/* ─── TAB: GENERAR (Formulario) ─────────────────────────────────────────────── */
.form-scroll {
    flex: 1; overflow-y: auto; padding: 1.5rem 2rem;
    display: flex; flex-direction: column; gap: 1.5rem;
}
.form-section {
    background: var(--surface); backdrop-filter: blur(12px);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 1.5rem; animation: fadeUp 0.4s ease both;
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
.section-title {
    font-size: 0.9rem; font-weight: 700; color: var(--text-2);
    letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 1rem;
    display: flex; align-items: center; gap: 0.5rem;
}
.section-icon { font-size: 1rem; }

.form-grid { display: grid; gap: 1rem; }
.form-grid.col-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid.col-2 { grid-template-columns: repeat(2, 1fr); }
.col-span-3 { grid-column: 1 / -1; }
.col-span-2 { grid-column: span 2; }

.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
label {
    font-size: 0.78rem; font-weight: 600; color: var(--text-3);
    text-transform: uppercase; letter-spacing: 0.06em;
}
input, select, textarea {
    background: rgba(15, 23, 42, 0.7); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 0.6rem 0.85rem;
    color: var(--text-1); font-family: 'Inter', sans-serif; font-size: 0.88rem;
    transition: all 0.2s; outline: none;
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, select:focus, textarea:focus {
    border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow);
    background: rgba(30,41,59,0.9);
}
input[readonly] {
    background: rgba(139,92,246,0.07); border-color: rgba(139,92,246,0.25);
    color: #c4b5fd; cursor: default;
}
textarea { resize: vertical; min-height: 90px; }
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 0.75rem center;
    background-size: 1rem; padding-right: 2.2rem; cursor: pointer;
}
select option { background: var(--bg-2); color: var(--text-1); }

/* Parties */
.parties-container { display: flex; flex-direction: column; gap: 0.75rem; }
.party-row {
    display: grid; grid-template-columns: 1fr 1fr auto; gap: 0.75rem; align-items: end;
    padding: 0.75rem; background: rgba(15,23,42,0.4); border-radius: var(--radius-sm);
    border: 1px solid var(--border-2); animation: fadeUp 0.25s ease both;
}
.party-row.cols-3 { grid-template-columns: 1fr 1fr 1fr auto; }
.party-row .remove-btn {
    height: 34px; width: 34px; background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3);
    color: var(--error); border-radius: 6px; cursor: pointer; font-size: 0.9rem;
    transition: all 0.2s; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.party-row .remove-btn:hover { background: var(--error); color: white; }
.add-party-btn {
    margin-left: auto; background: rgba(139,92,246,0.12); border: 1px solid rgba(139,92,246,0.3);
    color: var(--primary); border-radius: 6px; padding: 3px 10px; font-size: 0.75rem;
    font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.add-party-btn:hover { background: var(--primary); color: white; }

/* ─── Action Bar ────────────────────────────────────────────────────────────── */
.action-bar {
    display: flex; gap: 0.75rem; align-items: center; justify-content: flex-end;
    padding: 1rem 1.5rem; border-top: 1px solid var(--border);
    background: rgba(15,23,42,0.6); flex-shrink: 0; position: sticky; bottom: 0;
}

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.action-btn {
    padding: 0.42rem 0.85rem; border: 1px solid var(--border);
    background: rgba(255,255,255,0.04); color: var(--text-2); border-radius: 8px;
    cursor: pointer; font-size: 0.8rem; font-weight: 500; font-family: 'Inter', sans-serif;
    transition: all 0.2s; white-space: nowrap;
}
.action-btn:hover:not(:disabled) { background: rgba(255,255,255,0.1); color: var(--text-1); border-color: rgba(255,255,255,0.2); }
.action-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.template-btn { width: 100%; justify-content: center; text-align: center; }

.secondary-btn {
    padding: 0.65rem 1.2rem; border: 1px solid var(--border);
    background: rgba(255,255,255,0.04); color: var(--text-2); border-radius: 10px;
    cursor: pointer; font-size: 0.85rem; font-weight: 500; font-family: 'Inter', sans-serif; transition: all 0.2s;
}
.secondary-btn:hover:not(:disabled) { background: rgba(255,255,255,0.09); color: var(--text-1); }
.secondary-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.primary-btn {
    position: relative; padding: 0.7rem 1.8rem; border: none;
    background: linear-gradient(135deg, var(--primary), var(--primary-h)); color: white;
    border-radius: 10px; cursor: pointer; font-size: 0.9rem; font-weight: 700;
    font-family: 'Inter', sans-serif; transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
    letter-spacing: 0.02em; display: flex; align-items: center; justify-content: center;
    overflow: hidden; min-width: 190px; min-height: 42px;
}
.primary-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 12px 20px -8px var(--primary-glow); }
.primary-btn:active:not(:disabled)  { transform: translateY(0); }
.primary-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.primary-btn.loading .btn-text { opacity: 0; }
.primary-btn.loading .spinner { display: block; }
.danger-btn { background: linear-gradient(135deg, var(--error), #dc2626); }
.danger-btn:hover:not(:disabled) { box-shadow: 0 12px 20px -8px rgba(239,68,68,0.4); }

.full-w { width: 100%; }

/* Spinner */
.spinner {
    display: none; position: absolute; width: 20px; height: 20px;
    border: 3px solid rgba(255,255,255,0.25); border-radius: 50%;
    border-top-color: #fff; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── TAB: CONSULTAR ────────────────────────────────────────────────────────── */
.consultar-panel {
    display: flex; flex-direction: column; flex: 1; overflow: hidden;
    padding: 1.5rem; gap: 1rem;
}
.consultar-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--surface); padding: 1rem; border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.search-group { display: flex; align-items: center; gap: 0.5rem; flex: 1; max-width: 400px; }
.search-icon-inline { color: var(--text-3); }
.search-input { width: 100%; }
.consultar-toolbar-right { display: flex; gap: 0.5rem; }

.records-table-wrap {
    flex: 1; overflow: auto; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.records-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.records-table th {
    background: rgba(15,23,42,0.8); color: var(--text-3); font-weight: 600;
    text-align: left; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 1; text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.75rem;
}
.records-table td {
    padding: 0.75rem 1rem; border-bottom: 1px solid var(--border-2); color: var(--text-2);
}
.records-table tbody tr:hover { background: rgba(255,255,255,0.03); }
.empty-cell { text-align: center; color: var(--text-3); padding: 2rem !important; font-style: italic; }
.minuta-badge {
    background: rgba(139,92,246,0.15); color: #c4b5fd; padding: 2px 6px;
    border-radius: 4px; font-size: 0.75rem; font-weight: 500;
}

/* ─── TAB: INSTRUCTIVO ──────────────────────────────────────────────────────── */
.instructivo-scroll { flex: 1; overflow-y: auto; padding: 1.5rem; }
.instructivo-panel {
    max-width: 900px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 2rem;
}
.instructivo-header { text-align: center; margin-bottom: 2rem; border-bottom: 1px solid var(--border-2); padding-bottom: 1.5rem; }
.instructivo-header h2 { font-size: 1.5rem; margin-bottom: 0.5rem; color: var(--text-1); }
.instructivo-header p { color: var(--text-3); font-size: 1rem; }

.steps-grid { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 3rem; }
.step-card {
    display: flex; gap: 1rem; padding: 1.2rem; background: rgba(15,23,42,0.4);
    border: 1px solid var(--border-2); border-radius: var(--radius-sm);
}
.step-num {
    width: 32px; height: 32px; border-radius: 50%; background: var(--primary);
    color: white; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.1rem; flex-shrink: 0;
}
.step-body h4 { font-size: 1rem; margin-bottom: 0.4rem; color: var(--text-1); }
.step-body p { color: var(--text-2); font-size: 0.9rem; line-height: 1.6; }

.code-sample {
    background: rgba(0,0,0,0.3); border: 1px solid var(--border-2); border-radius: 6px;
    padding: 1rem; font-family: monospace; font-size: 0.85rem; color: var(--accent);
    margin: 0.8rem 0; line-height: 1.5;
}
.alert-instr {
    background: rgba(245,158,11,0.1); border-left: 3px solid var(--warning);
    padding: 0.8rem; border-radius: 0 4px 4px 0; color: #fcd34d; font-size: 0.85rem;
}

.var-reference h3 { font-size: 1.2rem; margin-bottom: 0.5rem; color: var(--text-1); border-bottom: 1px solid var(--border-2); padding-bottom: 0.5rem; }
.var-reference > p { color: var(--text-3); margin-bottom: 1.5rem; font-size: 0.9rem; }
.var-groups { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.var-group-block { background: rgba(15,23,42,0.4); border-radius: var(--radius-sm); border: 1px solid var(--border-2); overflow: hidden; }
.var-group-title { background: rgba(255,255,255,0.03); padding: 0.8rem 1rem; font-weight: 600; font-size: 0.9rem; border-bottom: 1px solid var(--border-2); }
.var-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.var-table td { padding: 0.6rem 1rem; border-bottom: 1px solid var(--border-2); }
.var-table tr:last-child td { border-bottom: none; }
.var-table td:first-child { width: 40%; font-family: monospace; color: var(--accent); }
.var-table td:last-child { color: var(--text-2); }

.tips-block {
    margin-top: 3rem; background: rgba(56,189,248,0.1); border: 1px solid rgba(56,189,248,0.2);
    border-radius: var(--radius-sm); padding: 1.5rem;
}
.tips-block h4 { color: #7dd3fc; margin-bottom: 0.8rem; font-size: 1.1rem; }
.tips-block ul { margin-left: 1.5rem; color: var(--text-2); font-size: 0.9rem; line-height: 1.6; }

/* ─── TAB: ADMIN ────────────────────────────────────────────────────────────── */
.admin-scroll { flex: 1; overflow-y: auto; padding: 1.5rem; }
.admin-panel { max-width: 1000px; margin: 0 auto; display: flex; flex-direction: column; gap: 1.5rem; }
.admin-header h2 { font-size: 1.5rem; margin-bottom: 0.4rem; }
.admin-header p { color: var(--text-3); font-size: 0.9rem; }

.admin-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.wide-card { grid-column: 1 / -1; }

.admin-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.5rem;
}
.admin-card h3 { font-size: 1.1rem; margin-bottom: 1.2rem; display: flex; align-items: center; gap: 0.5rem; color: var(--text-2); }

.users-list { display: flex; flex-direction: column; gap: 0.5rem; }
.user-row {
    display: flex; align-items: center; justify-content: space-between; padding: 0.8rem;
    background: rgba(15,23,42,0.5); border: 1px solid var(--border-2); border-radius: var(--radius-sm);
}
.user-info { display: flex; align-items: center; gap: 1rem; }
.user-row-name { font-weight: 600; font-size: 0.95rem; }
.user-row-role {
    font-size: 0.7rem; font-weight: 700; padding: 2px 8px; border-radius: 4px; text-transform: uppercase;
}
.delete-user-btn {
    width: 32px; height: 32px; background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3);
    color: var(--error); border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.delete-user-btn:hover:not(:disabled) { background: var(--error); color: white; }
.delete-user-btn:disabled { opacity: 0.3; cursor: not-allowed; border-color: transparent; color: var(--text-3); }

/* ─── Toasts & Modals ───────────────────────────────────────────────────────── */
.toast {
    position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%) translateY(80px);
    background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px;
    padding: 0.75rem 1.5rem; display: flex; align-items: center; gap: 0.75rem; font-size: 0.88rem;
    box-shadow: var(--shadow); z-index: 9999; transition: transform 0.35s, opacity 0.35s; opacity: 0;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--error); }
.toast.info .toast-icon { color: var(--accent); }
.toast.warning .toast-icon { color: var(--warning); }
.toast-icon { font-size: 1.1rem; }

.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center; z-index: 9998;
    opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.modal-overlay.show { opacity: 1; pointer-events: all; }
.glass-panel {
    background: rgba(30,41,59,0.85); backdrop-filter: blur(20px); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.modal-box { padding: 2rem; max-width: 400px; width: 90%; animation: fadeUp 0.3s ease both; }
.modal-box h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.modal-box p { color: var(--text-2); font-size: 0.9rem; margin-bottom: 1rem; }
.modal-input {
    width: 100%; margin-bottom: 1.2rem; padding: 0.65rem 0.9rem; background: rgba(15,23,42,0.7);
    border: 1px solid var(--border); border-radius: 8px; color: var(--text-1); font-size: 0.9rem;
    font-family: 'Inter', sans-serif; outline: none; transition: border-color 0.2s;
}
.modal-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; }

/* ─── Background ambient ────────────────────────────────────────────────────── */
body::before {
    content: ''; position: fixed; top: -30%; left: -10%; width: 50vw; height: 50vw;
    background: radial-gradient(circle, rgba(139,92,246,0.12) 0%, transparent 70%); pointer-events: none; z-index: -1;
}
body::after {
    content: ''; position: fixed; bottom: -30%; right: -10%; width: 50vw; height: 50vw;
    background: radial-gradient(circle, rgba(56,189,248,0.08) 0%, transparent 70%); pointer-events: none; z-index: -1;
}

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
    .form-grid.col-3 { grid-template-columns: repeat(2, 1fr); }
    .col-span-3 { grid-column: 1 / -1; }
    .var-groups { grid-template-columns: 1fr; }
}
@media (max-width: 850px) {
    .admin-grid { grid-template-columns: 1fr; }
}
@media (max-width: 750px) {
    .form-grid.col-3 { grid-template-columns: 1fr; }
    .form-scroll { padding: 1rem; }
    .party-row, .party-row.cols-3 { grid-template-columns: 1fr auto; }
    .party-row .form-group:not(:first-child) { grid-column: 1; }
    body { font-size: 13px; }
}

/* ─── Light Theme Overrides ────────────────────────────────────────────────── */
[data-theme="light"] .title-bar { background: rgba(255,255,255,0.95); }
[data-theme="light"] input, [data-theme="light"] select, [data-theme="light"] textarea { background: rgba(255,255,255,0.7); color: #0f172a; }
[data-theme="light"] .tab-nav { background: rgba(255,255,255,0.8); }
[data-theme="light"] .action-bar { background: rgba(255,255,255,0.6); }
[data-theme="light"] .records-table th { background: rgba(255,255,255,0.8); color: #334155; }
[data-theme="light"] .template-status { background: rgba(255,255,255,0.8); }
[data-theme="light"] .party-row { background: rgba(255,255,255,0.7); }
[data-theme="light"] .user-row { background: rgba(255,255,255,0.7); }
[data-theme="light"] .step-card, [data-theme="light"] .var-group-block { background: rgba(255,255,255,0.7); }
[data-theme="light"] .code-sample { background: rgba(0,0,0,0.05); }
[data-theme="light"] .modal-input { background: rgba(255,255,255,0.9); border-color: #cbd5e1; }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: #cbd5e1; }
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
