/* Tribuno - Estilos principales */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --info: #0891b2;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --sidebar-width: 260px;
    --header-height: 64px;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.08);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
    margin: 0;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
.material-symbols-rounded {
    font-family: 'Material Symbols Rounded';
    font-weight: normal;
    font-style: normal;
    font-size: 20px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'liga';
    vertical-align: -.2em;
}
.inline-icon {
    font-size: 1.1em;
    margin-right: .35rem;
}

/* Layout */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: #0f172a;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform .2s;
}

.sidebar-brand {
    padding: 1.25rem 1.5rem;
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-icon, .brand-icon-sm {
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.brand-icon { width: 48px; height: 48px; font-size: .85rem; }
.brand-icon-sm { width: 32px; height: 32px; font-size: .7rem; }

.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; }

.nav-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1.5rem;
    color: #94a3b8;
    transition: all .15s;
}
.nav-item:hover, .nav-item.active {
    background: rgba(255,255,255,.06);
    color: #fff;
}
.nav-item.active { border-left: 3px solid var(--primary); }

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,.08);
    color: #64748b;
    font-size: .75rem;
}

.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
}

.app-header {
    height: var(--header-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left { display: flex; align-items: center; gap: 1rem; }
.header-right { display: flex; align-items: center; gap: 1rem; }

.sidebar-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: .45rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.page-heading { margin: 0; font-size: 1.15rem; font-weight: 600; }

.user-menu { display: flex; align-items: center; gap: .5rem; }
.user-name { font-size: .9rem; font-weight: 500; }

.app-content { padding: 1.5rem; }

/* Auth */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 20% 15%, rgba(14, 165, 183, .22), transparent 32%),
        linear-gradient(135deg, #08111f 0%, #0f2f4a 48%, #0ea5b7 120%);
}

.auth-wrapper { width: 100%; max-width: 420px; padding: 1rem; }

.auth-card {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 24px 60px rgba(2, 6, 23, .28);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .16);
}

.auth-brand {
    background: linear-gradient(135deg, #07111f, #0f172a);
    color: #fff;
    padding: 2.25rem 2rem 1.75rem;
    text-align: center;
}
.auth-brand h1 { margin: .75rem 0 .25rem; font-size: 1.35rem; }
.auth-brand p { margin: 0; color: #94a3b8; font-size: .9rem; }
.brand-logo { display: block; height: 64px; width: auto; margin: 0 auto .25rem; }

.auth-form { padding: 2rem; }
.auth-links { text-align: center; margin-top: 1rem; font-size: .9rem; }
.auth-form-heading {
    display: flex;
    gap: .8rem;
    align-items: flex-start;
    margin-bottom: 1.25rem;
}
.auth-form-heading > .material-symbols-rounded {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eff6ff;
    color: var(--primary);
    font-size: 25px;
    flex-shrink: 0;
}
.auth-form-heading h2 {
    margin: 0;
    font-size: 1.05rem;
    color: var(--text);
}
.auth-form-heading p {
    margin: .15rem 0 0;
    color: var(--text-muted);
    font-size: .86rem;
}
.auth-input-wrap {
    display: flex;
    align-items: center;
    gap: .65rem;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    border-radius: 10px;
    padding: .2rem .75rem;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.auth-input-wrap:focus-within {
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
}
.auth-input-wrap .material-symbols-rounded {
    color: #64748b;
    font-size: 21px;
}
.auth-input-wrap input {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    padding: .75rem 0;
    font-size: .95rem;
    color: var(--text);
}
.auth-input-wrap input::placeholder { color: #94a3b8; }
.auth-submit {
    gap: .45rem;
    min-height: 46px;
    border-radius: 10px;
    box-shadow: 0 10px 22px rgba(37, 99, 235, .22);
}
.auth-submit .material-symbols-rounded { font-size: 20px; }

.install-wrapper { max-width: 720px; }
.install-card .auth-form { padding: 1.5rem 2rem 2rem; }
.install-section { margin-bottom: 1.75rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--border); }
.install-section:last-of-type { border-bottom: none; margin-bottom: 1rem; }
.install-section h2 { margin: 0 0 .75rem; font-size: 1rem; font-weight: 600; }
.install-hint { margin: 0 0 1rem; font-size: .875rem; color: var(--text-muted); }
.install-checklist { list-style: none; margin: 0; padding: 0; }
.install-checklist li { padding: .35rem 0; font-size: .875rem; }
.install-checklist li.ok { color: var(--success); }
.install-checklist li.warn { color: var(--warning, #b8860b); }
.install-checklist li.fail { color: var(--danger); }
.install-report-steps li { display: flex; flex-direction: column; gap: .2rem; padding: .5rem 0; }
.install-step-detail { font-size: .8125rem; color: var(--text-muted); font-weight: 400; }
.install-summary-list { margin: 0; padding-left: 1.1rem; font-size: .875rem; }
.install-summary-list li { margin-bottom: .35rem; }
.install-cron-block { margin-bottom: 1rem; padding: .75rem 1rem; background: var(--surface-muted, #f6f7f9); border-radius: .5rem; }
.install-cron-block h3 { margin: 0 0 .35rem; font-size: .9375rem; }
.install-cron-command { margin: .5rem 0 0; padding: .75rem; background: #1e1e1e; color: #f3f3f3; border-radius: .375rem; font-size: .75rem; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.install-report-actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-top: 1rem; }
.install-inline-form { display: inline; margin: 0; }
.install-db-test { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-top: .5rem; }
.install-db-test-result { font-size: .875rem; }
.install-db-test-result.ok { color: var(--success); }
.install-db-test-result.fail { color: var(--danger); }
.install-permissions-table { width: 100%; border-collapse: collapse; font-size: .8125rem; margin-top: .5rem; }
.install-permissions-table th,
.install-permissions-table td { padding: .45rem .5rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.install-permissions-table tr.ok td:last-child { color: var(--success); }
.install-permissions-table tr.warn td:last-child { color: var(--warning, #b8860b); }
.install-permissions-table tr.fail td:last-child { color: var(--danger); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-group-sm { max-width: 120px; }
.checkbox-label { display: flex; align-items: flex-start; gap: .5rem; margin-bottom: .75rem; font-size: .875rem; cursor: pointer; }
.checkbox-label input { margin-top: .2rem; }
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: .35rem .75rem;
}
.checkbox-grid .checkbox-label { margin-bottom: .25rem; }
.checkbox-grid-compact {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    max-width: 420px;
}
.module-assignment-form {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}
.header-search-static {
    pointer-events: none;
    color: var(--text-muted);
}
.setup-guide-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}
.setup-guide-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: .65rem;
    margin-top: 1rem;
}
.setup-guide-step {
    display: flex;
    align-items: center;
    gap: .45rem;
    padding: .65rem .75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
    color: var(--text-muted);
    font-size: .875rem;
}
.setup-guide-step.done {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #166534;
}
.module-list {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
}
.module-list li {
    display: flex;
    align-items: center;
    gap: .45rem;
    padding: .45rem 0;
    color: var(--text);
}
.module-list .material-symbols-rounded {
    color: var(--success);
    font-size: 20px;
}

.plan-options { display: flex; flex-direction: column; gap: .5rem; }
.plan-option { display: flex; align-items: flex-start; gap: .5rem; padding: .75rem; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.plan-option:has(input:checked) { border-color: var(--primary); background: #eff6ff; }
.plan-option-body { display: flex; flex-direction: column; gap: .15rem; font-size: .875rem; }
.register-payment-section { margin: 1rem 0; padding-top: 1rem; border-top: 1px solid var(--border); }
.register-payment-section h3 { margin: 0 0 .5rem; font-size: 1rem; }
.auth-wrapper.install-wrapper .auth-card { max-width: 720px; }

@media (max-width: 640px) {
    .form-row { grid-template-columns: 1fr; }
    .form-group-sm { max-width: none; }
}

/* Cards & stats */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h3 { margin: 0; font-size: 1rem; font-weight: 600; }
.card-body { padding: 1.25rem; }
.card-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border); }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}
.stat-label { display: block; font-size: .8rem; color: var(--text-muted); margin-bottom: .35rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-success .stat-value { color: var(--success); }
.stat-danger .stat-value { color: var(--danger); }
.stat-warning .stat-value { color: var(--warning); }

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .35rem; }

.form-control, .form-select {
    width: 100%;
    padding: .55rem .75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: .9rem;
    background: #fff;
    transition: border-color .15s;
}
.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.form-select-sm { width: auto; min-width: 200px; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0 1.25rem;
}
.form-grid .span-2 { grid-column: span 2; }
.form-actions { display: flex; gap: .75rem; margin-top: .5rem; }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .9rem;
    cursor: pointer;
}
.checkbox-group { display: flex; flex-direction: column; gap: .5rem; }

.field-hint { font-size: .8rem; color: var(--text-muted); }
.field-hint.valid { color: var(--success); }
.field-hint.invalid { color: var(--danger); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .55rem 1rem;
    border-radius: 6px;
    font-size: .875rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .9; color: #fff; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-ghost { background: transparent; color: var(--secondary); border-color: transparent; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: .35rem .65rem; font-size: .8rem; }
.btn-block { width: 100%; }

/* Tables */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
.table th { font-weight: 600; color: var(--text-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; background: #f8fafc; }
.table tbody tr:hover { background: #f8fafc; }
.actions { white-space: nowrap; }

/* Badges */
.badge {
    display: inline-block;
    padding: .2rem .55rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #e0f2fe; color: #075985; }
.badge-secondary { background: #f1f5f9; color: #475569; }
.badge-role { background: #ede9fe; color: #5b21b6; }

/* Alerts */
.alert {
    padding: .85rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: .9rem;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }

/* Toolbar */
.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.search-form { display: flex; gap: .5rem; flex: 1; max-width: 600px; }
.filters-bar { margin-bottom: 1.25rem; }
.filters-form { display: flex; gap: .5rem; align-items: center; }
.quick-actions { display: flex; gap: .75rem; flex-wrap: wrap; }

.detail-list {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: .75rem 1rem;
    margin: 0;
}
.detail-list dt { font-weight: 600; color: var(--text-muted); }
.detail-list dd { margin: 0; }

.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: .5rem 0; border-bottom: 1px solid var(--border); }

.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
code { background: #f1f5f9; padding: .15rem .4rem; border-radius: 4px; font-size: .85em; }

.company-selector { margin-right: .5rem; }

.pagination { display: flex; gap: .35rem; flex-wrap: wrap; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.5); }
.modal-content {
    position: relative; background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); width: 100%; max-width: 480px; padding: 1.5rem; z-index: 1;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.modal-header h3 { margin: 0; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); }
.table-sm th, .table-sm td { padding: .5rem .75rem; font-size: .85rem; }
.mb-3 { margin-bottom: 1rem; }

.totals-panel {
    background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1rem 1.25rem; max-width: 320px; margin-left: auto; margin-top: 1rem;
}
.totals-panel div { display: flex; justify-content: space-between; padding: .25rem 0; }
.totals-panel .total-row { border-top: 1px solid var(--border); margin-top: .5rem; padding-top: .5rem; font-size: 1.1rem; }

.preview-box {
    background: #0f172a; color: #e2e8f0; padding: 1rem; border-radius: var(--radius);
    max-height: 400px; overflow: auto; font-size: .75rem; white-space: pre-wrap;
}

.search-results { position: relative; }
.search-result-item {
    padding: .5rem .75rem; cursor: pointer; background: #fff;
    border: 1px solid var(--border); border-top: none;
}
.search-result-item:hover { background: #f1f5f9; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: .75rem 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: none; }

.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { padding: .5rem 0 .5rem 1.75rem; position: relative; border-bottom: 1px solid var(--border); }
.checklist li::before {
    content: '';
    position: absolute;
    left: 0;
    top: .85rem;
    width: .65rem;
    height: .65rem;
    border-radius: 50%;
    background: var(--secondary);
}
.checklist li.ok::before { background: var(--success); }
.checklist li.fail::before { background: var(--danger); }
.checklist li.warn::before { background: #d97706; }

.progress-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); transition: width .3s ease; }

.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.reference-row { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: .75rem; }

.mt-4 { margin-top: 1.5rem; }

/* Responsive */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: span 1; }
    .detail-list { grid-template-columns: 1fr; }
    .detail-list dt { margin-top: .5rem; }
}
