:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --bg: #f4f5fa;
    --card-bg: #ffffff;
    --border: #e4e6f0;
    --text: #1f2333;
    --text-muted: #6b7280;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(20,20,50,0.08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

/* ---------- Auth ---------- */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    padding: 20px;
}
.auth-card {
    background: #fff;
    border-radius: 16px;
    padding: 36px 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    text-align: center;
}
.auth-logo {
    width: 56px; height: 56px; line-height: 56px;
    background: var(--primary); color: #fff; font-weight: 700;
    border-radius: 14px; margin: 0 auto 12px; font-size: 18px;
}
.auth-card h1 { margin: 0 0 4px; font-size: 22px; }
.auth-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 20px; }
.auth-form { text-align: left; display: flex; flex-direction: column; gap: 4px; }

label { font-size: 13px; font-weight: 600; margin-top: 10px; color: #374151; }
input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    margin-top: 4px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 16px; border-radius: 8px; border: none;
    font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none;
    transition: background 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: #f0f0f8; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-block { width: 100%; margin-top: 18px; }

.alert { padding: 10px 12px; border-radius: 8px; font-size: 13px; margin: 12px 0; text-align: left; }
.alert-error { background: #fee2e2; color: #b91c1c; }
.alert-info { background: #e0e7ff; color: #3730a3; }

/* ---------- Navbar ---------- */
.navbar {
    display: flex; align-items: center; gap: 24px;
    background: #fff; border-bottom: 1px solid var(--border);
    padding: 12px 24px; position: sticky; top: 0; z-index: 20;
}
.navbar-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.navbar-logo { background: var(--primary); color: #fff; width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.navbar-links { display: flex; gap: 4px; flex: 1; }
.navbar-links a { padding: 8px 14px; border-radius: 8px; text-decoration: none; color: var(--text-muted); font-weight: 600; font-size: 14px; }
.navbar-links a.active, .navbar-links a:hover { background: #eef0fc; color: var(--primary); }
.navbar-user { display: flex; align-items: center; gap: 10px; position: relative; cursor: pointer; padding: 6px 8px; border-radius: 10px; user-select: none; }
.navbar-user:hover { background: #f0f0f8; }
.navbar-user-info { display: flex; flex-direction: column; line-height: 1.2; font-size: 13px; }
.navbar-user-info small { color: var(--text-muted); }
.dropdown-caret { font-size: 10px; color: var(--text-muted); margin-left: -2px; }

.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(20,20,60,0.15);
    min-width: 170px;
    overflow: hidden;
    z-index: 50;
}
.user-dropdown.open { display: block; }
.user-dropdown a {
    display: block;
    padding: 10px 14px;
    text-decoration: none;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
}
.user-dropdown a:hover, .user-dropdown a.active { background: #eef0fc; color: var(--primary); }
.user-dropdown .dropdown-divider { border-top: 1px solid var(--border); margin: 2px 0; }

.avatar { width: 34px; height: 34px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.avatar-lg { width: 52px; height: 52px; font-size: 20px; margin-bottom: 8px; }
.avatar-sm { width: 26px; height: 26px; font-size: 11px; }

/* ---------- Layout ---------- */
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.board { display: flex; flex-direction: column; gap: 28px; }
.board-section { background: var(--card-bg); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.section-header h2 { margin: 0; font-size: 17px; }
.hint { color: var(--text-muted); font-size: 13px; margin: 0 0 14px; }

.empty-state, .empty-state-sm { color: var(--text-muted); font-size: 13px; padding: 12px 0; }

/* ---------- Task cards ---------- */
.task-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.task-card {
    background: #fbfbfe; border: 1px solid var(--border); border-radius: 10px;
    padding: 12px; cursor: pointer; transition: box-shadow 0.15s, transform 0.15s;
}
.task-card.draggable { cursor: grab; }
.task-card:hover { box-shadow: 0 4px 14px rgba(20,20,60,0.1); }
.task-card.dragging { opacity: 0.4; }
.task-card h4 { margin: 6px 0 4px; font-size: 14px; }
.task-card-top { display: flex; justify-content: space-between; align-items: center; }
.task-due { color: var(--text-muted); font-size: 12px; margin: 0; }
.task-card.overdue { border-color: #fca5a5; }
.attach-badge { font-size: 11px; color: var(--text-muted); }
.task-actions { display: flex; gap: 6px; margin-top: 10px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: capitalize; }
.priority-baja { background: #dcfce7; color: #166534; }
.priority-media { background: #fef3c7; color: #92400e; }
.priority-alta { background: #fed7aa; color: #9a3412; }
.priority-urgente { background: #fecaca; color: #991b1b; }
.badge-role { background: #e0e7ff; color: #3730a3; margin: 6px 0; }
.badge-status { background: #e5e7eb; color: #374151; }
.status-en_progreso { background: #dbeafe; color: #1e40af; }
.status-completada { background: #dcfce7; color: #166534; }
.status-cancelada { background: #fee2e2; color: #991b1b; }

/* ---------- Team / dropzones ---------- */
.team-grid, .user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.user-card {
    background: #fbfbfe; border: 2px dashed var(--border); border-radius: 12px;
    padding: 16px; text-align: center; transition: all 0.15s;
}
.user-card.inactive { opacity: 0.5; }
.user-card h3 { margin: 0; font-size: 14px; }
.user-card .user-email { font-size: 12px; color: var(--text-muted); margin: 4px 0; }
.user-card .via { display: block; color: #9ca3af; font-size: 11px; }
.user-card .user-pending { font-size: 12px; color: var(--text-muted); margin: 6px 0 8px; }
.dropzone.drag-over { border-color: var(--primary); background: #eef0fc; transform: scale(1.02); }

.user-card-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.btn-danger { color: #b91c1c; border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }

.account-card { max-width: 520px; }
.account-summary { display: flex; align-items: center; gap: 14px; }
.account-summary h3 { margin: 0 0 4px; }
.narrow-form { max-width: 360px; }
.form-success { color: #166534; font-size: 13px; margin-top: 8px; }
hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ---------- Tracking ---------- */
.tracking-list { display: flex; flex-direction: column; gap: 8px; }
.tracking-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; cursor: pointer; }
.tracking-row:hover { background: #f7f7fc; }
.tracking-info { flex: 1; display: flex; flex-direction: column; }
.tracking-info small { color: var(--text-muted); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,15,30,0.5); display: none; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal.open { display: flex; }
.modal-content { background: #fff; border-radius: 14px; padding: 24px; width: 100%; max-width: 440px; max-height: 88vh; overflow-y: auto; }
.modal-wide { max-width: 600px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { color: #b91c1c; font-size: 13px; margin-top: 8px; }

.task-detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.task-detail-header h2 { margin: 0; font-size: 18px; }
.task-detail-header-actions { display: flex; gap: 6px; flex-shrink: 0; }
.task-detail-badges { display: flex; gap: 8px; margin: 10px 0; }
.detail-table { width: 100%; font-size: 13px; margin: 12px 0; }
.detail-table td { padding: 4px 0; color: var(--text-muted); }
.detail-table td:first-child { width: 40%; color: var(--text-muted); }
.detail-table td:last-child { color: var(--text); font-weight: 600; }
.attachment-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.attachment-item { text-decoration: none; color: var(--primary); font-size: 13px; }
.history-list { display: flex; flex-direction: column; gap: 6px; font-size: 13px; max-height: 160px; overflow-y: auto; }
.history-item { display: flex; justify-content: space-between; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.history-item small { color: var(--text-muted); }

/* ---------- Toast ---------- */
.toast {
    position: fixed; bottom: 20px; right: 20px; background: #1f2333; color: #fff;
    padding: 12px 18px; border-radius: 10px; font-size: 13px; opacity: 0; transform: translateY(10px);
    transition: all 0.25s; z-index: 200; max-width: 320px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-warning { background: #92400e; }

@media (max-width: 640px) {
    .navbar { flex-wrap: wrap; gap: 10px; }
    .navbar-links { order: 3; width: 100%; }
    .form-row { grid-template-columns: 1fr; }
}
