/* ============================================================
   VALDERRAMA - Estilos principales v2
   ============================================================ */

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

:root {
    --green:        #0A5C47;
    --green-mid:    #0F7A5E;
    --green-light:  #E8F5F0;
    --green-dark:   #063D30;
    --gold:         #B8860B;
    --gold-light:   #FDF3DC;
    --blue-dark:    #1A2B4A;
    --ok:           #2D6A0F;
    --ok-bg:        #EBF5E0;
    --info:         #1255A0;
    --info-bg:      #E4EEFA;
    --danger:       #9B1C1C;
    --danger-bg:    #FDF0F0;
    --warn:         #7A4100;
    --warn-bg:      #FEF3E2;
    --gray:         #555;
    --gray-light:   #F5F4F0;
    --text:         #1C1C1C;
    --text-muted:   #2a2a2a;
    --border:       rgba(0,0,0,.10);
    --border-hover: rgba(0,0,0,.18);
    --bg:           #F2F1ED;
    --surface:      #FFFFFF;
    --radius-sm:    6px;
    --radius-md:    10px;
    --radius-lg:    14px;
    --shadow-sm:    0 1px 3px rgba(0,0,0,.08);
    --shadow-md:    0 4px 12px rgba(0,0,0,.10);
}

html { font-size: 15px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    background-color: #F2F1ED;
    background-image: url('../img/fondo_campo.webp');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
}

/* ---- TOPBAR ---- */
.topbar {
    position: sticky; top: 0; z-index: 50;
    background: var(--green-dark);
    display: flex; align-items: center; justify-content: space-between;
    height: 58px; padding: 0 1.75rem; gap: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
    border-bottom: 2px solid var(--gold);
}
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.topbar-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.topbar-logo img { height: 34px; background: #fff; border-radius: 6px; padding: 3px 8px; }
.topbar-divider { width: 1px; height: 24px; background: rgba(255,255,255,.2); }
.topbar-dept { font-size: 12px; color: rgba(255,255,255,.65); background: rgba(255,255,255,.1); padding: 3px 10px; border-radius: 20px; }
.topbar-nav { display: flex; align-items: center; gap: 2px; }
.topbar-link { color: rgba(255,255,255,.75); text-decoration: none; font-size: 13px; padding: 6px 13px; border-radius: var(--radius-sm); display: flex; align-items: center; gap: 5px; transition: background .15s, color .15s; font-weight: 500; }
.topbar-link:hover { background: rgba(255,255,255,.12); color: #fff; }
.topbar-link.active { background: rgba(255,255,255,.18); color: #fff; }
.topbar-link i { font-size: 16px; }
.topbar-right { display: flex; align-items: center; gap: .85rem; }
.topbar-user { font-size: 13px; color: rgba(255,255,255,.8); display: flex; align-items: center; gap: 5px; }
.btn-logout { color: rgba(255,255,255,.75); background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); border-radius: var(--radius-sm); padding: 5px 13px; font-size: 13px; cursor: pointer; text-decoration: none; transition: background .15s; }
.btn-logout:hover { background: rgba(255,255,255,.2); color: #fff; }

/* ---- FLASH ---- */
.flash { display: flex; align-items: center; gap: 10px; padding: .85rem 1.75rem; font-size: 14px; font-weight: 500; }
.flash i { font-size: 18px; flex-shrink: 0; }
.flash-success { background: var(--ok-bg); color: var(--ok); border-bottom: 1px solid #c3e6a0; }
.flash-error   { background: var(--danger-bg); color: var(--danger); border-bottom: 1px solid #f5c0c0; }

/* ---- MAIN WRAP ---- */
.main-wrap { max-width: 1120px; margin: 0 auto; padding: 1.75rem 1.5rem; }

/* ---- PAGE HEADER ---- */
.page-header { display: flex; align-items: center; gap: .85rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-title { font-size: 21px; font-weight: 700; color: var(--text); flex: 1; }

/* ---- BUTTONS ---- */
.btn-primary { background: var(--green); color: #fff; border: none; border-radius: var(--radius-md); padding: 9px 20px; font-size: 14px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; transition: background .15s, transform .1s; box-shadow: 0 2px 6px rgba(10,92,71,.25); }
.btn-primary:hover { background: var(--green-mid); transform: translateY(-1px); }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border-hover); border-radius: var(--radius-md); padding: 8px 16px; font-size: 13px; font-weight: 500; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 5px; transition: background .15s; }
.btn-ghost:hover { background: var(--gray-light); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn-success { background: var(--ok); color: #fff; border: none; border-radius: var(--radius-md); padding: 10px 20px; font-size: 14px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; box-shadow: 0 2px 6px rgba(45,106,15,.3); transition: opacity .15s, transform .1s; }
.btn-success:hover { opacity: .9; transform: translateY(-1px); }
.btn-danger { background: var(--danger); color: #fff; border: none; border-radius: var(--radius-md); padding: 10px 20px; font-size: 14px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; box-shadow: 0 2px 6px rgba(155,28,28,.3); transition: opacity .15s, transform .1s; }
.btn-danger:hover { opacity: .9; transform: translateY(-1px); }
.btn-delivered { background: var(--green-light); color: var(--green); border: 1.5px solid var(--green); border-radius: var(--radius-md); padding: 10px 20px; font-size: 14px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; transition: opacity .15s; }
.btn-delivered:hover { opacity: .85; }

/* ---- STATS ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 1.75rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.1rem 1.25rem; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--green); }
.stat-card.stat-card-info::before   { background: var(--info); }
.stat-card.stat-card-ok::before     { background: var(--ok); }
.stat-card.stat-card-danger::before { background: var(--danger); }
.stat-card.stat-card-warn::before   { background: var(--gold); }
.stat-card.stat-card-delivered::before { background: var(--green-mid); }
.stat-label { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .6px; font-weight: 600; }
.stat-val { font-size: 30px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-info    { color: var(--info); }
.stat-ok      { color: var(--ok); }
.stat-danger  { color: var(--danger); }
.stat-warn    { color: var(--gold); }

/* ---- SECTION ---- */
.section { margin-bottom: 1.75rem; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .85rem; }
.section-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 7px; color: var(--text); }

/* ---- TICKET CARD ---- */
.ticket-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem 1.25rem; margin-bottom: .6rem; display: block; text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s, transform .1s; box-shadow: var(--shadow-sm); }
.ticket-card:hover { border-color: var(--green); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.ticket-urgent { border-left: 4px solid var(--gold); }
.tc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 5px; }
.tc-title { font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.4; }
.tc-badges { display: flex; gap: 5px; flex-shrink: 0; flex-wrap: wrap; }
.tc-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tc-bottom { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tc-amount { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 3px; font-weight: 500; }

/* ---- BADGES ---- */
.badge { font-size: 11px; padding: 3px 10px; border-radius: 20px; font-weight: 600; white-space: nowrap; }
.badge-pending  { background: var(--info-bg); color: var(--info); }
.badge-approved { background: var(--ok-bg); color: var(--ok); }
.badge-rejected { background: var(--danger-bg); color: var(--danger); }
.badge-delivered{ background: var(--green-light); color: var(--green-dark); }
.badge-urgent   { background: var(--warn-bg); color: var(--warn); }
.badge-normal   { background: var(--gray-light); color: var(--gray); }
.badge-dept     { background: var(--green-light); color: var(--green); }
.file-pill, .comment-pill { font-size: 11px; display: inline-flex; align-items: center; gap: 3px; padding: 3px 10px; border-radius: 20px; font-weight: 500; }
.file-pill    { background: var(--info-bg); color: var(--info); }
.comment-pill { background: var(--green-light); color: var(--green); }

/* ---- FILTERS ---- */
.filters-form { margin-bottom: 1.1rem; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.filter-btn { background: var(--surface); border: 1px solid var(--border-hover); border-radius: 20px; padding: 5px 15px; font-size: 12px; font-weight: 500; cursor: pointer; color: var(--text-muted); text-decoration: none; transition: all .15s; }
.filter-btn:hover { background: var(--gray-light); color: var(--text); }
.filter-btn.active { background: var(--green); color: #fff; border-color: var(--green); }
.filter-select { border: 1px solid var(--border-hover); border-radius: var(--radius-md); padding: 5px 10px; font-size: 12px; background: var(--surface); color: var(--text); cursor: pointer; }

/* ---- EMPTY STATE ---- */
.empty-state { text-align: center; padding: 3.5rem 1rem; color: var(--text-muted); }
.empty-state i { font-size: 48px; margin-bottom: 1rem; display: block; opacity: .3; }
.empty-state p { font-size: 15px; }

/* ---- DETAIL VIEW ---- */
.detail-layout { display: grid; grid-template-columns: 1fr 290px; gap: 1.1rem; align-items: start; }
@media (max-width: 768px) { .detail-layout { grid-template-columns: 1fr; } }
.detail-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.4rem; box-shadow: var(--shadow-sm); }
.detail-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; margin-bottom: 1.1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.detail-title { font-size: 19px; font-weight: 700; color: var(--text); flex: 1; line-height: 1.4; }
.detail-badges { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
.detail-subtitle { font-size: 11px; font-weight: 700; margin-bottom: .85rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .6px; }
.detail-meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; margin-bottom: 1.1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.meta-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 3px; font-weight: 600; }
.meta-val { font-size: 14px; font-weight: 600; color: var(--text); }
.detail-section { margin-bottom: 1rem; }
.detail-desc { font-size: 14px; color: var(--text); line-height: 1.7; margin-top: 5px; background: var(--gray-light); padding: .85rem 1rem; border-radius: var(--radius-md); }
.file-link { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--info); text-decoration: none; font-weight: 500; background: var(--info-bg); padding: 7px 14px; border-radius: var(--radius-md); border: 1px solid rgba(18,85,160,.15); transition: opacity .15s; }
.file-link:hover { opacity: .8; }
.comment-box { background: var(--green-light); border-radius: var(--radius-md); border-left: 4px solid var(--green); padding: 1rem 1.1rem; margin-top: 1rem; }
.comment-label { font-size: 11px; color: var(--green); font-weight: 700; margin-bottom: 5px; text-transform: uppercase; letter-spacing: .5px; display: flex; align-items: center; gap: 5px; }
.comment-text { font-size: 14px; color: var(--text); line-height: 1.6; }
.historial-list { display: flex; flex-direction: column; gap: .6rem; }
.historial-item { display: flex; gap: .85rem; }
.historial-dot { width: 10px; height: 10px; background: var(--green); border-radius: 50%; flex-shrink: 0; margin-top: 5px; }
.historial-content { font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.historial-user { font-weight: 600; color: var(--text); }
.historial-date { font-size: 11px; display: block; color: var(--text-muted); margin-top: 2px; }
.detail-sidebar { display: flex; flex-direction: column; gap: .85rem; }
.action-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.1rem; box-shadow: var(--shadow-sm); }
.action-title { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: .85rem; }

/* ---- FORM ---- */
.form-wrap { max-width: 700px; }
.field-group { margin-bottom: 1.1rem; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.field-hint { font-weight: 400; color: var(--text-muted); font-size: 12px; }
.required { color: var(--danger); }
.field-input { width: 100%; border: 1px solid var(--border-hover); border-radius: var(--radius-md); padding: 10px 13px; font-size: 14px; background: var(--surface); color: var(--text); font-family: inherit; transition: border-color .15s, box-shadow .15s; }
.field-input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(10,92,71,.1); }
textarea.field-input { resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 500px) { .form-row { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: .75rem; margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.file-drop { border: 2px dashed var(--border-hover); border-radius: var(--radius-lg); padding: 2rem; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; background: var(--gray-light); }
.file-drop:hover, .file-drop.drag-over { border-color: var(--green); background: var(--green-light); }

/* ---- MODAL DE CONFIRMACION ---- */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,.55); z-index: 9999; display: none; align-items: center; justify-content: center; padding: 1.5rem; backdrop-filter: blur(3px); }
.modal-overlay.open { display: flex; }
.modal-box { background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.3); overflow: hidden; animation: modalIn .2s ease; }
@keyframes modalIn { from { opacity: 0; transform: scale(.95) translateY(-10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header { background: var(--green-dark); padding: 1rem 1.5rem; display: flex; align-items: center; gap: .85rem; border-bottom: 2px solid var(--gold); }
.modal-header img { height: 30px; background: #fff; border-radius: 5px; padding: 3px 8px; }
.modal-header-text { color: rgba(255,255,255,.85); font-size: 13px; font-weight: 600; letter-spacing: .3px; }
.modal-body { padding: 1.75rem 1.5rem; text-align: center; }
.modal-icon { font-size: 44px; margin-bottom: .75rem; display: block; }
.modal-title-text { font-size: 17px; font-weight: 700; color: var(--text); margin-bottom: .5rem; }
.modal-desc { font-size: 14px; color: var(--text-muted); line-height: 1.6; }
.modal-footer { padding: 1rem 1.5rem; background: var(--gray-light); display: flex; gap: .75rem; justify-content: flex-end; border-top: 1px solid var(--border); }

/* ---- LOGIN ---- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(150deg, var(--green-dark) 0%, #0A3D2E 60%, #052B20 100%); padding: 1.5rem; }
.login-wrap { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 1.5rem; }
.login-logo { text-align: center; padding: 1rem 0; }
.login-logo img { height: 80px; background: #fff; border-radius: 10px; padding: 8px 16px; }
.login-logo-subtitle { font-size: 12px; color: rgba(255,255,255,.45); margin-top: .6rem; letter-spacing: 1px; text-transform: uppercase; }
.login-card { background: var(--surface); border-radius: var(--radius-lg); padding: 2rem; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-card-title { font-size: 17px; font-weight: 700; color: var(--text); margin-bottom: 1.5rem; text-align: center; border-bottom: 1px solid var(--border); padding-bottom: 1rem; }
.login-hint { font-size: 12px; color: rgba(255,255,255,.45); line-height: 1.7; text-align: center; }
.login-hint code { font-size: 12px; background: rgba(255,255,255,.1); padding: 1px 6px; border-radius: 4px; color: rgba(255,255,255,.65); }

/* ---- FOOTER ---- */
.site-footer { text-align: center; font-size: 12px; color: var(--text-muted); padding: 1.5rem; margin-top: 2rem; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: center; gap: .6rem; position: relative; z-index: 0; }
.site-footer img { height: 22px; opacity: .8; }

/* ============================================================
   RESPONSIVE MOBILE
   ============================================================ */

@media (max-width: 768px) {

    /* Topbar mobile */
    .topbar {
        height: auto;
        flex-wrap: wrap;
        padding: .6rem 1rem;
        gap: .5rem;
    }
    .topbar-left { flex: 1; }
    .topbar-logo img { height: 26px; }
    .topbar-divider { display: none; }
    .topbar-dept { display: none; }
    .topbar-nav {
        order: 3;
        width: 100%;
        justify-content: center;
        border-top: 1px solid rgba(255,255,255,.1);
        padding-top: .5rem;
        gap: 0;
    }
    .topbar-link {
        flex: 1;
        justify-content: center;
        font-size: 12px;
        padding: 6px 8px;
        text-align: center;
        flex-direction: column;
        gap: 2px;
    }
    .topbar-link i { font-size: 20px; }
    .topbar-right { gap: .5rem; }
    .topbar-user { font-size: 12px; }
    .btn-logout { padding: 4px 10px; font-size: 12px; }

    /* Main wrap */
    .main-wrap { padding: 1rem .85rem; }

    /* Page header */
    .page-header { margin-bottom: 1rem; }
    .page-title { font-size: 18px; }

    /* Stats grid — 2 columnas en mobile */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-bottom: 1.25rem;
    }
    .stat-val { font-size: 26px; }

    /* Ticket cards */
    .ticket-card { padding: .85rem 1rem; }
    .tc-top { flex-direction: column; gap: 6px; }
    .tc-badges { flex-wrap: wrap; }

    /* Detail layout — columna única */
    .detail-layout {
        grid-template-columns: 1fr;
        gap: .85rem;
    }
    .detail-sidebar { order: -1; } /* Acciones arriba en mobile */
    .detail-card { padding: 1rem; }
    .detail-card-header { flex-direction: column; gap: .5rem; }
    .detail-title { font-size: 16px; }
    .detail-meta-grid { grid-template-columns: 1fr 1fr; gap: .6rem; }

    /* Botones de acción en mobile */
    .action-card { padding: .85rem; }
    .btn-success, .btn-danger, .btn-delivered, .btn-primary {
        padding: 11px 16px;
        font-size: 14px;
    }

    /* Formulario */
    .form-row { grid-template-columns: 1fr; }
    .form-actions { flex-direction: column; }
    .form-actions .btn-ghost { text-align: center; justify-content: center; }

    /* Filters */
    .filters { gap: 5px; }
    .filter-btn { padding: 5px 11px; font-size: 11px; }

    /* Modal */
    .modal-box { margin: 0 .5rem; }
    .modal-body { padding: 1.25rem 1rem; }
    .modal-footer { flex-direction: column-reverse; }
    .modal-footer button { width: 100%; justify-content: center; }

    /* Login */
    .login-logo img { height: 60px; }
    .login-card { padding: 1.5rem 1.25rem; }

    /* Footer */
    .site-footer { font-size: 11px; flex-direction: column; gap: .3rem; }
}

@media (max-width: 400px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .topbar-user span { display: none; }
}

/* ============================================================
   KANBAN - Panel de 3 columnas
   ============================================================ */

.kanban-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    align-items: start;
}

.kanban-col {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.kanban-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: .85rem 1rem;
    font-weight: 700; font-size: 13px;
    border-bottom: 1px solid var(--border);
}
.kanban-header-pending  { background: #EEF4FF; color: var(--info); border-bottom-color: #C7D9F8; }
.kanban-header-approved { background: var(--ok-bg); color: var(--ok); border-bottom-color: #C3E6A0; }
.kanban-header-rejected { background: var(--danger-bg); color: var(--danger); border-bottom-color: #F5C0C0; }

.kanban-title { display: flex; align-items: center; gap: 6px; }
.kanban-title i { font-size: 16px; }

.kanban-count {
    background: rgba(0,0,0,.1);
    border-radius: 20px;
    padding: 2px 10px;
    font-size: 12px;
    font-weight: 700;
}

.kanban-body { padding: .75rem; display: flex; flex-direction: column; gap: .5rem; min-height: 100px; }

.kanban-card {
    display: block; text-decoration: none; color: inherit;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: .75rem .85rem;
    transition: border-color .15s, box-shadow .15s, transform .1s;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.kanban-card:hover { border-color: var(--green); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kanban-urgent  { border-left: 3px solid var(--gold); background: #FFFDF5; }
.kanban-delivered { border-left: 3px solid var(--green-mid); background: #F2FBF7; }
.kanban-card-rejected { background: #FFF8F8; }

.kanban-urgent-badge {
    font-size: 10px; font-weight: 700; color: var(--warn);
    background: var(--warn-bg); padding: 2px 8px; border-radius: 20px;
    display: inline-flex; align-items: center; gap: 3px;
    margin-bottom: 5px;
}
.kanban-delivered-badge {
    font-size: 10px; font-weight: 700; color: var(--green);
    background: var(--green-light); padding: 2px 8px; border-radius: 20px;
    display: inline-flex; align-items: center; gap: 3px;
    margin-bottom: 5px;
}

.kanban-card-title { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.4; margin-bottom: 3px; }
.kanban-card-meta  { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.kanban-card-dept  { font-size: 11px; color: var(--green); font-weight: 600; margin-bottom: 4px; }
.kanban-comment    { font-size: 11px; color: var(--text-muted); font-style: italic; margin: 4px 0; display: flex; align-items: flex-start; gap: 4px; line-height: 1.4; }
.kanban-comment i  { flex-shrink: 0; margin-top: 1px; }

.kanban-card-footer {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 6px; padding-top: 6px;
    border-top: 1px solid var(--border);
}
.kanban-date   { font-size: 10px; color: var(--text-muted); }
.kanban-amount { font-size: 11px; color: var(--text-muted); font-weight: 600; }

.kanban-empty  { font-size: 12px; color: var(--text-muted); text-align: center; padding: 1.5rem .5rem; opacity: .7; }

.kanban-ver-mas {
    display: block; text-align: center;
    font-size: 12px; color: var(--green); font-weight: 600;
    padding: .5rem; text-decoration: none;
    border-top: 1px solid var(--border);
    margin-top: .25rem;
    border-radius: var(--radius-sm);
    transition: background .15s;
}
.kanban-ver-mas:hover { background: var(--green-light); }

/* Mobile: kanban en columna única */
@media (max-width: 768px) {
    .kanban-grid { grid-template-columns: 1fr; }
    .kanban-col { max-height: none; }
}

/* ============================================================
   PRESUPUESTO
   ============================================================ */

.ppto-dept-row {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem 1.1rem;
    margin-bottom: .6rem;
    transition: border-color .15s;
}
.ppto-dept-row:hover { border-color: var(--border-hover); }
.ppto-selected { border-color: var(--green) !important; }

.ppto-detalle {
    margin-top: .85rem;
    padding-top: .85rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.ppto-ticket {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .6rem .75rem;
    background: var(--gray-light);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: inherit;
    transition: background .15s;
    border: 1px solid transparent;
}
.ppto-ticket:hover { background: var(--green-light); border-color: var(--green); }

/* ============================================================
   USUARIOS
   ============================================================ */

.user-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

/* ============================================================
   FONDO DE CAMPO DE GOLF
   ============================================================ */

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,.55);
    z-index: 0;
    pointer-events: none;
}

.topbar, .flash, main.main-wrap { position: relative; z-index: 1; }
.site-footer { position: relative; z-index: 0; }
.login-body::before { display: none; }
.login-body {
    background-image: url('../img/fondo_campo.webp');
    background-size: cover;
    background-position: center;
}
.login-body::after {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(6,61,48,.75);
    z-index: 0;
}
.login-wrap { position: relative; z-index: 1; }

/* ============================================================
   CALENDARIO DE GASTOS
   ============================================================ */

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.cal-header-day {
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: 6px 4px;
    background: var(--gray-light);
    border-radius: var(--radius-sm);
}

.cal-cell {
    min-height: 80px;
    max-height: 120px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 5px;
    background: var(--surface);
    vertical-align: top;
    transition: border-color .15s;
    overflow: hidden;
}

.cal-cell:hover {
    max-height: none;
    overflow: visible;
    z-index: 10;
    position: relative;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
}

.cal-cell-empty { background: rgba(0,0,0,.02); border-color: transparent; }
.cal-cell-active { border-color: var(--green-mid); background: #F8FEFB; }
.cal-cell-today { border-color: var(--gold) !important; box-shadow: 0 0 0 1px var(--gold); }

.cal-day-num {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.cal-today-num {
    color: var(--gold);
    font-weight: 700;
}

.cal-events { display: flex; flex-direction: column; gap: 2px; }

.cal-event {
    font-size: 10px;
    color: #fff;
    padding: 2px 5px;
    border-radius: 3px;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: default;
}

.cal-day-total {
    font-size: 10px;
    font-weight: 700;
    color: var(--green);
    margin-top: 3px;
    text-align: right;
}

@media (max-width: 768px) {
    .cal-grid { gap: 2px; }
    .cal-cell { min-height: 50px; padding: 3px; }
    .cal-header-day { font-size: 9px; padding: 4px 2px; }
    .cal-day-num { font-size: 10px; }
    .cal-event { font-size: 8px; padding: 1px 3px; }
}

/* ============================================================
   OJO CONTRASEÑA
   ============================================================ */

.password-wrap {
    position: relative;
}
.password-wrap .field-input {
    padding-right: 42px;
}
.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    display: flex;
    align-items: center;
    font-size: 18px;
    transition: color .15s;
}
.password-toggle:hover { color: var(--text); }

/* ============================================================
   PRESUPUESTO - Layout 2 columnas
   ============================================================ */

.ppto-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1rem;
    align-items: start;
}

.ppto-col-left { display: flex; flex-direction: column; gap: 0; }
.ppto-col-right { position: sticky; top: 70px; }

@media (max-width: 900px) {
    .ppto-layout { grid-template-columns: 1fr; }
    .ppto-col-right { position: static; }
}

/* ============================================================
   KANBAN - Scroll interno
   ============================================================ */

.kanban-body {
    max-height: 580px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-hover) transparent;
}

.kanban-body::-webkit-scrollbar { width: 4px; }
.kanban-body::-webkit-scrollbar-track { background: transparent; }
.kanban-body::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 4px; }
.kanban-body::-webkit-scrollbar-thumb:hover { background: var(--gray); }

/* ============================================================
   COMUNICACIÓN INTERNA
   ============================================================ */

.com-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 1rem;
    align-items: start;
}

@media (max-width: 768px) {
    .com-layout { grid-template-columns: 1fr; }
}

.com-lista {
    position: sticky;
    top: 70px;
    max-height: 580px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-hover) transparent;
    border-radius: var(--radius-lg);
}
.com-lista::-webkit-scrollbar { width: 4px; }
.com-lista::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 4px; }
.com-lista .detail-card { overflow: visible; }

.com-item {
    display: block; text-decoration: none; color: inherit;
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--border);
    transition: background .15s;
}
.com-item:hover { background: var(--gray-light); }
.com-item-unread { background: var(--green-light); }
.com-item-unread:hover { background: #d4eee5; }

.com-item-icon {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; flex-shrink: 0;
}
.com-icon-msg  { background: var(--green-light); color: var(--green); }
.com-icon-aviso{ background: var(--warn-bg); color: var(--warn); }

/* Chat */
.chat-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    height: 600px;
    min-height: 400px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    position: relative;
    z-index: 2;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
    scrollbar-width: thin;
}

.chat-msg { display: flex; }
.chat-msg-mine   { justify-content: flex-end; }
.chat-msg-theirs { justify-content: flex-start; }

.chat-bubble {
    max-width: 70%;
    border-radius: var(--radius-lg);
    padding: .75rem 1rem;
    position: relative;
}
.chat-bubble-mine   { background: var(--green); color: #fff; border-bottom-right-radius: 4px; }
.chat-bubble-theirs { background: var(--gray-light); color: var(--text); border-bottom-left-radius: 4px; border: 1px solid var(--border); }

.chat-sender { font-size: 11px; font-weight: 700; margin-bottom: 4px; color: var(--green); }
.chat-bubble-mine .chat-sender { color: rgba(255,255,255,.8); }
.chat-content { font-size: 14px; line-height: 1.6; }
.chat-time { font-size: 10px; margin-top: 4px; opacity: .6; text-align: right; }

.chat-input-wrap {
    padding: .85rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
}
.chat-input { resize: none; }

/* Número de ticket */
.ticket-num {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--gray-light);
    padding: 2px 8px;
    border-radius: 20px;
    font-family: monospace;
    letter-spacing: .5px;
}

/* Chat general */
.chat-general-badge {
    background: var(--gold);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.com-dept-badge {
    background: var(--info-bg);
    color: var(--info);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
}


/* ============================================================
   MOBILE - Diseño optimizado para móvil v2
   ============================================================ */

@media (max-width: 768px) {

    /* --- TOPBAR MÓVIL --- */
    .topbar {
        height: auto;
        padding: 0;
        flex-direction: column;
        gap: 0;
    }
    .topbar-left {
        width: 100%;
        padding: 8px 12px;
        justify-content: space-between;
    }
    .topbar-logo img { height: 28px; }
    .topbar-divider { display: none; }
    .topbar-dept { font-size: 11px; }
    .topbar-right {
        position: absolute;
        top: 8px;
        right: 12px;
        gap: 8px;
    }
    .topbar-user { display: none; }
    .btn-logout { font-size: 11px; padding: 4px 8px; }

    /* Navegación inferior fija en móvil */
    .topbar-nav {
        width: 100%;
        border-top: 1px solid rgba(255,255,255,.15);
        display: flex;
        justify-content: space-around;
        padding: 2px 0;
        background: var(--green-dark);
    }
    .topbar-link {
        flex: 1;
        flex-direction: column;
        gap: 2px;
        padding: 6px 4px;
        font-size: 10px;
        text-align: center;
        border-radius: 0;
        justify-content: center;
    }
    .topbar-link i { font-size: 20px; }
    .topbar-link span { display: none; }

    /* --- MAIN WRAP --- */
    .main-wrap { padding: .75rem .7rem; }

    /* --- PAGE HEADER --- */
    .page-header { margin-bottom: .85rem; flex-wrap: wrap; gap: .5rem; }
    .page-title { font-size: 17px; }

    /* --- STATS GRID --- */
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        margin-bottom: 1rem;
    }
    .stat-card { padding: .65rem .75rem; }
    .stat-label { font-size: 9px; margin-bottom: 3px; }
    .stat-val { font-size: 22px; }

    /* --- KANBAN --- */
    .kanban-grid { grid-template-columns: 1fr; gap: .75rem; }
    .kanban-body { max-height: 280px; }
    .kanban-card { padding: .65rem .75rem; }
    .kanban-card-title { font-size: 12px; }
    .kanban-card-meta { font-size: 10px; }
    .kanban-card-dept { font-size: 10px; }

    /* --- TICKET CARDS --- */
    .ticket-card { padding: .75rem .85rem; }
    .tc-top { flex-direction: column; gap: 5px; }
    .tc-title { font-size: 13px; }
    .tc-badges { flex-wrap: wrap; }
    .tc-meta { font-size: 11px; }

    /* --- FILTERS --- */
    .filters { gap: 4px; }
    .filter-btn { padding: 4px 10px; font-size: 11px; }
    .filter-select { font-size: 11px; padding: 4px 6px; }
    .filters-form { margin-bottom: .75rem; }

    /* --- DETAIL LAYOUT --- */
    .detail-layout { grid-template-columns: 1fr; gap: .75rem; }
    .detail-sidebar { order: -1; }
    .detail-card { padding: .85rem; }
    .detail-card-header { flex-direction: column; gap: .5rem; }
    .detail-title { font-size: 15px; }
    .detail-meta-grid { grid-template-columns: 1fr 1fr; gap: .5rem; }
    .meta-val { font-size: 13px; }

    /* --- ACTION BUTTONS --- */
    .btn-success, .btn-danger, .btn-delivered {
        padding: 10px 14px;
        font-size: 13px;
    }
    .btn-primary { padding: 8px 14px; font-size: 13px; }
    .btn-ghost { padding: 7px 12px; font-size: 12px; }

    /* --- FORM --- */
    .form-row { grid-template-columns: 1fr; gap: .75rem; }
    .form-actions { flex-direction: column; gap: .5rem; }
    .form-actions > * { width: 100%; justify-content: center; }
    .field-input { font-size: 16px; } /* 16px evita zoom en iOS */

    /* --- MODAL --- */
    .modal-box { margin: .5rem; max-height: 90vh; overflow-y: auto; }
    .modal-body { padding: 1.25rem 1rem; }
    .modal-footer { flex-direction: column-reverse; gap: .5rem; }
    .modal-footer button { width: 100%; justify-content: center; }

    /* --- COMUNICACION --- */
    .com-layout { grid-template-columns: 1fr; }
    .com-lista { position: static; max-height: 300px; }
    .chat-wrap { height: calc(100vh - 220px); min-height: 300px; }
    .chat-bubble { max-width: 85%; }
    .chat-content { font-size: 13px; }

    /* --- PRESUPUESTO --- */
    .ppto-layout { grid-template-columns: 1fr; }
    .ppto-col-right { position: static; }
    .cal-grid { gap: 2px; }
    .cal-cell { min-height: 44px; padding: 2px 3px; }
    .cal-header-day { font-size: 9px; padding: 3px 2px; }
    .cal-day-num { font-size: 9px; }
    .cal-event { font-size: 8px; padding: 1px 3px; }

    /* --- LOGIN --- */
    .login-logo img { height: 55px; }
    .login-card { padding: 1.25rem 1rem; }

    /* --- FOOTER --- */
    .site-footer { font-size: 11px; flex-direction: column; gap: .25rem; padding: 1rem; }
    .site-footer img { height: 16px; }

    /* --- TIPO OPCIONES COMUNICACION --- */
    .tipo-label { padding: .5rem .25rem; font-size: 11px; }
}

@media (max-width: 380px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-val { font-size: 20px; }
    .topbar-link { font-size: 9px; }
    .topbar-link i { font-size: 18px; }
}

/* Footer siempre debajo del chat */
.com-layout + .site-footer,
main.main-wrap + .site-footer {
    margin-top: 2rem;
    position: relative;
    z-index: 0;
}
